When Migrating From ChatOpenAI to ChatGroq Binding Functions Raise an Error #20879
-
Checked other resources
Commit to Help
Example Codeoptions = ["FINISH"]
function_def = {
"name": "route",
"description": "Select the next role.",
"parameters": {
"title": "routeSchema",
"type": "object",
"properties": {
"next": {
"title": "Next",
"anyOf": [
{"enum": options},
],
}
},
"required": ["next"],
},
}
supervisor_chain = (
prompt
| model.bind_functions(functions=[function_def], function_call="route")
)
supervisor_chain.invoke({"input": ["what's the date today?"]}) DescriptionI built a langgraph multiagent system similar to Supervisor architecture and it works without any errors with chatgpt System Infolangchain==0.1.16 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
To address the Here's a revised approach using from langchain_community.tools import MoveFileTool
from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
# Initialize your model
model = ChatOpenAI(model="gpt-3.5-turbo")
# Define your tools
tools = [MoveFileTool()]
# Bind tools to the model
model_with_tools = model.bind_tools(tools)
# Invoke the model with tools
message = model_with_tools.invoke([HumanMessage(content="move file foo to bar")]) This code snippet demonstrates how to correctly bind tools to your model, which should eliminate the For further guidance and examples on migrating from functions to tools with the required parameters, refer to the LangChain documentation, particularly the section on using tools as OpenAI functions.
|
Beta Was this translation helpful? Give feedback.
-
OpenAI introduced functions first, then they deprecated functions and replace them with tools. Use |
Beta Was this translation helpful? Give feedback.
-
worked for me:
Although ChatGroq Llama models not handling agents properly for me, not sure yet. but first pass works so far |
Beta Was this translation helpful? Give feedback.
-
Is there any simple implementation for |
Beta Was this translation helpful? Give feedback.
-
I found groq llama3-groq-70b-8192-tool-use-preview model can work good for tool usage in langchain/langgraph |
Beta Was this translation helpful? Give feedback.
OpenAI introduced functions first, then they deprecated functions and replace them with tools.
Use
bind_tools
rather thanbind_functions
and treatbind_functions
as deprecated.