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
When using function calling feature for Gemini API, the Tool must be used.
Here is a thought of mine. Is it possible just simple pass a C# method or lambda or it's method type to the GenerateContent method's tools argument. Your library might be able to convert the method into a Tool object. That will be extremely useful.
Furthermore, it's possibly call that method directly when the Gemini API response with that method calls.
The text was updated successfully, but these errors were encountered:
Hi @doggy8088
That sounds like a great idea. I've seen something like this in one of the other .NET-based SDKs where the developer used one or more Attribute marker to handle function calling. I'll put it in the backlog.
Thanks for using the SDK.
The issue has been tagged with help wanted. I'd really love to improve the handling. Right now, one has to provide the function declarations, parameters, etc as pure Javascript objects in order to get it to work.
Similar to the recent changes regarding JSON response schema I'd like to implement some functionality, maybe using an attribute to mark methods, that generates the tool definitions.
Making progress on this task. I wrote a new custom JSON converter to generate the FunctionDeclarations. There is still some work to do, like i.e. switching to chat session and actually invoking the detected function call.
However, it's going to look similar to this.
var prompt = "It is too bright. Change it.";
var googleAi = new GoogleAI(apiKey: fixture.ApiKey);
var model = googleAi.GenerativeModel(model: _model);
var tools = new Tools();
tools.AddFunction(ToggleDarkMode);
var response = await model.GenerateContent(prompt, tools: tools);
Currently, serialization works as expected and Gemini API returns the function_call based on the generated declarations.
I'm hoping to complete this by the beginning of the coming week.
When using function calling feature for Gemini API, the Tool must be used.
Here is a thought of mine. Is it possible just simple pass a C# method or lambda or it's method type to the
GenerateContent
method'stools
argument. Your library might be able to convert the method into aTool
object. That will be extremely useful.Furthermore, it's possibly call that method directly when the Gemini API response with that method calls.
The text was updated successfully, but these errors were encountered: