Open benwager opened 1 day ago
Can you log the item.id
s as well? Wondering whether this is a model issue or a library issue. Is it possible to replicate with a test case?
I think the problem is with this line : tool_choice: 'required', Cause at the beginning, the model will send a function call to query wether status, which is desired. But after that when the function response, is submitted to the model to create a second response ( which happen automatically as mentioned in Readme ) ... At this point the model should logically not return a function call again , and Normally it should extract the desired data from the response and rephrase them in a readable format. But I assume, since tool choice is set to required, the model will be force to call the function again, though it doesn't make sense hier
One solution is to update the session hier:
const result = await fetch(
https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lng}¤t=temperature_2m,wind_speed_10m
,
);
const json = await result.json();
// ToDo : write code hier to update the session making tool choice NOT required
return json
What @zakir0101 said seems to be correct. As soon as I remove tool_choice: 'required', it only triggers a single function call.
So for now, it seems best to follow @zakir0101 suggestion to update session and remove tool_choice required option after the first function call completion. And then add it again for subsequent requests.
@khorwood-openai
Here is output with the item.id logged on both function_call and function_call_output
connected to realtime API
Function call
get_weather
{"lat":52.3676,"lng":4.9041,"location":"Amsterdam"}
item_AGhf3owGwo3zIDI8J2jIh
Function completed
{"latitude":52.366,"longitude":4.901,"generationtime_ms":0.03600120544433594,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":5,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","wind_speed_10m":"km/h"},"current":{"time":"2024-10-10T07:00","interval":900,"temperature_2m":13.5,"wind_speed_10m":20.9}}
item_AGhf4R6ikbkJUvJ4fbDlO
Function call
get_weather
{"lat":52.3676,"lng":4.9041,"location":"Amsterdam"}
item_AGhf4C1Xf0qsiSPR9Zoqz
Function completed
{"latitude":52.366,"longitude":4.901,"generationtime_ms":0.024080276489257812,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":5,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","wind_speed_10m":"km/h"},"current":{"time":"2024-10-10T07:00","interval":900,"temperature_2m":13.5,"wind_speed_10m":20.9}}
item_AGhf4OZxhEoHS8f5Bfs8w
Function call
get_weather
{"lat":52.3676,"lng":4.9041,"location":"Amsterdam"}
item_AGhf4R71Ti0WKjRILxskY
I am trying to create a node console application, but...
I am getting multiple (sometimes 10+) calls being made to my tool function calls.
Even when using the example get_weather as per docs:
The output of console:
It usually hits it more than this, but I kill it early