using Agent.Core.Logging;using Agent.Core.Ollama;namespace Lilith.Agent;public partial class Lilith{ public bool IsBooted { get; private set; } public async Task<string?> BootAsync(bool startServerIfNotRunning = true) { IsBooted = false; await InitializeOllamaAsync(startServerIfNotRunning); await InjectMemoryContextIntoSystemPromptAsync(); Logger.WriteLine("System", $"=== Lilith AI Chat ({Credentials.Model} via Ollama) ===", LogColors.Cyan); Logger.WriteLine("System", "Type your message and press Enter. Type 'exit' to quit.\n", LogColors.Cyan); string? greetReply = await GreetAsync(); EnsureChatReadiness(); Logger.WriteLine("System", "", LogColors.White); IsBooted = true; return greetReply; } public Task<string?> GreetAsync() => ChatAsync( "Greet the user. First use retrieve_memory or get_memory_at_path to check for their name at user/name. " + "If you find a name, greet them by name. If not, ask for their name and offer to remember it with store_memory."); private void EnsureChatReadiness() { if (_client is null) { throw new InvalidOperationException("Ollama client was not initialized."); } if (History.Count == 0 || !string.Equals(History[0].Role, "system", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Chat history was not seeded with a system prompt."); } if (string.IsNullOrWhiteSpace(History[0].Content)) { throw new InvalidOperationException("System prompt content is missing."); } if (ContextMax <= 0) { throw new InvalidOperationException("Model context window was not initialized."); } }}
Documentation
Boot
Startup and readiness for the Lilith chat session.
Lilith.Boot.cs
BootAsync— initializes Ollama, prints the console banner, runs the opening greeting, and validates chat history.GreetAsync— sends the initial “greet the user” prompt through the chat pipeline.EnsureChatReadiness— confirms the Ollama client, system message, and context window are ready before user input.