You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is an issue with the Python library and not an underlying OpenAI API
This is an issue with the Python library
Describe the bug
Error code: 400 - {'error': {'message': "Invalid parameter: 'tool_calls' cannot be used when 'functions' are present. Please use 'tools' instead of 'functions'.", 'type': 'invalid_request_error', 'param': 'messages.[2].tool_calls', 'code': None}}
To Reproduce
Structure is in the code snippet, after MAssassor answer its question (after using tool and then go back to MAssasor), should be go back to supervisor, but it give above error.
Code snippets
## first read guideline and then go to the different source to get data: defcreate_team_supervisor(llm, system_prompt, members) ->str:
"""An LLM-based router."""options= ["FINISH"] +membersfunction_def= {
"name": "route",
"description": "Select the next role.",
"parameters": {
"title": "routeSchema",
"type": "object",
"properties": {
"next": {
"title": "Next",
"anyOf": [
{"enum": options},
],
},
},
"required": ["next"],
},
}
prompt=ChatPromptTemplate.from_messages(
[
("system", system_prompt),
MessagesPlaceholder(variable_name="messages"),
(
"system",
"Given the conversation above, who should act next?"" Or should we FINISH? Select one of: {options}",
),
]
).partial(options=str(options), team_members=", ".join(members))
return (
prompt|llm.bind_functions(functions=[function_def], function_call="route")
|JsonOutputFunctionsParser()
)
classTeamState(TypedDict):
# A message is added after each team member finishesmessages: Annotated[List[BaseMessage], operator.add]
# The team members are tracked so they are aware of# the others' skill-setsPOLICY_NUMBER: strCLAIM_NUMBER: strFILE_PATH: strteam_members: List[str]
# Used to route work. The supervisor calls a function# that will update this every time it makes a decisionnext: strsender:strdefrouter(state):
# This is the routermessages=state["messages"]
last_message=messages[-1]
ifnotlast_message.content:
# The previous agent is invoking a tool# print(state['sender'], 'call_tool')return"call_tool"# print(state['sender'], "CogSupervisor")return'continue'graph=StateGraph(TeamState)
## Add nodes to the graphgraph.add_node("MAssassor", med_node)
graph.add_node("BAssassor", beh_node)
graph.add_node("Supervisor", cog_supervisor)
graph.add_node("call_tool", tool_node)
graph.add_edge(START, "Supervisor")
## Add condition edges to the graph graph.add_conditional_edges("MAssassor",
router,
{"call_tool": "call_tool", "continue": "Supervisor"},)
graph.add_conditional_edges("BAssassor",
router,
{"call_tool": "call_tool", "continue": "Supervisor"},)
graph.add_conditional_edges(
"Supervisor",
lambdax: x["next"],
{"MAssassor": "MAssassor",
"BAssassor": "BAssassor",
"FINISH": END},
)
graph.add_conditional_edges(
"call_tool",
lambdax: x["sender"],
{"MAssassor": "MAssassor",
"BAssassor": "BAssassor",
},
)
chain=graph.compile()
OS
macOS
Python version
Python 3.9.6
Library version
openai 1.51.2
The text was updated successfully, but these errors were encountered:
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
Error code: 400 - {'error': {'message': "Invalid parameter: 'tool_calls' cannot be used when 'functions' are present. Please use 'tools' instead of 'functions'.", 'type': 'invalid_request_error', 'param': 'messages.[2].tool_calls', 'code': None}}
To Reproduce
Structure is in the code snippet, after MAssassor answer its question (after using tool and then go back to MAssasor), should be go back to supervisor, but it give above error.
Code snippets
OS
macOS
Python version
Python 3.9.6
Library version
openai 1.51.2
The text was updated successfully, but these errors were encountered: