Skip to content

The assistant

How the TUI's AI assistant works: what it reads, what goes to your AI provider, and how it is built. Its providers, keys and tools: AI.

What the assistant knows

The docs. The assistant is told to answer questions about Virtufin and this TUI (how something works, terms, configuration, the operations, scripts) from the documentation: it searches first, reads a section when the snippet is not enough, links the pages it used, and says when the docs do not cover it. The TUI loads every docs site's MkDocs search index (<site>/search/search_index.json) on the first search into one full-text index, keeps it for a day, and keeps a site's last copy when it cannot be loaded (the search names that site). Only the listed sites are read; VIRTUFIN_TUI_AI_DOCS_SITES (comma-separated base URLs) narrows them. The web app's assistant reads the same sites.

Each turn, the assistant is given a small state snapshot (active scenario, current triggers/topics/workers) so it can use real ids and names instead of guessing. If a model replies with text instead of calling a tool, it is nudged once; if it still doesn't act, its text is shown as a normal chat reply (so models that only half-support tool-calling still work).

Privacy

Each turn sends your message plus the state snapshot (active scenario and summaries of current triggers, topics, and workers) to the configured LLM provider. No secrets (API keys, connection credentials) are included in the snapshot. Be aware of this before pointing the tab at a third-party endpoint -- run a local model (Ollama entry) if the control plane's state must not leave the host.

Implementation notes

  • Agent logic is Textual-free under src/virtufin_tui/ai/ (config.py, llm_client.py, tools.py, agent.py) so it is unit-tested without a Pilot harness.
  • The openai dependency is bundled (a core dependency in the base install).
  • Anthropic-native and streaming token rendering are not yet supported; any OpenAI-compatible endpoint (including local servers) works today.