Adding Parameters to API in plugins based on prompts

I am creating a plugin that calls my custom api. This custom api gets has few optional query parameters.

eg : my api can be constructed in following ways.

  • http:/baseurl/api/employee/{id} – Gets emp information alone
  • http:/baseurl/api/employee/{id}?info=address – Gets emp information with address
  • http:/baseurl/api/employee/{id}?info=address&info=payment – Gets emp information with address and payment information

This info property is an array in my controller. And I have my plugin designed as below.

[KernelFunction, Description("Get the employee Information.")]
    public async Task<string> GetMemberInformation(
        [Description("id of the employee")] string id,
        [Description("User Query")] string userAsk
    )
    {
        try
        {
            using HttpResponseMessage response = await client.GetAsync($"http://baseurl/api/employee/{id}");
            // would like to add query params based on the prompts
            response.EnsureSuccessStatusCode();
            content = await response.Content.ReadAsStringAsync();
            return content;
        }
        catch (Exception e)
        {
           
        }

    }

I will be giving prompts like this.

  • Get me the employee information of 12345NO problem for the above prompt
  • Get me the employee information of 12345 with address
  • Get me the address of employee 12345
  • Get me the correspondence information of employee 12345For hte above 3 prompts, I would like to have the query param address added
  • Get me the complete information of the employeeFor this prompt I would like to have all hte query params added.

What I would like to know is the way to call api’s based on the prompts… How can I decide on the parameters based on the prompts… Kidnly suggest if there are any links or documentation.

Thanks…

You would be providing an additional specification for each external tool that the AI might find useful to invoke.

There are slightly different specification formats for “functions”, supported on Chat Completions, vs “tools”, also on Chat Completions and the only type of specification that Assistants will accept if you use that instead.

You just have to match up a specification’s properties with the type of inputs your function code needs, and instruct the AI to write the input for it in that special simplified json schema format.

Then either watch the response for those calls to be made, or in assistants poll the status to see if a tool needs to be fulfilled instead of a response to the user being ready.

Your destination for documentation is the “documentation” link on the forum sidebar, then with a section on function calls.

1 Like