Mscc.GenerativeAI.Microsoft
1.9.5-preview
dotnet add package Mscc.GenerativeAI.Microsoft --version 1.9.5-preview
NuGet\Install-Package Mscc.GenerativeAI.Microsoft -Version 1.9.5-preview
<PackageReference Include="Mscc.GenerativeAI.Microsoft" Version="1.9.5-preview" />
paket add Mscc.GenerativeAI.Microsoft --version 1.9.5-preview
#r "nuget: Mscc.GenerativeAI.Microsoft, 1.9.5-preview"
// Install Mscc.GenerativeAI.Microsoft as a Cake Addin #addin nuget:?package=Mscc.GenerativeAI.Microsoft&version=1.9.5-preview&prerelease // Install Mscc.GenerativeAI.Microsoft as a Cake Tool #tool nuget:?package=Mscc.GenerativeAI.Microsoft&version=1.9.5-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. net9.0 is compatible. |
.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.1-preview.1.24570.5)
- Mscc.GenerativeAI (>= 1.9.2)
-
.NETStandard 2.0
- Microsoft.Extensions.AI (>= 9.0.1-preview.1.24570.5)
- Mscc.GenerativeAI (>= 1.9.2)
-
net6.0
- Microsoft.Extensions.AI (>= 9.0.1-preview.1.24570.5)
- Mscc.GenerativeAI (>= 1.9.2)
-
net8.0
- Microsoft.Extensions.AI (>= 9.0.1-preview.1.24570.5)
- Mscc.GenerativeAI (>= 1.9.2)
-
net9.0
- Microsoft.Extensions.AI (>= 9.0.1-preview.1.24570.5)
- Mscc.GenerativeAI (>= 1.9.2)
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 | 0 | 11/22/2024 |
1.9.4 | 22 | 11/21/2024 |
1.9.3 | 33 | 11/20/2024 |
1.9.2 | 36 | 11/18/2024 |
1.9.1 | 35 | 11/13/2024 |
1.9.0-preview | 37 | 11/4/2024 |
1.8.3-preview | 37 | 11/1/2024 |
1.8.2-preview | 40 | 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.9.5
### Changed
- Update M.E.AI to 9.0.1-preview.1.24570.5 [#48](https://github.com/mscraftsman/generative-ai/pull/48) - thanks to @stephentoub
## 1.9.4
### Changed
- bump version
## 1.9.3
### Changed
- bump version
## 1.9.2
### Changed
- bump version
## 1.9.1
### Changed
- PR: Update Microsoft.Extensions.AI to 9.0.0-preview.9.24556.5 [#44](https://github.com/mscraftsman/generative-ai/pull/44) - thanks to @stephentoub
## 1.9.0
### Changed
- bump version
## 1.8.3
### Changed
- bump version
## 1.8.2
### Added
- initial release