Google_GenerativeAI 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Google_GenerativeAI --version 0.1.0
NuGet\Install-Package Google_GenerativeAI -Version 0.1.0
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" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Google_GenerativeAI --version 0.1.0
#r "nuget: Google_GenerativeAI, 0.1.0"
#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.
// Install Google_GenerativeAI as a Cake Addin
#addin nuget:?package=Google_GenerativeAI&version=0.1.0

// Install Google_GenerativeAI as a Cake Tool
#tool nuget:?package=Google_GenerativeAI&version=0.1.0

Google GenerativeAI (Gemini)

Unofficial C# SDK based on Google GenerativeAI (Gemini Pro) REST APIs.

This package includes C# Source Generator which allows you to define functions natively through a C# interface, and also provides extensions that make it easier to call this interface later.
In addition to easy function implementation and readability, it generates Args classes, extension methods to easily pass a functions to API, and extension methods to simply call a function via json and return json.
Currently only System.Text.Json is supported.

Usage

Quick Start

  1. Obtain an API key to use with the Google AI SDKs.
 var apiKey = 'Your API Key';

 var model = new GenerativeModel(apiKey);

 var res = await model.GenerateContentAsync("How are you doing?");

Function Calling

using GenerativeAI;

public enum Unit
{
    Celsius,
    Fahrenheit,
}

public class Weather
{
    public string Location { get; set; } = string.Empty;
    public double Temperature { get; set; }
    public Unit Unit { get; set; }
    public string Description { get; set; } = string.Empty;
}

[GenerativeAIFunctions]
public interface IWeatherFunctions
{
    [Description("Get the current weather in a given location")]
    public Task<Weather> GetCurrentWeatherAsync(
        [Description("The city and state, e.g. San Francisco, CA")] string location,
        Unit unit = Unit.Celsius,
        CancellationToken cancellationToken = default);
}

public class WeatherService : IWeatherFunctions
{
    public Task<Weather> GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default)
    {
        return Task.FromResult(new Weather
        {
            Location = location,
            Temperature = 22.0,
            Unit = unit,
            Description = "Sunny",
        });
    }
}

 WeatherService service = new WeatherService();
 
 var apiKey = Environment.GetEnvironmentVariable("Gemini_API_Key", EnvironmentVariableTarget.User);

 var model = new GenerativeModel(apiKey, functions:service.AsFunctions(),calls:service.AsCalls());

 var result = await model.GenerateContentAsync("What is the weather in San Francisco today?");
 
 Console.WriteLine(result);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Google_GenerativeAI:

Package Downloads
LangChain.Providers.Google

Google Gemini Chat model provider.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Google_GenerativeAI:

Repository Stars
tryAGI/LangChain
C# implementation of LangChain. We try to be as close to the original as possible in terms of abstractions, but are open to new entities.
Version Downloads Last updated
1.0.0 208 5/22/2024
0.1.20 752 4/29/2024
0.1.19 3,418 4/4/2024
0.1.18 204 4/3/2024
0.1.17 74 4/3/2024
0.1.16 77 4/3/2024
0.1.15 438 2/25/2024
0.1.14 1,977 2/24/2024
0.1.13 73 2/24/2024
0.1.12 4,507 12/19/2023
0.1.11 97 12/19/2023
0.1.10 83 12/19/2023
0.1.9 124 12/18/2023
0.1.7 73 12/18/2023
0.1.6 88 12/18/2023
0.1.5 102 12/18/2023
0.1.4 93 12/18/2023
0.1.3 88 12/18/2023
0.1.2 90 12/18/2023
0.1.1 115 12/18/2023
0.1.0 110 12/17/2023