Skip to content

Commit

Permalink
fix: tongyi multimodal response format error response process
Browse files Browse the repository at this point in the history
  • Loading branch information
achenglike authored Dec 10, 2024
1 parent f56728b commit b46152f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions libs/community/langchain_community/chat_models/tongyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,17 @@ def _stream_completion_with_retry(**_kwargs: Any) -> Any:
):
# inline fix response text logic
resp_copy = json.loads(json.dumps(resp))
choice = resp_copy["output"]["choices"][0]
message = choice["message"]
if isinstance(message.get("content"), list):
content_text = "".join(
item.get("text", "")
for item in message["content"]
if isinstance(item, dict)
)
message["content"] = content_text
resp = resp_copy
if resp_copy.get("output") and resp_copy["output"].get("choices"):
choice = resp_copy["output"]["choices"][0]
message = choice["message"]
if isinstance(message.get("content"), list):
content_text = "".join(
item.get("text", "")
for item in message["content"]
if isinstance(item, dict)
)
message["content"] = content_text
resp = resp_copy
if prev_resp is None:
delta_resp = resp
else:
Expand Down

0 comments on commit b46152f

Please sign in to comment.