Table of Contents

Namespace OllamaSharp

Classes

Chat

A chat helper that handles the chat logic internally and automatically extends the message history.

A simple interactive chat can be implemented in just a handful of lines:
var ollama = new OllamaApiClient("http://localhost:11434", "llama3.2-vision:latest");
var chat = new Chat(ollama);
// ...
while (true)
{
	Console.Write("You: ");
	var message = Console.ReadLine()!;
	Console.Write("Ollama: ");
	await foreach (var answerToken in chat.SendAsync(message))
		Console.Write(answerToken);
	// ...
	Console.WriteLine();
}
// ...
// Output:
// You: Write a haiku about AI models
// Ollama: Code whispers secrets
//   Intelligent designs unfold
//   Minds beyond our own
ChatOptionsExtensions

Extension methods to stream IAsyncEnumerable to its end and return one single result value

ConversationContext

Represents a conversation context containing context data.

IAsyncEnumerableExtensions

Extension methods to stream IAsyncEnumerable to its end and return one single result value

OllamaApiClient

The default client to use the Ollama API conveniently. https://github.com/jmorganca/ollama/blob/main/docs/api.md

OllamaApiClient.Configuration

The configuration for the Ollama API client.

OllamaApiClientExtensions

Extension methods to simplify the usage of the IOllamaApiClient.

OllamaToolAttribute

Specifies that the class or method is a tool for Ollama. OllamaSharp will generate an implementation of this class or method with the name suffix -Tool. If your method is named "GetWeather", the generated class will be named "GetWeatherTool".

ToolSourceGenerator

A source generator that produces tool implementations including invocations for methods marked with [OllamaToolAttribute].

Interfaces

IOllamaApiClient

Interface for the Ollama API client.