My use case is to build an assistant that, based on user input, queries some weather data, analyzes it and provides an answer.
In order to query the data I defined some functions the model can call (https://platform.openai.com/docs/guides/function-calling), which return a JSON object that is then added to the chat history.
This works pretty well and the model is spot-on in deciding what to call. However, it seems that sometimes it only uses parts of the data that is stored in the JSON.
For example, to answer one question the model needed to sum all values in an array that looks like this
{
'sunshine_duration':
[10800.0,
10440.0,
7920.000000000001,
9360.0,
...
6840.0,
7560.0,
10440.0,
8640.0] // 365 total values
}
The sum the assistant gives me is wrong.
I know this because I can see what the model is calling and analyzing as function result.
When asked for clarification, it gave me these as the values used for the sum
[10800,
10440,
7920,
9360,
...
14760,
7200,
7920,
8280]
Curiously enough, the first ones are ok, but the last ones are not.
I’ve asked it multiple times and it always gave me a different answer for the last values but not for the first ones so my guess is that it is somehow truncating the JSON input when processing it and then making up the data (I cannot find this sequence of data anywhere in the function result).
Does the max_tokens
parameter has any control on this? How can I control the size of the input that the model can process?
Maybe I’m not using the function calling/tools capabilities in the way they were designed, but the official documentation does not talk about any hard limit in the response so I’m not sure.