How can I make the assistant call the function every time?

{
  "name": "_getCurrentTime",
  "description": "Get the current time",
  "strict": false,
  "parameters": {
    "type": "object",
    "properties": {},
    "required": []
  }
}

I created a chatbot assistant and implemented a simple function.
(_getCurrentTime() returns the current time format ‘HH:mm’.)

The first time I asked, “What time is it now?”, the assistant returned a requires_action status, and I got current time “11:30.”

But the second time I asked the same question, the assistant did not return a requires_action status and I got “11:30.” again.

After that, no matter how many times I try, it doesn’t call the function and just returns ‘11:30’.

How can I make the assistant call the function every time?

This should point you in the right direction:

Read more here.

1 Like

You can try playing around with the description to specify when the function should be called. Refer to this: https://platform.openai.com/docs/guides/function-calling/step-2-describe-your-function-to-the-model-so-it-knows-how-to-call-it

You can put a description like: “Get the current time. Call this function when the user asks for current time or asks ‘What time is it?’, or similar time-related questions.”

No level of prompting will make it force to run the Function. You have to force it by passing

  "tool_choice":"required",

like @caydennormanton suggested.

1 Like