I’m using a function to (try to) get a consistent Json data. When using a function I’m ending up in a loop - I do get a function reply on the first client.chat.completions.create(), but when I then post the function response back it keeps going - how do I avoid this?
(Ideally I don’t want to follow-up at all after I get the parameters for the function as it shouldn’t be needed - All I want is the AI to provide the parameters and be done…)
I’m new at this so I could be going about this all wrong?
The API will try to find solution to your query. If the function response you are sending back does not correspond to its expectation, chances are it will call the function again or call other functions it thinks is needed, etc. In order to avoid this, you need to improve your function return value when the result is okay and also when there is a problem.
For simple example, you ask what is the weather in new york today?
then when get_weather
is invoked, you send back { "location": "Atlanta", "status": "sunny"}
, the API might call the function get_weather
again. This one is too obvious but it is just for illustration that you can probably test.
Thanks - that is likely my problem. I will see if creating and different response fixes it.