-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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: Bug: Conflict between Response Format property & function calling #9768
Comments
@apg-developer Could you please share how the |
@dmytrostruk sure, the definition is on the plugin but here you can see the class definition for RecipeOutput. Thank you so much for your help !!! public class RecipeOutput {
public string Name { get; set; }
public string Description { get; set; }
public Ingredient[] Ingredients { get; set; }
public string Instructions { get; set; }
}
public class Ingredient {
public string Name { get; set; }
public string Quantity { get; set; }
public string MeasureUnit { get; set; }
} |
@apg-developer Thanks a lot! Could you please try to run the same example but also specify semantic-kernel/dotnet/samples/Concepts/ChatCompletion/OpenAI_StructuredOutputs.cs Lines 203 to 208 in f5facce
|
@dmytrostruk the result was the same. Note the following stack trace & the provided screenshot. Thanks for your help ! General stack trace
Inner exception stack trace
Modified snippet code var builder = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(deploymentName: ProjectSettings.DeploymentName,
apiKey: ProjectSettings.ApiKey,
serviceId: ProjectSettings.ServiceId,
endpoint: ProjectSettings.Endpoint,
apiVersion: "2024-08-01-preview"); |
Hello, I am currently facing the same issue when returning data from a plugin function to a ChatCompletionAgent with the Expected behaviour agentKernel.ImportPluginFromObject(new SomePluginForDataRetrieval());
var agent = new ChatCompletionAgent()
{
Name = "ToolAndResponseFormatAgent",
Instructions = """
A Prompt guiding how to use the plugin
""",
Kernel = agentKernel,
Arguments = new KernelArguments(new OpenAIPromptExecutionSettings()
{
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),
ResponseFormat = typeof(FormattedResponse)
})
};
await agent.InvokeAsync(chatHistory); Should not return a 500 error when using ResponseFormat and a plugin that returns data to the agent in the form of an object Platform
Hope that this issue can be resolved soon, thanks for already pointing it out @apg-developer and for the support so far @dmytrostruk |
@apg-developer @deq3 Thanks again for reporting this issue. It appeared that Structured Outputs feature in Azure OpenAI (i.e. Response Format as JSON Schema) doesn't work with parallel function calls: When you enable function calling by using old In order to avoid the error, you need to explicitly disable parallel calls with following syntax: var executionSettings = new OpenAIPromptExecutionSettings
{
ResponseFormat = typeof(FormattedResponse),
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new() { AllowParallelCalls = false })
}; When you disable parallel calls explicitly, the issue should be resolved for you. Please let me know if that works. Thank you! |
Describe the bug
A HTTP 500 server_error is thrown when a ChatCompletion Agent uses function calling to retrieve data. The error only happens if Microsoft.SemanticKernel.Connectors.OpenAI.OpenAIPromptExecutionSettings.ResponseFormat property is enable on the settings of the agent. Otherwise error does not happen.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
await chatCompletionService.GetChatMessageContentAsync() method should return without errors the data provided by the plugin using the structure provided in ResponseFormat property.
Screenshots
Platform
Additional context
I have tried several combinations to try to achieve the goal
The text was updated successfully, but these errors were encountered: