.Net: How to force GPT to ask for parameter value before actually calling the function ?
I am using the below code which works perfectly if question has the parameter value, for example weather service. but in case user does not provide the value for city, i want gpt should comback and ask for paramter value and then invoke it after getting value from user. How can i achieve that, what else need to be done with code below ?
var builder = Kernel.CreateBuilder( );
builder.Services.AddAzureOpenAIChatCompletion(aoaiModel, aoaiEndpoint, aoaiApiKey);
builder.Plugins.AddFromType
=====================================================================================
@nssidhu Can you verify this is your scenario?
- You are using a plugin
- The first plugin function can prompt the user for some input
- The second plugin function will perform an action but requires the user input
- You invoke the AI with a question which will cause the AI
- Invoke the first plugin function to get the user input
- Invoke the second plugin function and pass in the user input
- Return the response returned from the second function
Thanks.
That would be hardwiring things. I have seen those sample, the ask here is different. Instead of me writing hardcoding the invocation of plugin, it should be Auto Invoked.
I was relying on AutoInvokeKernelFunctions, so expectation is that Chapt would determine that plugin/function requires a city name and user has not provided, so chatGPT should ask for the city name and once user provide that it should continue with execution.
In my case there could be say 5 or more plugins. User ask a question. Relying AutoInvokeKernelFunctions feature, i would say Semantic Kernel determines that it needs to execute Plugin3, But that Plugin3 expect 3 parameters and Semantic kernel could only figure out one parameter from the question.
Expectation here is the Semantic Kernel should ask for other parameters from user and once all the parameters are collected it should continue the execution of that plugin.
If sematic kernel determines that it need to chain the plugins to answer questions, it should ask for any other missing parameters as may be needed by other functions.
Since we don't know what question user will ask, I guess we cannot simply ask for parameters upfront. I hope i am answering your question.
I think I had read somewhere in SK documentation a while ago that parameter description should say that it is required - however, I have not seen this work ever with SK. LLM never asks for missing information.
Before trying SK I had also experimented with Azure OpenAI.NET and there in the function-definition you could specify the required parameters. This worked well and the LLM would ask the user for missing parameters before executing a function/tool. Here is an example that shows this - see how getWeatherTool is defined and location is a required parameter. https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/openai/Azure.AI.OpenAI/tests/Samples/ChatTools.cs
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.