-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codebugSomething isn't workingSomething isn't workingopenapiIssues related to the OpenAPI function importerIssues related to the OpenAPI function importer
Description
Describe the bug
OpenAPI function erroring when invoked.
Error message:
Argument type 'System.Text.Json.JsonElement' is not convertible to parameter type 'integer'. (Parameter 'skip')
Actual value was 0. (Parameter 'skip')
Actual value was 0.
Stack trace:
at Microsoft.SemanticKernel.Plugins.OpenApi.OpenApiTypeConverter.Convert(String name, String type, Object argument, KernelJsonSchema schema)
at Microsoft.SemanticKernel.Plugins.OpenApi.RestApiOperation.BuildQueryString(IDictionary`2 arguments)
at Microsoft.SemanticKernel.Plugins.OpenApi.RestApiOperationRunner.BuildsOperationUrl(RestApiOperation operation, IDictionary`2 arguments, Uri serverUrlOverride, Uri apiHostUrl)
at Microsoft.SemanticKernel.Plugins.OpenApi.RestApiOperationRunner.RunAsync(RestApiOperation operation, KernelArguments arguments, RestApiOperationRunOptions options, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Plugins.OpenApi.OpenApiKernelPluginFactory.<>c__DisplayClass6_0.<<CreateRestApiFunction>g__ExecuteAsync|0>d.MoveNext()
at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c__DisplayClass25_0.<<GetReturnValueMarshalerDelegate>b__11>d.MoveNext()
at System.Threading.Tasks.ValueTask`1.get_Result()
at Microsoft.SemanticKernel.KernelFunction.<>c__DisplayClass32_0.<<InvokeAsync>b__0>d.MoveNext()
at Microsoft.SemanticKernel.Kernel.<InvokeFilterOrFunctionAsync>d__34.MoveNext()
To Reproduce
Steps to reproduce the behavior:
- Define an endpoint for an OpenAPI plugin like the following:
[HttpGet("bookings")]
[SwaggerOperation(OperationId = "GetBookings", Summary = "Returns a list of bookings. Supports 'skip' and 'take' query parameters for paging.")]
[ProducesResponseType(typeof(IEnumerable<BookingDto>), StatusCodes.Status200OK)]
public IActionResult GetBookings(
[FromQuery][SwaggerParameter("The number of bookings to skip.")] int? skip = null,
[FromQuery][SwaggerParameter("The maximum number of bookings to return.")] int? take = null)
{
IEnumerable<BookingDto> bookings = _bookings;
if (skip.HasValue && skip.Value > 0)
{
bookings = bookings.Skip(skip.Value);
}
if (take.HasValue && take.Value > 0)
{
bookings = bookings.Take(take.Value);
}
return Ok(bookings.ToList());
}
Later edit: I apologise for the badly formatted code, not sure how to fix it.
Expected behavior
Parameter conversation to work and the function to be invoked successfully
Platform
- Language: C#
- Source: 1.56.0
- AI model: gpt-4o-mini 2024-12-01-preview
Additional context
This seems to only be an issue when registering IChatClient
(MEAI) in the Kernel. If I use AddAzureOpenAIChatCompletion
it works fine.
I've also seen errors around converting booleans.
gsamcalero
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codebugSomething isn't workingSomething isn't workingopenapiIssues related to the OpenAPI function importerIssues related to the OpenAPI function importer
Type
Projects
Status
Sprint: Done