Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: When using InvokeAsync on an agent, function call and function call results are missing #6036

Closed
matthewbolanos opened this issue Apr 29, 2024 · 0 comments · Fixed by #6046
Assignees
Labels

Comments

@matthewbolanos
Copy link
Member

In the following example, it is currently not possible to retrieve the function call and function call results so that you can add it to your own ChatHistory object.

// Create kernel
var builder = Kernel.CreateBuilder();
builder.WithCompletionService();
builder.Services.AddLogging(c => c.AddDebug().SetMinimumLevel(LogLevel.Trace));
builder.Plugins.AddFromType<LightPlugin>();
var kernel = builder.Build();

ChatCompletionAgent agent = new()
{
    Name = "HomeAssistant",
    Instructions = "You are a home assistant. You can help with home-related tasks.",
    Kernel = kernel,
    ExecutionSettings = new OpenAIPromptExecutionSettings() { ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions },
};

// Create chat history
ChatHistory history = [];

while (true)
{
    // Get user input
    Console.Write("User > ");
    history.AddMessage(
        AuthorRole.User,
        Console.ReadLine()!
    );

    var results = agent.InvokeAsync(history);

    await foreach (var content in results)
    {
        Console.WriteLine("Assistant > " + content);
        history.AddMessage(AuthorRole.Assistant, content.ToString());
    }
}
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Apr 29, 2024
@matthewbolanos matthewbolanos added agents and removed .NET Issue or Pull requests regarding .NET code triage labels Apr 29, 2024
@github-actions github-actions bot changed the title When using InvokeAsync on an agent, function call and function call results are missing .Net: When using InvokeAsync on an agent, function call and function call results are missing Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants