using System;using System.Text;using System.Threading.Tasks;using Agent.Core.Logging;using Agent.Core.TextToSpeech;using LilithAgent = Lilith.Agent;namespace LilithConsole{ partial class Program { static async Task Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; string model = Environment.GetEnvironmentVariable("LILITH_MODEL") ?? "gemma4"; Console.Title = Environment.GetEnvironmentVariable("GENESIS_TEST_WINDOW_TITLE") ?? $"Lilith — {model} Chat"; var credentials = new LilithAgent.LilithCredentials(Model: model); Action<LogEntry> onLog = entry => { entry.Type.Handle( onWrite: () => Console.Write(entry.Description), onWriteLine: () => Console.WriteLine(entry.Description), onProgress: () => { int width = Math.Max(Console.WindowWidth - 1, 40); string text = entry.Description.Length >= width ? entry.Description[..width] : entry.Description.PadRight(width); Console.Write($"\r{text}"); }); }; var lilith = new LilithAgent.Lilith(onLog, credentials); KokoroTts? tts = null; try { bool waitForTts = Environment.GetEnvironmentVariable("LILITH_WAIT_FOR_TTS") == "1"; tts = await KokoroTts.CreateAsync(lilith.Logger, new KokoroTtsOptions { WaitForTts = waitForTts }); lilith.UseTextToSpeech(tts); } catch (Exception ex) { lilith.Logger.WriteLine("TTS", $"Speech disabled: {ex.Message}", LogColors.Orange); } await lilith.BootAsync(startServerIfNotRunning: true); bool running = true; while (running) { lilith.Logger.Write("Input", "You: ", LogColors.Green); string? input = Console.ReadLine()?.Trim(); if (string.IsNullOrEmpty(input)) { continue; } if (input.StartsWith("/voice ", StringComparison.OrdinalIgnoreCase)) { string newVoice = input.Substring(7).Trim(); if (tts is not null) { try { tts.SetVoice(newVoice); lilith.Logger.WriteLine("System", $"Voice changed to: {newVoice}", LogColors.Cyan); } catch (Exception ex) { lilith.Logger.WriteLine("System", $"Failed to change voice: {ex.Message}", LogColors.Orange); } } else { lilith.Logger.WriteLine("System", "TTS is not enabled.", LogColors.Orange); } continue; } running = await lilith.HandleInputAsync(input); } lilith.SaveConversation(); lilith.Logger.WriteLine("System", "Goodbye.", LogColors.Cyan); } }}
Documentation
Program
Console host for the Version 2 Lilith chat session.
Program.cs
- Sets UTF-8 console output and window title.
- Attempts
KokoroTtssetup (speech after replies); continues without TTS on failure. BootAsyncthen loops on user input untilexitor slash commands.