The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
mistralai: update tool calling (#19451)
ccurmec4599444eed2
diff --git a/libs/partners/mistralai/langchain_mistralai/chat_models.py b/libs/partners/mistralai/langchain_mistralai/chat_models.pyindex eb562b7d9d..2566f999cd 100644--- a/libs/partners/mistralai/langchain_mistralai/chat_models.py+++ b/libs/partners/mistralai/langchain_mistralai/chat_models.py@@ -83,7 +83,7 @@ def _convert_mistral_chat_message_to_message(additional_kwargs: Dict = {}if tool_calls := _message.get("tool_calls"):- additional_kwargs["tool_calls"] = [tc.model_dump() for tc in tool_calls]+ additional_kwargs["tool_calls"] = tool_callsreturn AIMessage(content=content, additional_kwargs=additional_kwargs)diff --git a/libs/partners/mistralai/tests/integration_tests/test_chat_models.py b/libs/partners/mistralai/tests/integration_tests/test_chat_models.pyindex 1bdd99305b..8fdcde33a7 100644--- a/libs/partners/mistralai/tests/integration_tests/test_chat_models.py+++ b/libs/partners/mistralai/tests/integration_tests/test_chat_models.py@@ -61,3 +61,24 @@ def test_invoke() -> None:result = llm.invoke("I'm Pickle Rick", config=dict(tags=["foo"]))assert isinstance(result.content, str)+++def test_structred_output() -> None:+ llm = ChatMistralAI(model="mistral-large-latest", temperature=0)+ schema = {+ "title": "AnswerWithJustification",+ "description": (+ "An answer to the user question along with justification for the answer."+ ),+ "type": "object",+ "properties": {+ "answer": {"title": "Answer", "type": "string"},+ "justification": {"title": "Justification", "type": "string"},+ },+ "required": ["answer", "justification"],+ }+ structured_llm = llm.with_structured_output(schema)+ result = structured_llm.invoke(+ "What weighs more a pound of bricks or a pound of feathers"+ )+ assert isinstance(result, dict)