Skip to content

.NET client library for Ollama - your gateway to seamless integration with the powerful Ollama APIs. This library provides developers with a straightforward way to interact with Ollama APIs, enabling rapid development of robust applications in C#.

License

Notifications You must be signed in to change notification settings

Dev-Art-Solutions/OllamaClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OllamaClient

.NET client library for Ollama - your gateway to seamless integration with the powerful Ollama APIs. This library provides developers with a straightforward way to interact with Ollama APIs, enabling rapid development of robust applications in C#.

Build status

build and test

Quick Start

Installation

Install OllamaClient via NuGet Package Manager Console:

Install-Package OllamaClient

Example

using Microsoft.Extensions.DependencyInjection;
using OllamaClient;
using OllamaClient.Extensions;

var serviceProvider = new ServiceCollection()
          .AddOllamaClient()
          .BuildServiceProvider();

var client = serviceProvider.GetRequiredService<IOllamaHttpClient>();

var pullResult = client.Pull(new OllamaClient.Models.PullRequest()
{
    Name = "mistral",
}, CancellationToken.None);

Console.WriteLine(pullResult.Status);

var models = await client.GetModels(CancellationToken.None);

foreach (var model in models.Models)
{
    Console.WriteLine(model.Name);
}

var result = client.SendChat(new OllamaClient.Models.ChatStreamRequest()
{
    Model = models.Models[0].Name,
    Messages = new List<OllamaClient.Models.Message>() { new OllamaClient.Models.Message()
    {
        Content = "Hello, how are you?",
        Role = "user"
    } }
}, CancellationToken.None);

await foreach (var message in result)
{
    if(message.Message is null) continue;

    Console.Write(message.Message.Content);
}

About

.NET client library for Ollama - your gateway to seamless integration with the powerful Ollama APIs. This library provides developers with a straightforward way to interact with Ollama APIs, enabling rapid development of robust applications in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages