semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Plan with imported skills from ChatGPT plugins , got unexpected results

Open sheng-jie opened this issue 2 years ago • 0 comments

I modified Example21_ChatGPTPlugins.cs in local to run with planner, got unexpected results.

var kernel = new KernelBuilder().WithLogger(ConsoleLogger.Log).Build();

kernel.Config.AddAzureTextCompletionService(
            Env.Var("AZURE_OPENAI_SERVICE_ID"),
            Env.Var("AZURE_OPENAI_DEPLOYMENT_NAME"),
            Env.Var("AZURE_OPENAI_ENDPOINT"),
            Env.Var("AZURE_OPENAI_KEY"));

var skill = await kernel.ImportChatGptPluginSkillFromUrlAsync("Klarna", new Uri("https://www.klarna.com/.well-known/ai-plugin.json"));
        
var contextVariables = new ContextVariables();
contextVariables.Set("q", "Laptop");     //A precise query that matches one very small category or product that needs to be searched for to find the products the user is looking for. If the user 
explicitly stated what they want, use that as a query. The query is as specific as possible to the product name or category mentioned by the user in its singular form, and don't contain any 
clarifiers like latest, newest, cheapest, budget, premium, expensive or similar. The query is always taken from the latest topic, if there is a new topic a new query is started.
contextVariables.Set("size", "3");        // number of products returned
contextVariables.Set("budget", "200");    // maximum price of the matching product in local currency, filters results
var rst = await kernel.RunAsync(contextVariables, skill["productsUsingGET"]);
Console.WriteLine("skill response: {0}", rst);

//run with planner
var planner = new SequentialPlanner(kernel, new PlannerConfig() { MaxTokens = 1024 });
var originalPlan = await planner.CreatePlanAsync("I want to buy a laptop and my budget is 200 dollars");
Console.WriteLine("Original plan:");
Console.WriteLine(originalPlan.ToJson());
var result = await kernel.RunAsync(originalPlan);
Console.WriteLine("plan response: {0}", result);
Console.ReadLine();

The results as follows:

