You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
kernel function call is not working properly with gemini-1.5-flash for below code
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Google;
using SementicKernelDemo.Plugins.LightsPlugin;
string? modelID = Environment.GetEnvironmentVariable("MODEL_ID");
string? apiKey = Environment.GetEnvironmentVariable("API_KEY");
if (string.IsNullOrEmpty(modelID) || string.IsNullOrEmpty(apiKey))
throw new Exception("Please set the MODEL_ID and API_KEY environment variables to your Google AI Gemini model ID and API key, respectively.");
// create kernel
#pragma warning disable SKEXP0070
var kernel = Kernel.CreateBuilder()
.AddGoogleAIGeminiChatCompletion(modelID, apiKey, GoogleAIVersion.V1)
.Build();
// Add plugins
kernel.Plugins.AddFromType<LightsPlugin>("Lights");
//Enable Prompt Execution Settings
GeminiPromptExecutionSettings geminiPromptExecutionSettings = new() {
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(),
ToolCallBehavior = GeminiToolCallBehavior.EnableKernelFunctions
};
var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory();
string? userInput;
do
{
Console.WriteLine("User >");
userInput = Console.ReadLine();
try
{
history.AddUserMessage(userInput);
var result = await chatCompletionService.GetChatMessageContentAsync(
history,
executionSettings: geminiPromptExecutionSettings,
kernel: kernel);
Console.WriteLine("Assistant > " + result);
history.AddMessage(result.Role, result.Content ?? string.Empty);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
} while (userInput is not null);
#pragma warning restore SKEXP0070
To Reproduce
Steps to reproduce the behavior:
Execute the above code its failing when ToolCallBehavior = GeminiToolCallBehavior.EnableKernelFunctions or ToolCallBehavior = GeminiToolCallBehavior.AutoInvokeKernelFunctions is set. if i don't set it does not recognize kernel functions.
Expected behavior
It should recognize kernel functions and return the result back from my plugin
Screenshots
Platform
OS: Windows
IDE: Visual Studio
Language: C#
Source: microsoft.sementic.kernel and connector.google
Additional context
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Bug: gemini-1.5-flash function calling is not working getting 400 bad request error.
.Net: Bug: gemini-1.5-flash function calling is not working getting 400 bad request error.
Jan 17, 2025
Describe the bug
kernel function call is not working properly with gemini-1.5-flash for below code
To Reproduce
Steps to reproduce the behavior:
Execute the above code its failing when ToolCallBehavior = GeminiToolCallBehavior.EnableKernelFunctions or ToolCallBehavior = GeminiToolCallBehavior.AutoInvokeKernelFunctions is set. if i don't set it does not recognize kernel functions.
Expected behavior
It should recognize kernel functions and return the result back from my plugin
Screenshots
Platform
Additional context
The text was updated successfully, but these errors were encountered: