AIMessage enforces ToolCall model incompatible with openai #27937
Replies: 1 comment 2 replies
-
Hey @yildirimgoks! 👋 I'm here to help you with bugs, questions, and becoming a contributor. I'm Dosu, a bot designed to assist you while you wait for a human maintainer. There are similar discussions and an issue related to the problem you're encountering:
The problem seems to stem from the differences in the expected format for tool calls between OpenAI and LangChain. LangChain's |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When you provide a value for the 'tool_calls' argument of the AIMessage, root_validator tries to parse the values in it to a ToolCall object using the langchain_core.messages.tool.tool_call function. Although instancing ToolCall by calling it directly with OpenAI compatible tool_calls model is possible, the tool_call() function expects a specific set of variables to build the ToolCall, and does not accept extra keyword variables. This enforces a very specific data model when tool_calls is provided with AIMessage and makes it impossible to create an AIMessage object with the desired tool_calls formatting.
Is this intended or could this be a bug? IIs there a different way of creating an AI message with tool_calls that I'm missing?
Example code:
Beta Was this translation helpful? Give feedback.
All reactions