OllamaSharp 4.0.0-preview.10
See the version list below for details.
dotnet add package OllamaSharp --version 4.0.0-preview.10
NuGet\Install-Package OllamaSharp -Version 4.0.0-preview.10
<PackageReference Include="OllamaSharp" Version="4.0.0-preview.10" />
paket add OllamaSharp --version 4.0.0-preview.10
#r "nuget: OllamaSharp, 4.0.0-preview.10"
// Install OllamaSharp as a Cake Addin #addin nuget:?package=OllamaSharp&version=4.0.0-preview.10&prerelease // Install OllamaSharp as a Cake Tool #tool nuget:?package=OllamaSharp&version=4.0.0-preview.10&prerelease
<p align="center"> <img alt="ollama" height="200px" src="https://github.com/awaescher/OllamaSharp/blob/main/Ollama.png"> </p>
OllamaSharp 🦙
OllamaSharp provides .NET bindings for the Ollama API, simplifying interactions with Ollama both locally and remotely.
✅ Supporting Microsoft.Extensions.AI and Microsoft Semantic Kernel
Features
- Ease of use: Interact with Ollama in just a few lines of code.
- API endpoint coverage: Support for all the Ollama API endpoints, including chats, embeddings, listing models, pulling and creating new models, and more.
- Real-time streaming: Stream responses directly to your application.
- Progress reporting: Get real-time progress feedback on tasks like model pulling.
- Support for vision models and tools (function calling).
Usage
OllamaSharp wraps each Ollama API endpoint in awaitable methods that fully support response streaming.
The following list shows a few simple code examples.
ℹ Try our full featured demo application that's included in this repository
Initializing
// set up the client
var uri = new Uri("http://localhost:11434");
var ollama = new OllamaApiClient(uri);
// select a model which should be used for further operations
ollama.SelectedModel = "llama3.1:8b";
Listing all models that are available locally
var models = await ollama.ListLocalModelsAsync();
Pulling a model and reporting progress
await foreach (var status in ollama.PullModelAsync("llama3.1:405b"))
Console.WriteLine($"{status.Percent}% {status.Status}");
Generating a completion directly into the console
await foreach (var stream in ollama.GenerateAsync("How are you today?"))
Console.Write(stream.Response);
Building interactive chats
var chat = new Chat(ollama);
while (true)
{
var message = Console.ReadLine();
await foreach (var answerToken in chat.SendAsync(message))
Console.Write(answerToken);
}
// messages including their roles and tool calls will automatically be tracked within the chat object
// and are accessible via the Messages property
Credits
The icon and name were reused from the amazing Ollama project.
I would like to thank all the contributors who take the time to improve OllamaSharp. First and foremost mili-tan, who always keeps OllamaSharp in sync with the Ollama API. ❤
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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 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. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.0-rc.2.24473.5)
- Microsoft.Extensions.AI.Abstractions (>= 9.0.0-preview.9.24507.7)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on OllamaSharp:
Package | Downloads |
---|---|
Microsoft.KernelMemory.AI.Ollama
Provide access to Ollama LLM models in Kernel Memory to generate embeddings and text |
|
Microsoft.SemanticKernel.Connectors.Ollama
Semantic Kernel connector for Ollama. Contains services for text generation, chat completion and text embeddings. |
|
CommunityToolkit.Aspire.Hosting.Ollama
An Aspire integration leveraging the Ollama container with support for downloading a model on startup. |
|
CommunityToolkit.Aspire.OllamaSharp
A .NET Aspire client integration for the OllamaSharp library. |
|
EnergyAssembly
Package Description |
GitHub repositories (6)
Showing the top 5 popular GitHub repositories that depend on OllamaSharp:
Repository | Stars |
---|---|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
microsoft/kernel-memory
RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.
|
|
dotnet/ai-samples
|
|
CommunityToolkit/Aspire
A community project with additional components and extensions for .NET Aspire
|
|
lindexi/lindexi_gd
博客用到的代码
|
Version | Downloads | Last updated |
---|---|---|
4.0.22 | 246 | 2 days ago |
4.0.21 | 22 | 2 days ago |
4.0.20 | 204 | 3 days ago |
4.0.19 | 7 | 3 days ago |
4.0.18 | 147 | 4 days ago |
4.0.17 | 1,636 | 8 days ago |
4.0.16 | 74 | 8 days ago |
4.0.15 | 68 | 8 days ago |
4.0.14 | 74 | 8 days ago |
4.0.13 | 72 | 8 days ago |
4.0.12 | 73 | 8 days ago |
4.0.11 | 7,249 | a month ago |
4.0.10 | 61 | a month ago |
4.0.9 | 1,688 | a month ago |
4.0.8 | 18,555 | 2 months ago |
4.0.7 | 3,554 | 2 months ago |
4.0.6 | 11,602 | 2 months ago |
4.0.5 | 1,302 | 2 months ago |
4.0.4 | 381 | 2 months ago |
4.0.3 | 8,368 | 2 months ago |
4.0.2 | 261 | 2 months ago |
4.0.1 | 2,068 | 3 months ago |
4.0.0-preview.10 | 82 | 3 months ago |
4.0.0-preview.9 | 53 | 3 months ago |
4.0.0-preview.8 | 79 | 3 months ago |
3.0.15 | 3,154 | 3 months ago |
3.0.14 | 6,965 | 3 months ago |
3.0.13 | 93 | 3 months ago |
3.0.12 | 15,272 | 3 months ago |
3.0.11 | 1,369 | 3 months ago |
3.0.10 | 10,510 | 3 months ago |
3.0.9 | 98 | 3 months ago |
3.0.8 | 13,148 | 4 months ago |
3.0.7 | 19,660 | 4 months ago |
3.0.6 | 1,180 | 4 months ago |
3.0.5 | 792 | 4 months ago |
3.0.4 | 25,031 | 4 months ago |
3.0.3 | 118 | 4 months ago |
3.0.2 | 418 | 4 months ago |
3.0.1 | 16,989 | 4 months ago |
3.0.0 | 1,991 | 5 months ago |
2.1.3 | 2,569 | 5 months ago |
2.1.2 | 2,219 | 5 months ago |
2.1.1 | 4,141 | 5 months ago |
2.0.15 | 137 | 5 months ago |
2.0.14 | 103 | 5 months ago |
2.0.13 | 1,837 | 5 months ago |
2.0.12 | 113 | 5 months ago |
2.0.11 | 124 | 5 months ago |
2.0.10 | 3,937 | 6 months ago |
2.0.9 | 101 | 6 months ago |
2.0.8 | 138 | 6 months ago |
2.0.7 | 1,591 | 6 months ago |
2.0.6 | 3,087 | 7 months ago |
2.0.5 | 108 | 7 months ago |
2.0.4 | 577 | 7 months ago |
2.0.3 | 109 | 7 months ago |
2.0.2 | 158 | 7 months ago |
2.0.1 | 3,676 | 7 months ago |
1.1.13 | 185 | 7 months ago |
1.1.12 | 476 | 7 months ago |
1.1.11 | 301 | 7 months ago |
1.1.10 | 1,011 | 7 months ago |
1.1.9 | 7,127 | 8 months ago |
1.1.8 | 1,363 | 8 months ago |
1.1.7 | 122 | 8 months ago |
1.1.5 | 115 | 8 months ago |
1.1.4 | 186 | 8 months ago |
1.1.3 | 116 | 8 months ago |
1.1.2 | 117 | 8 months ago |
1.1.1 | 3,182 | 10 months ago |
1.1.0 | 1,874 | 1/8/2024 |
1.0.4 | 296 | 12/27/2023 |
1.0.3 | 343 | 11/30/2023 |
1.0.2 | 334 | 11/5/2023 |
1.0.1 | 190 | 10/16/2023 |
1.0.0 | 1,508 | 10/16/2023 |