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: Add JsonElement String to Primitive Implicit Conversion Support (SLM Function Calling) #9784

Merged

Conversation

RogerBarreto
Copy link
Member

@RogerBarreto RogerBarreto commented Nov 21, 2024

Motivation and Context

In the original logic the conversion was giving priority for existence of converters when the parameter value was a JsonElement/JsonDocument/JsonNode, this change checks if the argument is one of those types first and use the proper JSON conversion.

This change also bring some resiliency when the JsonElement provided is a string for primitive types like boolean and C# numeric types.

This change improves function calling experience when using local models that send JSON string argument values ("1" or "true") instead of the expected JSON type (1, true) for calling functions.
i.e: Llama 3.1, Llama 3.2

Added Unit Tests covering the added JsonElement arguments support.

@RogerBarreto RogerBarreto self-assigned this Nov 21, 2024
@RogerBarreto RogerBarreto requested a review from a team as a code owner November 21, 2024 16:55
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels Nov 21, 2024
@RogerBarreto RogerBarreto changed the title .Net: Add advanced support for conversion of JsonElement as arguments .Net: Add JsonElement String to Primitive Implicit Conversion Support (SLM Function Calling) Nov 21, 2024
@microsoft microsoft deleted a comment from tharkhay4 Nov 22, 2024
@microsoft microsoft deleted a comment from tharkhay4 Nov 22, 2024
@RogerBarreto RogerBarreto added this pull request to the merge queue Nov 22, 2024
Merged via the queue into microsoft:main with commit ef8251c Nov 22, 2024
15 checks passed
@RogerBarreto RogerBarreto deleted the issues/9711-ollama-jsonelement-fc branch November 22, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Ollama connector fails when calling plugin functions that have parameters with Guid type
5 participants