# Chat The chat TUI runs conversational RAG against your database from the terminal. Streaming responses, expandable citations with visual grounding, multi-turn sessions, and a command palette for filtering and inspection. !!! note Requires the `tui` extra: `pip install haiku.rag-slim[tui]` (included in the full `haiku.rag` package). ## Run it ```bash haiku-rag chat haiku-rag chat --db /path/to/database.lancedb haiku-rag chat --model openai:gpt-4o ``` 
*Demo: chatting with an agent over 1000 arXiv papers. Shows context building (3:00), citations with visual grounding (3:20), and document listing.* ## How it works The chat is a Pydantic AI agent with the `rag` [skill](skills/rag.md) attached. Each turn the agent decides which tool to call next, runs hybrid search against your documents, expands context around the hits, may issue further searches, and answers with citations. You see streaming text and a live indicator of which tool is running. The session is in-memory for the lifetime of the TUI. Conversation history is kept across turns so follow-up questions reuse prior context. Citations are tracked per turn and inspectable via the command palette. Clearing the chat resets the session and the agent's memory. ## Citations and visual grounding Each answer cites the chunks the agent used, with source document, page numbers, and section headings. Citations are expandable inline. For visual grounding (the chunk highlighted on its page image), open the command palette and pick "Show visual grounding". This requires: - Documents processed via Docling with page images (default for PDFs). - A terminal that supports inline images (iTerm2, WezTerm, Kitty). - A stored DoclingDocument on the document. Plain text added via `haiku-rag add` doesn't have it. You can also render visual grounding from the CLI without launching the TUI: ```bash haiku-rag visualize