Raygun.Aspire.Hosting.Ollama 1.0.0

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

// Install Raygun.Aspire.Hosting.Ollama as a Cake Tool
#tool nuget:?package=Raygun.Aspire.Hosting.Ollama&version=1.0.0                

Raygun.Aspire.Hosting.Ollama

An Aspire component leveraging the Ollama container with support for downloading a model on startup.

Installation

1. Install the NuGet package

Install the Raygun.Aspire.Hosting.Ollama NuGet package into the Aspire orchestration project (AppHost). Either use the NuGet package management GUI in the IDE you use, OR use the below dotnet command.

dotnet add package Raygun.Aspire.Hosting.Ollama

2. Add the Ollama container

Use the static AddOllama method to add this container component to the application builder.

// The distributed application builder is created here

var ollama = builder.AddOllama();

// The builder is used to build and run the app somewhere down here

Configuration

The AddOllama method has optional arguments to set the name, port and modelName. The name is what gets displayed in the Aspire orchestration app against this component. The port is provided randomly by Aspire. If for whatever reason you need a fixed port, you can set that here. The modelName specifies what LLM to pull when it starts up. The default is llama3. You can also set this to null to prevent any models being pulled on startup - leaving you with a plain Ollama container to work with.

Downloading the LLM

When the Ollama container for this component first spins up, this component will download the LLM (llama3 unless otherwise specified). The progress of this download will be displayed in the State column for this component on the Aspire orchestration app. Important: Keep the Aspire orchestration app open until the download is complete, otherwise the download will be cancelled. In the spirit of productivity, we recommend kicking off this process before heading for lunch. This component binds a volume called "ollama" so that once the model is fully downloaded, it'll be available for subsequent runs.

Accessing the Ollama server from other Aspire components

You can pass the ollama component to other Aspire components in the usual way:

builder.AddMyComponent().WithReference(ollama);

Within that component (e.g. a web app), you can fetch the Ollama connection string from the application builder as follows. Note that if you changed the name of the Ollama component via the name argument, then you'll need to use that here when specifying which connection string to get.

var connectionString = builder.Configuration.GetConnectionString("Ollama");

You can then call any of the Ollama endpoints through this connection string. We recommend using the OllamaSharp client to do this.

Product Compatible and additional computed target framework versions.
.NET 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. 
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.1.0 191 8/13/2024
1.0.0 179 6/7/2024