Assistant API - Switching on Data Retrieval, Weather, and Stock Price Functions into an Assistant through API Calls

I’m attempting to create an assistant via the API call from the Assistant API.

When I create an assistant by making the call as outlined in the API documentation, the call works perfectly, and the assistant is successfully created.
However, what I’m having trouble with is this, when I create an assistant, all I want to do is enable the retrieval tool and add two functions: one to get weather and one to get stock prices. So, it should look like the image below.

Screenshot 2024-02-15 101617

Could anyone guide me on how to set up an assistant with both their functions and data retrieval capabilities activated when i hit the Create assistant endpoint.

Id really appreciated it and iv spent hours trying to make it work.

Kind regards

Hi there, What is the current part you are stuck on specifically?

@Oliver-wholegraintech
Thank you for getting in touch. The issue is that I’m struggling to figure out the JSON POST call format for the endpoint (Create Assistant) to add two functions and enable retrieval. I’ve attempted to use ChatGPT to generate it, but without success.

Any help would be amazing :star_struck:.

Regards :pray:

Okay cool!

What is the current setup you’re using in the API connector? What’s the error message coming through?

Thanks so much for your help I did and managed to solve it @Oliver-wholegraintech . Really appreciate your time. :pray:

{
  "instructions": "You are an HR bot, and you have access to files to answer employee questions about company policies.",
  "tools": [
    {
      "type": "retrieval"
    },
    {
      "type": "function",
      "function": {
        "description": "Calculate employee benefits based on their employment type and years of service.",
        "name": "calculate_benefits",
        "parameters": {
          "type": "object",
          "properties": {
            "employment_type": {
              "type": "string",
              "enum": ["full-time", "part-time", "contract"]
            },
            "years_of_service": {
              "type": "integer"
            }
          },
          "required": ["employment_type", "years_of_service"]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "description": "Retrieves employee schedule based on employee ID.",
        "name": "get_employee_schedule",
        "parameters": {
          "type": "object",
          "properties": {
            "employee_id": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,64}$"
            }
          },
          "required": ["employee_id"]
        }
      }
    }
  ],
  "model": "gpt-3.5-turbo-0125",
  "file_ids": ["<file>"]
}
1 Like