Closed maximeperrindev closed 5 months ago
This was patched in langchain-mistralai==0.1.6, please re-open if this is not fixed on upgrade.
Thank you for the catch.
I am encountering the same issue - invoking model with tools and chat history resulting in error message:
{"object":"error","message":"Assistant message must have either content or tool_calls, but not both."}
Using @langchain/mistralai 0.0.19. Is it possible that the logic was not fixed in the JS package?
Hey @honzababarik, apologies for missing this - will have a look and report back tomorrow!
@honzababarik fix is live in the latest version (@langchain/mistralai@0.0.22
). Thanks again for reporting, and let me know in the JS repo if you see anything similar pop up again?
Getting the same error with langchain-mistralai
python
langsmith
langchain-mistralai
langchain-community
langchain==0.2.2
langchain-core==0.2.4
httpx.HTTPStatusError: Error response 400 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":"Assistant message must have either content or tool_calls, but not both.","type":"invalid_request_error","param":null,"code":null}
Getting the same error with
langchain-mistralai
pythonlangsmith langchain-mistralai langchain-community langchain==0.2.2 langchain-core==0.2.4
httpx.HTTPStatusError: Error response 400 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":"Assistant message must have either content or tool_calls, but not both.","type":"invalid_request_error","param":null,"code":null}
what version? was patched in langchain-mistralai>=0.1.6
, are you seeing this issue in a later version?
@baskaryan
Name: langchain-mistralai
Version: 0.1.7
Same error with latest (0.1.10) langchain-mistralai version
Checked other resources
Example Code
-
Error Message and Stack Trace (if applicable)
httpx.HTTPStatusError: Error response 400 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":"Assistant message must have either content or tool_calls, but not both.","type":"invalid_request_error","param":null,"code":null}
Description
I'm trying to send a chat completion request to MistralAI API. However, when I send multiple messages with a chat history persitence, the api returns an error saying that it is impossible to include tool_calls AND content in the request.
It is probably related to
_convert_message_to_mistral_chat_message
in the chat_models.py in langchain_mistrail package. We shouldn't thetool_calls
variable if it is empty or we shouldn't return thecontent
variable if we're using tools.I am going to fix this with a PR asap
System Info
-