Skip to content

Commit 299b222

Browse files
authored
mistral[patch]: check types in adding model_name to response_metadata (#30499)
1 parent 22d1a7d commit 299b222

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libs/partners/mistralai/langchain_mistralai/chat_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ def _convert_chunk_to_message_chunk(
274274
}
275275
else:
276276
usage_metadata = None
277-
if _choice.get("finish_reason") is not None:
277+
if _choice.get("finish_reason") is not None and isinstance(
278+
chunk.get("model"), str
279+
):
278280
response_metadata["model_name"] = chunk.get("model")
279281
return AIMessageChunk(
280282
content=content,

0 commit comments

Comments
 (0)