When multiple functions are defined in the tools, the call results in a code 400 invalid argument error. The strange thing is that when tools contains only one of the functions, it works perfectly fine.
This is the tools
definition I have defined
tools=[
{
"function":{
"description":"select the url of a given music",
"name":"get_music",
"parameters":{
"properties":{
"music_name":{
"description":"The music name, e.g. Never Gonna Give You Up",
"type":"string"
},
"artist_name":{
"description":"The artist name, e.g. The Weeknd",
"type":"string"
}
},
"required":[
"music_name"
],
"type":"object"
}
},
"type":"function"
},
{
"function":{
"description":"Get the weather in a given location.",
"name":"get_weather",
"parameters":{
"properties":{
"cityname":{
"description":"The city name, e.g.default today's weather",
"type":"string"
},
"unit": {
"type": "string",
"format": "enum",
"enum": ["celsius", "fahrenheit"]
}
},
"required":[
"cityname"
],
"type":"object"
}
},
"type":"function"
}
]
I call Gemini using a POST request, following the OpenAI standard.
async with httpx.AsyncClient(proxies=proxies) as client:
response = await client.post(
f"{base_url}chat/completions",
headers={"Authorization": f"Bearer {api_key}"},
json={
"model": "gemini-1.5-flash-002", # 使用您选择的模型
"messages": conversation_history,
"tools": tools,
"tool_choice": "required"
}
)
I would greatly appreciate it if you could help me.