How to specify arguments for 'function calling' interactively?

Hello,

I’m developing a chatbot app for iOS using the OpenAI API. In a recent update, I implemented some plugin features using “function calling” in the app. The plugins are working almost as expected. However, when the API doesn’t have the necessary argument information for a function, it doesn’t prompt the user for input.

Here is the content of the messages and the functions:

messages: [
  "system":"You may infer what values should be entered into the function, but do not make assumptions without evidence. Ask the user for clarification if the request is ambiguous.",
  "system":"You know that today is \(now). You may consider a response based on
  this date and time if needed."
]
{
  "functions": [
    {
      "name": "handle_event",
      "description": "Schedules or finds the user's desired event.",
      "parameters": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [ "create", "search" ],
            "description": "Infer whether the user wants to create or search for an event."
          },
          "implicit_date": {
            "type": "string",
            "enum": [ "today", "tomorrow", "day after tomorrow", "this week", "next week", "previous week", "this month", "next month", "previous month", "other" ],
            "description": "Date for the user's desired event. Infer this from the users message with the firm evidence."
          },
          "day_of_week": {
            "type": "string",
            "enum": [ "monday", "tuesday", "wednesday", "thirsday", "friday", "saturday", "sunday", "other" ],
            "description": "The day of the week for the user's desired event. Infer this from the users message with the firm evidence."
          },
          "start_year": {
            "type": "integer",
            "description": "Year in the date for the user's desired event. Infer this from the users message with the firm evidence."
          },
          "start_month": {
            "type": "integer",
            "enum": [1,2,3,4,5,6,7,8,9,10,11,12],
            "description": "Month in the date for the user's desired event. Infer this from the users message with the firm evidence. If you are not sure, you can ask the user."
          },
          "start_day": {
            "type": "integer",
            "description": "Day in the date for the user's desired event. Infer this from the users message with the firm evidence. If you are not sure, you can ask the user."
          },
          "start_hour": {
            "type": "integer",
            "enum": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],
            "description": "Hour in the time for the user's desired event. Infer this from the users message with the firm evidence. If a start hour is not indicated in the event creation request, you should ask the user."
          },
          "start_minute": {
            "type": "integer",
            "description": "Minute in the time for the user's desired event. Infer this from the users message with the firm evidence."
          },
          "duration": {
            "type": "string",
            "description": "The duration of the event from start to finish. Infer this from the users message with the firm evidence. Translate into English."
          },
          "event": {
            "type": "string",
            "description": "Contents of the event such as meeting, shopping and so on."
          },
          "notes": {
            "type": "string",
            "description": "Incidental information and memorandum about the event."
          }
        },
        "required": [ "action", "event" ]
      }
    }
  ]
}

This function is used to create and search events. The “action” parameter is either “create” or “search” based on the entered text.

For example, if I input “Meeting with Jack on the 10th of this month”, I expect the API to ask, “What is the start time?” The “description” in the “start_hour” parameter doesn’t produce the desired behavior.

I would like to try different things and would like your advice.

You can add a special web interface and cache that in browser or on your backend. Since every time you do a request you send all the history you can surely change the functions.

1 Like

I solved the problem by referring to the answers in this topic.