skill response: {
  "content": "{\u0022products\u0022:[{\u0022name\u0022:\u0022Apple MacBook Air (2020) M1 OC 7C GPU 8GB 256GB SSD 13\\\u0022\u0022,\u0022url\u0022:\u0022https://www.klarna.com/us/shopping/pl/cl27/3200009205/Laptops/Apple-MacBook-Air-%282020%29-M1-OC-7C-GPU-8GB-256GB-SSD-13/?utm_source=openai\u0026ref-site=openai_plugin\u0022,\u0022price\u0022:\u0022$799.99\u0022,\u0022attributes\u0022:[\u0022Processor:Apple M1\u0022,\u0022Hard Drive Type:SSD\u0022,\u0022Screen Size:13.3\\\u0022\u0022,\u0022Operating System:macOS\u0022,\u0022Series:Apple Macbook Air\u0022,\u0022SSD Size:256 GB\u0022,\u0022RAM:8 GB\u0022,\u0022Release Year:2020\u0022]},{\u0022name\u0022:\u0022Apple MacBook Air (2022) M2 OC 8C GPU 8GB 256GB SSD 13.6\\\u0022\u0022,\u0022url\u0022:\u0022https://www.klarna.com/us/shopping/pl/cl27/3201585850/Laptops/Apple-MacBook-Air-%282022%29-M2-OC-8C-GPU-8GB-256GB-SSD-13.6/?utm_source=openai\u0026ref-site=openai_plugin\u0022,\u0022price\u0022:\u0022$1049.00\u0022,\u0022attributes\u0022:[\u0022Processor:Apple M2\u0022,\u0022Hard Drive Type:SSD\u0022,\u0022Screen Size:13.6\\\u0022\u0022,\u0022Operating System:macOS\u0022,\u0022Series:Apple Macbook Air\u0022,\u0022SSD Size:256 GB\u0022,\u0022RAM:8 GB\u0022,\u0022Release Year:2022\u0022]},{\u0022name\u0022:\u0022HP 14-dq0055dx\u0022,\u0022url\u0022:\u0022https://www.klarna.com/us/shopping/pl/cl27/3202767894/Laptops/HP-14-dq0055dx/?utm_source=openai\u0026ref-site=openai_plugin\u0022,\u0022price\u0022:\u0022$179.99\u0022,\u0022attributes\u0022:[\u0022Processor:Intel Celeron\u0022,\u0022Hard Drive Type:SSD\u0022,\u0022Screen Size:14.0\\\u0022\u0022,\u0022Windows Version:Windows 11 Home\u0022,\u0022Operating System:Windows\u0022,\u0022SSD Size:64 GB\u0022,\u0022RAM:4 GB\u0022,\u0022Release Year:2022\u0022]}]}",
  "contentType": "application/json; charset=utf-8"
}
Original plan:
{"state":[{"Key":"INPUT","Value":""}],"steps":[{"state":[{"Key":"INPUT","Value":""}],"steps":[],"named_parameters":[{"Key":"max_price","Value":"200"},{"Key":"size","Value":"10"},{"Key":"server_url","Value":"https://example.com"},{"Key":"q","Value":"laptop"},{"Key":"min_price","Value":"0"},{"Key":"INPUT","Value":""}],"named_outputs":[{"Key":"PRODUCTS","Value":""},{"Key":"INPUT","Value":""}],"next_step_index":0,"name":"productsUsingGET","skill_name":"Klarna","description":null},{"state":[{"Key":"INPUT","Value":""}],"steps":[],"named_parameters":[{"Key":"INPUT","Value":""}],"named_outputs":[{"Key":"INPUT","Value":""}],"next_step_index":0,"name":"","skill_name":"Microsoft.SemanticKernel.Orchestration.Plan","description":""}],"named_parameters":[{"Key":"INPUT","Value":""}],"named_outputs":[{"Key":"INPUT","Value":""}],"next_step_index":0,"name":"I want to buy a laptop and my budget is 200 dollars","skill_name":"Microsoft.SemanticKernel.Orchestration.Plan","description":"I want to buy a laptop and my budget is 200 dollars"}
warn: object[0]
      Something went wrong while rendering the Rest function. Function: Klarna.productsUsingGET. Error: Response status code does not indicate success: 404 (Not Found).
      System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
         at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
         at Microsoft.SemanticKernel.Connectors.WebApi.Rest.RestApiOperationRunner.SendAsync(Uri url, HttpMethod method, IDictionary`2 headers, HttpContent payload, CancellationToken cancellationToken) in D:\OpenAI\semantic-kernel\dotnet\src\SemanticKernel.Abstractions\Connectors\WebApi\Rest\RestApiOperationRunner.cs:line 97
         at Microsoft.SemanticKernel.KernelOpenApiExtensions.<>c__DisplayClass5_0.<<RegisterRestApiFunction>g__ExecuteAsync|0>d.MoveNext() in D:\OpenAI\semantic-kernel\dotnet\src\Skills\Skills.OpenAPI\Extensions\KernelOpenApiExtensions.cs:line 280

We can see that the generated plan is wrong, the server_url is not correct, it should be https://www.klarna.com/us/shopping.

{
    "state": [
        {
            "Key": "INPUT",
            "Value": ""
        }
    ],
    "steps": [
        {
            "state": [
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "steps": [],
            "named_parameters": [
                {
                    "Key": "max_price",
                    "Value": "200"
                },
                {
                    "Key": "size",
                    "Value": "10"
                },
                {
                    "Key": "server_url",
                    "Value": "https://example.com"
                },
                {
                    "Key": "q",
                    "Value": "laptop"
                },
                {
                    "Key": "min_price",
                    "Value": "0"
                },
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "named_outputs": [
                {
                    "Key": "PRODUCTS",
                    "Value": ""
                },
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "next_step_index": 0,
            "name": "productsUsingGET",
            "skill_name": "Klarna",
            "description": null
        },
        {
            "state": [
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "steps": [],
            "named_parameters": [
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "named_outputs": [
                {
                    "Key": "INPUT",
                    "Value": ""
                }
            ],
            "next_step_index": 0,
            "name": "",
            "skill_name": "Microsoft.SemanticKernel.Orchestration.Plan",
            "description": ""
        }
    ],
    "named_parameters": [
        {
            "Key": "INPUT",
            "Value": ""
        }
    ],
    "named_outputs": [
        {
            "Key": "INPUT",
            "Value": ""
        }
    ],
    "next_step_index": 0,
    "name": "I want to buy a laptop and my budget is 200 dollars",
    "skill_name": "Microsoft.SemanticKernel.Orchestration.Plan",
    "description": "I want to buy a laptop and my budget is 200 dollars"
}

sheng-jie avatar Apr 26 '23 04:04 sheng-jie