File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,4 @@ resource:
3434 tool :
3535 enabled : true
3636type : plugin
37- version : 0.7.2
37+ version : 0.7.3
Original file line number Diff line number Diff line change @@ -578,7 +578,9 @@ def build_parts(
578578
579579 # Handle text content (remove thinking tags)
580580 if message .content :
581- parts .extend (build_parts (message .content , is_assistant_tree = True ))
581+ part = build_parts (message .content , is_assistant_tree = True )
582+ if part :
583+ parts .extend (part )
582584
583585 # Handle tool calls
584586 # https://ai.google.dev/gemini-api/docs/function-calling?hl=zh-cn&example=chart#how-it-works
@@ -590,6 +592,10 @@ def build_parts(
590592 _unsafe_part .thought_signature = DEFAULT_THOUGHT_SIGNATURE
591593 parts .append (_unsafe_part )
592594
595+ # Filter out assistant messages with empty parts to avoid invalid requests
596+ if not parts :
597+ return None
598+
593599 return types .Content (role = "model" , parts = parts )
594600
595601 elif isinstance (message , SystemPromptMessage ):
@@ -709,7 +715,7 @@ def _handle_generate_stream_response(
709715 if (
710716 not chunk .candidates
711717 or not chunk .candidates [0 ].content
712- or not chunk .candidates [0 ].content .parts
718+ or ( not chunk .candidates [0 ].content .parts and not chunk . candidates [ 0 ]. finish_reason )
713719 ):
714720 continue
715721 candidate = chunk .candidates [0 ]
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ urllib3==2.6.0
184184 # via requests
185185websockets == 15.0.1
186186 # via google-genai
187- werkzeug == 3.1.4
187+ werkzeug >= 3.0.3 , < 3.1.dev0
188188 # via
189189 # dify-plugin
190190 # flask
You can’t perform that action at this time.
0 commit comments