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

.Net: Getting empty response when i call the planner

Open Cobra86 opened this issue 1 year ago • 6 comments

Describe the bug I'm sorry if it's not a bug but I tried everything and i can't find a fix. I'm getting this issue where calling the planner in the latest version results in an empty response. Also, I tested this with the planner sample project, specifically the MathSolver. https://github.com/MicrosoftDocs/semantic-kernel-docs/tree/main/samples/dotnet/11-Planner

To Reproduce Steps to reproduce the behavior:

  1. Run the project.
  2. Ask AI to add two numbers 2 and 1.
  3. Return empty response.

I'm getting empty response for any question that trigger the planner.

Expected behavior It should return a response.

Screenshots not applicable

Platform

  • OS: Windows
  • IDE: Visual Studio
  • Language: C#
  • Source: NuGet package version 1.1.0

Additional context None

Cobra86 avatar Jan 18 '24 21:01 Cobra86

@Cobra86, are you able to share what the generated Handlebars planner looks like when there is an "empty response"? This might be a regression on the Handlebars planner.

madsbolaris avatar Jan 19 '24 17:01 madsbolaris

It's not hitting the Handlebars method. This is program.cs for the test project. I'm using the MathSolver from semantic kernel samples

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using TestOpenAIConsoleApp;

using ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
{
    builder
        .SetMinimumLevel(0)
        .AddDebug();
});

// Create kernel
var builder = Kernel.CreateBuilder();

builder.AddAzureOpenAIChatCompletion(  
         endpoint: ", // Azure OpenAI Endpoint
         apiKey: "");      // Azure OpenAI Key;
builder.Services.AddLogging(c => c.AddDebug().SetMinimumLevel(LogLevel.Trace));
builder.Plugins.AddFromType<MathSolver>();

//builder.Plugins.AddFromType<MathSolver>();
var kernel = builder.Build();

ChatHistory Messages = [];

// Get chat completion service
var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();

// Start the conversation
while (true)
{
    // Get user input
    Console.Write("User > ");
    Messages.AddUserMessage(Console.ReadLine()!);

    // Enable auto function calling
    OpenAIPromptExecutionSettings openAIPromptExecutionSettings = new()
    {
        ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions
    };

    // Get the response from the AI
    var result = chatCompletionService.GetStreamingChatMessageContentsAsync(
        Messages,
        executionSettings: openAIPromptExecutionSettings,
        kernel: kernel);

    // Stream the results
    string fullMessage = "";
    var first = true;
    await foreach (var content in result)
    {
        if (content.Role.HasValue && first)
        {
            Console.Write("Assistant > ");
            first = false;
        }
        Console.Write(content.Content);
        fullMessage += content.Content;
    }
    Console.WriteLine();

    // Add the message from the agent to the chat history
    Messages.AddAssistantMessage(fullMessage);
}

Cobra86 avatar Jan 19 '24 18:01 Cobra86

It appears there was an issue with Azure OpenAI UK, but I can now see the response. I'll keep this issue open, as it seems the code isn't handling it properly.

Cobra86 avatar Jan 29 '24 18:01 Cobra86

We got word that it's been fixed. Are you still getting the issue?

madsbolaris avatar Feb 01 '24 19:02 madsbolaris

Yes, It's fixed. In future, will the code handle this issue? I'm not sure what was the issue and is it good practice to throw error when the response is empty ?

Cobra86 avatar Feb 02 '24 09:02 Cobra86

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar May 03 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 24 '24 01:05 github-actions[bot]