VOOZH about

URL: https://www.nuget.org/packages/Google_GenerativeAI.Tools/

⇱ NuGet Gallery | Google_GenerativeAI.Tools 3.6.6


ο»Ώ

πŸ‘ Image
Google_GenerativeAI.Tools 3.6.6

dotnet add package Google_GenerativeAI.Tools --version 3.6.6
 
 
NuGet\Install-Package Google_GenerativeAI.Tools -Version 3.6.6
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Google_GenerativeAI.Tools" Version="3.6.6" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Google_GenerativeAI.Tools" Version="3.6.6" />
 
Directory.Packages.props
<PackageReference Include="Google_GenerativeAI.Tools" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Google_GenerativeAI.Tools --version 3.6.6
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Google_GenerativeAI.Tools, 3.6.6"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Google_GenerativeAI.Tools@3.6.6
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Google_GenerativeAI.Tools&version=3.6.6
 
Install as a Cake Addin
#tool nuget:?package=Google_GenerativeAI.Tools&version=3.6.6
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Google_GenerativeAI.Tools

πŸ‘ NuGet
πŸ‘ License: MIT

Google_GenerativeAI.Tools – README

A comprehensive toolkit to seamlessly integrate and structure your Google Gemini function calls in C#. Google_GenerativeAI.Tools is offered as part of the Google_GenerativeAI SDK, supporting multiple modes of usage: either through reflection-based approaches or via code generation.


Table of Contents

  1. Installation
  2. Approaches
  3. Comparison
  4. Contributing
  5. License

Introduction

Google_GenerativeAI.Tools streamlines how you define, discover, and call your functions for Google Gemini.

Key features:

  • Flexible reflection-based or code generation-based approaches.
  • Automatic JSON schema generation for advanced scenarios.
  • Strong typing and maintainability for large projects.
  • NativeAOT-friendly APIs to ensure trimming safety.

Installation

  1. Install the NuGet package (assuming it's available on NuGet.org):

    dotnet add package Google.GenerativeAI.Tools
    
  2. Reference the package in your project file:

    <ItemGroup>
     <PackageReference Include="Google.GenerativeAI.Tools" Version="x.x.x" />
    </ItemGroup>
    
  3. Restore packages:

    dotnet restore
    

Approaches

1. Reflection-Based

This method depends on runtime inspection of methods or delegates to generate the schema and create function tools.

Pros

  • Rapid development.
  • Minimal boilerplate, ideal for smaller or proof-of-concept projects.

Cons

  • Requires manual handling of complex serialization contexts (e.g., JsonSerializerContext) for NativeAOT.
  • Less structured than code generation.
Examples (Reflection-Based)

Use [QuickTool] or [QuickTools] to define reflection-based tools:


public record StudentRecord
{
 public string StudentId { get; set; }
 public string FullName { get; set; }
 // ...
}

// Reflection-based delegate
var func = (async ([Description("Query to retrieve student record")] string fullName) =>
{
 // Implementation detail
 return new StudentRecord
 {
 StudentId = "12345",
 FullName = fullName
 };
});

// Create QuickTool
var quickFt = new QuickTool(func, "GetStudentRecordAsync", "Returns the student record");

var model = new GenerativeModel(/* your config */);
model.AddFunctionTool(quickFt);

// Usage
var result = await model.GenerateContentAsync("What's the student record for John Joe?");
Console.WriteLine(result.Text());

2. Code Generator-Based

Code generation automatically produces schemas and extension methods, saving you from manually dealing with reflection or serializer contexts.

Pros

  • Automatic JSON schema creation (bypassing reflection).
  • NativeAOT ready with minimal extra configuration.
  • Clean, strongly typed approach for large or complex projects.

Cons

  • Additional codegen step required.
  • Slightly steeper initial setup.
2.1 Individual Methods

Decorate your methods with [FunctionTool] to generate the needed schemas and integrate them:

[FunctionTool(GoogleFunctionTool = true)]
[Description("Retrieves content of a specific book page")]
public static Task<string> GetBookPageContentAsync(
 string bookName, 
 int pageNumber, 
 CancellationToken cancellationToken = default)
{
 // Implementation
 return Task.FromResult($"Page {pageNumber} of {bookName}");
}

//Usage

var tools = new Tools([GetBookPageContentAsync]);
generativeModel.AddFunctionTool(tools);

Generated code will handle JSON schema definitions and produce extension methods to register with your GenerativeModel.

2.2 Interface-Based

Build an interface to define one or more related methods. The code generator scans [GenerateJsonSchema] attributes to build tooling and registration code:

[GenerateJsonSchema(GoogleFunctionTool = true)]
public interface IWeatherFunctions
{
 [Description("Get current weather in a location")]
 Weather GetCurrentWeather(
 [Description("City and state, e.g. San Francisco, CA")]
 string location, 
 Unit unit = Unit.Celsius);
 // ... 
}

public class WeatherService : IWeatherFunctions
{
 public Weather GetCurrentWeather(string location, Unit unit = Unit.Celsius)
 {
 return new Weather
 {
 Location = location,
 Temperature = 20,
 Unit = unit
 };
 }
}

// Register after code generation
var weatherService = new WeatherService();
var googleTool = weatherService.AsGoogleFunctionTool();
model.AddFunctionTool(googleTool);

Interface Grouping
Group multiple functions in one interface, effectively creating a reusable β€œplugin.”


Comparison

Aspect Reflection-Based Code Generator-Based
Setup Complexity Low (quick prototyping) Moderate (attributes, interfaces, codegen)
Serialization Handling Manual (must define JsonSerializerContext for complex) Automatic via generated code
NativeAOT / Trimming Extra steps to preserve reflection data Designed for AOT; minimal extra configuration
Grouping Multiple Methods Possible, but less structured Interface-based approach naturally groups multiple methods as a reusable plugin
Use Cases Small or short-lived projects, quick PoCs Enterprise solutions with complex needs requiring maintainability and strong typing

Checkout Wiki Page for more in depth example uses


Contributing

  1. Fork this repository (if applicable).
  2. Create a feature branch.
  3. Submit a pull request describing your changes.

Please add tests and documentation for any new features.


License

This project is available under [MIT] License. Refer to the LICENSE file for more details.

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 is compatible.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.6 1,028 4/20/2026
3.6.5 64 4/18/2026
3.6.4 345 3/26/2026
3.6.3 501 1/23/2026
3.6.2 111 1/15/2026
3.6.1 230 12/28/2025
3.5.0 138 12/26/2025
3.4.1 17,028 11/8/2025
3.4.0 1,256 10/21/2025
3.3.0 1,126 10/3/2025
3.2.0 1,663 9/10/2025
3.1.1 185 9/7/2025
3.0.0 1,210 7/21/2025
2.7.0 1,473 6/2/2025
2.6.0 546 5/25/2025
2.5.10 354 5/9/2025
2.5.9.1 198 5/25/2025
2.5.9 241 4/25/2025
2.5.8.1 196 5/25/2025
2.5.8 231 4/18/2025
Loading failed