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…