-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: C#
- OS: Win11
- Language runtime version: .NET 10
- Package version: 0.13.1
Steps to reproduce
- Take you example code from the README for tool calling. Like this.
using Google.GenAI;
using Microsoft.Extensions.AI;
using System.ComponentModel
// assuming credentials are set up in environment variables as instructed above.
IChatClient chatClient = new Client().AsIChatClient("gemini-2.0-flash")
.AsBuilder()
.UseFunctionInvocation()
.UseOpenTelemetry()
.Build();
ChatOptions options = new()
{
Tools = [AIFunctionFactory.Create(([Description("The name of the person whose age is to be retrieved")] string personName) => personName switch
{
"Alice" => 30,
"Bob" => 25,
_ => 35
}, "get_person_age", "Gets the age of the specified person");
};
await foreach (var update in chatClient.GetStreamingResponseAsync("How much older is Alice than Bob?", options))
{
Console.Write(update);
}- Modify the ChatOptions so it has a GenerateContentConfig instance.
var generateContentConfig = new Google.GenAI.Types.GenerateContentConfig();
ChatOptions options = new()
{
RawRepresentationFactory = (_) => generateContentConfig,
Tools = [AIFunctionFactory.Create(([Description("The name of the person whose age is to be retrieved")] string personName) => personName switch
{
"Alice" => 30,
"Bob" => 25,
_ => 35
}, "get_person_age", "Gets the age of the specified person");
};Having the RawRepresentationFactory will cause the tool calling to now fail with an error of 'Duplicate function declaration found:'. Remove that entry in ChatOptions and it works again.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.