Merge pull request #5384 from miraclebakelaser/fix/cohere-tool-calls-content-field

fix(factory.py): handle missing 'content' in cohere assistant messages
This commit is contained in:
Krish Dholakia 2024-08-27 07:13:28 -07:00 committed by GitHub
commit ec2357f1d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1781,7 +1781,7 @@ def cohere_messages_pt_v2(
assistant_tool_calls: List[ToolCallObject] = []
## MERGE CONSECUTIVE ASSISTANT CONTENT ##
while msg_i < len(messages) and messages[msg_i]["role"] == "assistant":
if isinstance(messages[msg_i]["content"], list):
if messages[msg_i].get("content", None) is not None and isinstance(messages[msg_i]["content"], list):
for m in messages[msg_i]["content"]:
if m.get("type", "") == "text":
assistant_content += m["text"]