Mscc.GenerativeAI.Microsoft
1.8.2-preview
See the version list below for details.
dotnet add package Mscc.GenerativeAI.Microsoft --version 1.8.2-preview
NuGet\Install-Package Mscc.GenerativeAI.Microsoft -Version 1.8.2-preview
<PackageReference Include="Mscc.GenerativeAI.Microsoft" Version="1.8.2-preview" />
paket add Mscc.GenerativeAI.Microsoft --version 1.8.2-preview
#r "nuget: Mscc.GenerativeAI.Microsoft, 1.8.2-preview"
// Install Mscc.GenerativeAI.Microsoft as a Cake Addin #addin nuget:?package=Mscc.GenerativeAI.Microsoft&version=1.8.2-preview&prerelease // Install Mscc.GenerativeAI.Microsoft as a Cake Tool #tool nuget:?package=Mscc.GenerativeAI.Microsoft&version=1.8.2-preview&prerelease
MSCC GenerativeAI for .NET integrating with Microsoft.Extensions.AI and Microsoft Semantic Kernel.
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 | Versions 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. |
-
.NETFramework 4.7.2
- Microsoft.Extensions.AI (>= 9.0.0-preview.9.24525.1)
- Mscc.GenerativeAI (>= 1.8.1)
-
.NETStandard 2.0
- Microsoft.Extensions.AI (>= 9.0.0-preview.9.24525.1)
- Mscc.GenerativeAI (>= 1.8.1)
-
net6.0
- Microsoft.Extensions.AI (>= 9.0.0-preview.9.24525.1)
- Mscc.GenerativeAI (>= 1.8.1)
-
net8.0
- Microsoft.Extensions.AI (>= 9.0.0-preview.9.24525.1)
- Mscc.GenerativeAI (>= 1.8.1)
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.9.5-preview | 41 | 11/22/2024 |
1.9.4 | 38 | 11/21/2024 |
1.9.3 | 39 | 11/20/2024 |
1.9.2 | 39 | 11/18/2024 |
1.9.1 | 38 | 11/13/2024 |
1.9.0-preview | 38 | 11/4/2024 |
1.8.3-preview | 38 | 11/1/2024 |
1.8.2-preview | 41 | 10/31/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