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: Gemini function calling throws error when a kernel function with Enum
parameter is available
#5796
Comments
Enum
parameter is availableEnum
parameter is available
I get errors even when no enum parameters are used with AutoInvokeKernelFunctions. As an example:
Gives me a 500 error from Gemini for gemini-1.0-pro-002 and gemini-1.5-pro-preview-0409 |
You should check at first in google docs do selected versions of models support function calling. And 500 is server error, so this problem is rather related to google api not connector. |
Yes, both of those models have function calling. If I change GeminiToolCallBehavior.AutoInvokeKernelFunctions to GeminiToolCallBehavior.EnableKernelFunctions it does the function calling correctly. |
I am checking google ai documentation link and I don't see models you tried to use. Here are aliases for vertex ai link And in your sample you used googleAi but with models from vertex. |
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Fixes #5796 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Type for enum wasn't correctly set in JsonSchemaMapper, it didn't matter for OpenAI but gemini was throwing exception if type isn't specified. Fixed that with `string` type. Added new unit tests for Gemini and OpenAI. Both passed. @RogerBarreto @SergeyMenshykh DataHelper and BertOnyx was updated automatically by formatter. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Roger Barreto <[email protected]>
Describe the bug
When using function calling with Gemini
ToolCallBehavior
set toGeminiToolCallBehavior.AutoInvokeKernelFunctions
, and the Kernel instance has a plugin function with anEnum
parameter, the Gemini request will return a 400 (bad request) error.To Reproduce
Steps to reproduce the behavior:
Kernel
instance with a plugin containing a function with enum parameter (TimePlugin
is simple example to test).GeminiPromptExecutionSettings
withToolCallBehavior = GeminiToolCallBehavior.AutoInvokeKernelFunctions
InvokePromptAsync
that includes the execution settings.Expected behavior
Similar to current OpenAI function calling, the Gemini connector should handle necessary type changes when converting kernel functions to gemini function definitions to avoid these errors
Platform
Additional context
Created example that demonstrates the issue - uses
TimePlugin
which causes error andTimePlugin
withDateMatchingLastDayName
function removed, which does not cause the error.The text was updated successfully, but these errors were encountered: