Skip to content

Commit

Permalink
fix empty part checking
Browse files Browse the repository at this point in the history
  • Loading branch information
luxzoli committed Oct 7, 2024
1 parent d292510 commit df95d5f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion autogen/oai/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,12 @@ def is_function_call(parts):
# If this is first message or the role is different from the previous role then append the parts
else:
# If the previous text message is empty then update the text to "empty" as Gemini does not support empty messages
if (len(rst) > 0) and ("text" in rst[-1].parts[0]._raw_part) and (rst[-1].parts[0].text == ""):
if (
(len(rst) > 0)
and hasattr(rst[-1].parts[0], "_raw_part")
and hasattr(rst[-1].parts[0]._raw_part, "text")
and (rst[-1].parts[0].text == "")
):
append_text_to_last("empty")
append_parts(parts, role)

Expand Down

0 comments on commit df95d5f

Please sign in to comment.