Das Modell gibt Mutiple -Tools zurück, die sie auch aufrufen können, auch wenn `parallel_tool_calls` auf` false` gesetztPython

Python-Programme
Anonymous
 Das Modell gibt Mutiple -Tools zurück, die sie auch aufrufen können, auch wenn `parallel_tool_calls` auf` false` gesetzt

Post by Anonymous »

Ich experimentiere mit den OpenAI -Agenten SDK (Python) und rannte mit parallel_tool_calls . Ich sehe jedoch immer noch Multiple Toolaufrufe, die in der Antwort der Assistenten zurückgegeben wurden.

Code: Select all

client = AsyncOpenAI(
api_key=GEMINI_API_KEY,
base_url=BASE_URL
)
model = OpenAIChatCompletionsModel(
openai_client=client,
model="gemini-2.0-flash" # using openai sdk with gemini model
)
< /code>

# Emited some code for brevity

async def main():
agent = Agent[UserInfo](
name="Assistant",
model=model,
tools=[fetch_user_uid, fetch_weather], # Provided two tools
model_settings=ModelSettings(parallel_tool_calls=False) # Setting `parallel_tool_calls` to false.
)

result = await Runner.run(
starting_agent=agent,
input="what's user uid and what's the weather in karachi?", # asking question to check if the model is calling both tools
context=user_info,
)

if __name__ == "__main__":
asyncio.run(main())
< /code>
Protokolle: < /p>
...
LLM resp:
{
"content": null,
"refusal": null,
"role": "assistant",
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": [ # Model is asking to call both tools even when `parallel_tool_calls` is set to `False`
{
"id": "",
"function": {
"arguments": "{}",
"name": "fetch_user_uid"
},
"type": "function"
},
{
"id": "",
"function": {
"arguments": "{\"city\":\"karachi\"}",
"name": "fetch_weather"
},
"type": "function"
}
]
}

...
Erwartete Ergebnisse:
LLM -Aufrufe höchstens ein Tool -Anruf pro Runde.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post