OllamaClientLibrary 1.0.0

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

// Install OllamaClientLibrary as a Cake Tool
#tool nuget:?package=OllamaClientLibrary&version=1.0.0                

OllamaClientLibrary

OllamaClientLibrary is a .NET Standard 2.1 library for interacting with the Ollama API. It provides functionality to generate text completions and chat completions using various models.

Features

  • Generate text completions
  • Generate json completions
  • Generate chat completions
  • List available local and remote models with filtering options
  • Configurable options for temperature, model, and API key

Installation

You can install the package via NuGet:

dotnet add package OllamaClientLibrary

Usage

Generate JSON Completion sample

  • Setup OllamaClient
using var client = new OllamaClient(new LocalOllamaOptions()
{
    Host = "http://localhost:11434", // default host is http://localhost:11434
    Model = "llama3.2:latest", // default model is "deepseek-r1". Make sure this model is available in your Ollama installation. 
    Temperature = Temperature.DataCleaningOrAnalysis, // default is Temperature.GeneralConversationOrTranslation
    ApiKey = "your-api-key" // optional, by default it is null
});
  • Create DTO objects
class Response
{
    public List<DotNetCoreVersion>? Data { get; set; }
}

class DotNetCoreVersion
{
    [JsonSchemaFormat("string", @"^([0-9]+).([0-9]+).([0-9]+)$")]
    public string? Version { get; set; }

    public DateTime? ReleaseDate { get; set; }

    public DateTime? EndOfLife { get; set; }
}
  • Provide a prompt and get a JSON Completion
var response = await client.GenerateCompletionJsonAsync<Response>("You are a professional .net developer. Provide a list of all available .NET Core versions for the last 5 years");
  • Display the result
    if (response?.Data != null)
    {
        foreach (var item in response.Data.OrderBy(s => s.ReleaseDate))
        {
            Console.WriteLine($"Version: {item.Version}, ReleaseDate: {item.ReleaseDate}, EndOfLife: {item.EndOfLife}");
        }
    }

More samples

License

This project is licensed under the MIT License.

Repository

For more information, visit the GitHub repository.

Author

Oleksandr Kushnir

Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.2.0 83 2/16/2025
1.1.0 70 2/14/2025
1.0.1 78 2/9/2025
1.0.0 82 2/9/2025