-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ChatMistralAI with chat history : Assistant message must have either content or tool_calls error #21196
Comments
…using tool_calls or content) (#21201) This PR fixes #21196. The error was occurring when calling chat completion API with a chat history. Indeed, the Mistral API does not accept both `content` and `tool_calls` in the same body. This PR removes one of theses variables depending on the necessity. --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr> Co-authored-by: Chester Curme <chester.curme@gmail.com>
This was patched in langchain-mistralai==0.1.6, please re-open if this is not fixed on upgrade. Thank you for the catch. |
…using tool_calls or content) (langchain-ai#21201) This PR fixes langchain-ai#21196. The error was occurring when calling chat completion API with a chat history. Indeed, the Mistral API does not accept both `content` and `tool_calls` in the same body. This PR removes one of theses variables depending on the necessity. --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr> Co-authored-by: Chester Curme <chester.curme@gmail.com>
I am encountering the same issue - invoking model with tools and chat history resulting in error message:
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 ( |
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 the
tool_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
The text was updated successfully, but these errors were encountered: