mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-05 08:23:17 +00:00
- Add missing 'role' field to tool result ContentType objects - Tool result messages must have role='user' to match Gemini API requirements - Fixes 'contents[2].parts[0].data: required oneof field data' error on second turn - Prevents uninitialized data field in tool result messages
This commit is contained in:
@@ -500,7 +500,7 @@ def _gemini_convert_messages_with_history( # noqa: PLR0915
|
||||
messages[msg_i]["role"] not in tool_call_message_roles
|
||||
):
|
||||
if len(tool_call_responses) > 0:
|
||||
contents.append(ContentType(parts=tool_call_responses))
|
||||
contents.append(ContentType(role="user", parts=tool_call_responses))
|
||||
tool_call_responses = []
|
||||
|
||||
if msg_i == init_msg_i: # prevent infinite loops
|
||||
@@ -510,7 +510,7 @@ def _gemini_convert_messages_with_history( # noqa: PLR0915
|
||||
)
|
||||
)
|
||||
if len(tool_call_responses) > 0:
|
||||
contents.append(ContentType(parts=tool_call_responses))
|
||||
contents.append(ContentType(role="user", parts=tool_call_responses))
|
||||
|
||||
if len(contents) == 0:
|
||||
verbose_logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user