Ollama/Lilith.Ollama.cscsharp

Documentation

Ollama

Wiring between Lilith and the shared Agent-Core Ollama client.

Lilith.Ollama.cs

  • InitializeOllamaAsync — creates the client with model, system prompt, and optional auto-start of the Ollama service.
  • Exposes History, ContextMax, and CurrentContextTokens from the underlying client.
  • Subscribes to high context usage warnings for the console UI.
using Agent.Core.Logging;using Agent.Core.Ollama;namespace Lilith.Agent;public partial class Lilith{    private OllamaClient _client = null!;    public ChatHistory History => _client.History;    public int ContextMax => _client.ContextMax;    public int CurrentContextTokens => _client.CurrentContextTokens;    private async Task InitializeOllamaAsync(bool startServerIfNotRunning)    {        _client = await OllamaClient.CreateClient(            Credentials.Model,            Credentials.SystemPrompt,            Logger,            startServerIfNotRunning,            agentName: Credentials.AgentName);        _client.ToolRegistry = BuildToolRegistry();        _client.OnContextHighUsage += pct =>            Logger.WriteLine("System", $"\u26a0 Context window is {pct}% full — history is getting long.", LogColors.Orange);    }}