Gpt function calling hallucinations, runs 3 times

Hi all,

I have been working on this for a couple of days now and I hope that somebody can point me in the right direction.

Is there a way to tell the function to not run more than once ? It gives the same reply 3 times.

1 Like

You need to include the fact that the function call was successfully ran back into the prompt messages, you can do this by including the reply the function returned or just using a placeholder that says “Function successfully performed” otherwise the model will try to call the function again.

1 Like

I know I did add it there with the tile as function.
But I will try the “successfully worked”

Thank you

If you rely on some of the output generated by the model for the function call later, then you should include that in the successful message, if you don’t then it should be fine as is.

1 Like

Will look into that. I should have asked earlier :joy:
Spent two days on this :joy:

1 Like

Does it need to be the last prompt?

or I can do it like this ?

{ role: “user”, content: inputText },
{ role: “function”, content: “Function successfully performed” },
{
role: “assistant”,
content: responseText,
},

Yes, you can use the python .append function to just add new roles and message content to the messages list, append the users question and the models answer to it, and repeat that in a loop, you can see this thread for further guidance.

1 Like

Thank you for the response, super nice of you.

my problem was that I did a reference to the function instead of using a string as the name.
that was my problem and now it works.

Thank you so much