Mscc.GenerativeAI.Google 1.8.2-preview

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

// Install Mscc.GenerativeAI.Google as a Cake Tool
#tool nuget:?package=Mscc.GenerativeAI.Google&version=1.8.2-preview&prerelease                

MSCC GenerativeAI for .NET integrating with Microsoft.Extensions.AI and Microsoft Semantic Kernel.

GitHub GitHub last commit

Integrate Gemini API into your .NET applications using Microsoft.Extensions.AI. This package implements the IChatClient and IEmbeddingGenerator interfaces offering a unified experience for .NET applications and libraries.

Benefits of Microsoft.Extensions.AI

Microsoft.Extensions.AI offers a unified API abstraction for AI services, similar to our successful logging and dependency injection (DI) abstractions. Our goal is to provide standard implementations for caching, telemetry, tool calling, and other common tasks that work with any provider.

Read more Introducing Microsoft.Extensions.AI Preview – Unified AI Building Blocks for .NET

Getting started

To get started, you can create a console application and install the Mscc.GenerativeAI.Microsoft package. Have your API key from Google AI Studio and you're ready to go.

Chat

using Microsoft.Extensions.AI;
using Mscc.GenerativeAI.Microsoft;

// Chat with Gemini API.
var apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
var model = "gemini-1.5-pro-latest";
var prompt = "What is AI?";

IChatClient chatClient = new GeminiChatClient(apiKey, model);

var response = await chatClient.CompleteAsync(prompt);
Console.WriteLine(response.Message);

response = await chatClient.CompleteAsync( 
    "Translate the following text into Pig Latin: I love .NET and AI"); 
Console.WriteLine(response.Message);

Embeddings

using Microsoft.Extensions.AI;
using Mscc.GenerativeAI.Microsoft;

// Create embeddings using the appropriate model.
var apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
var model = "text-embedding-004";
var prompt = "What is AI?";

IEmbeddingGenerator<string,Embedding<float>> generator = 
    new GeminiEmbeddingGenerator(apiKey, model);

var embeddings = await generator.GenerateAsync([prompt]);
Console.WriteLine(string.Join(", ", embeddings[0].Vector.ToArray()));

More examples

The folders samples and tests contain more examples.

Troubleshooting

tba

Feedback

You can create issues at the https://github.com/mscraftsman/generative-ai repository.

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 was computed.  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 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  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

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
1.8.3 7 11/1/2024
1.8.2 26 10/31/2024
1.8.2-preview 22 10/31/2024
1.8.1 42 10/30/2024
1.8.0 63 10/29/2024
1.7.0 96 10/14/2024
1.6.5 73 10/13/2024
1.6.4 88 10/9/2024
1.6.3 109 9/24/2024
1.6.2 94 9/19/2024
1.6.1 81 9/18/2024
1.6.0 158 8/29/2024
1.5.1 109 7/31/2024
1.5.0 646 5/15/2024
1.4.0 255 4/22/2024
1.3.0 110 4/18/2024
1.2.0 115 4/16/2024
1.1.4 109 4/15/2024
1.1.3 122 4/12/2024
1.1.2 102 4/11/2024
1.1.1 107 4/10/2024
1.1.0 107 4/9/2024
1.0.1 126 4/1/2024
1.0.0 121 3/30/2024
0.9.4 112 3/29/2024
0.9.3 119 3/28/2024
0.9.1 116 3/26/2024
0.9.0 114 3/23/2024
0.8.4 157 3/21/2024
0.8.3 122 3/20/2024
0.8.2 142 3/20/2024
0.8.1 118 3/20/2024
0.8.0 117 3/20/2024
0.7.2 124 3/18/2024
0.7.1 123 3/18/2024
0.7.0 152 3/15/2024

# Changelog (Release Notes)

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
### Changed
### Fixed

## 1.8.2

### Added

- initial release