Implementation:Neuml Txtai Interactive Console
| Knowledge Sources | |
|---|---|
| Domains | CLI, REPL, Search |
| Last Updated | 2026-02-10 01:00 GMT |
Overview
Concrete tool for interactive REPL-based search and workflow execution provided by txtai.
Description
The Console class is an interactive command-line REPL (Read-Eval-Print Loop) built on Python's cmd.Cmd with rich terminal output via the rich library. It loads a txtai Application (from YAML config) or Embeddings index and allows users to interactively run searches, execute workflows, adjust result highlighting, and modify result limits. Search results are rendered as formatted tables with optional token-level highlighting for explainability. The console supports the following commands:
- Default input: treated as a search query
.load: load an index or application configuration.config: display current configuration.highlight: set/toggle token highlight color for explainability.limit: set maximum results per search.workflow: execute a named workflow
Usage
Use the Console when you want an interactive terminal session for exploring txtai indexes and applications. It is launched from the command line and supports loading both raw embeddings indexes and full YAML-configured applications. The console is useful for rapid prototyping, debugging queries, and exploring search results with visual highlighting.
Code Reference
Source Location
- Repository: Neuml_Txtai
- File: src/python/txtai/console/base.py
Signature
class Console(Cmd):
def __init__(self, path=None)
def preloop(self)
def default(self, line)
def config(self)
def highlight(self, command)
def limit(self, command)
def load(self, path)
def search(self, query)
def workflow(self, command)
def isyaml(self, path)
def split(self, command, default=None)
def render(self, result, column, value)
Import
from txtai.console.base import Console
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | str | No | Path to initial YAML configuration file or embeddings index directory to load on startup |
| line | str | Yes (default) | Raw command-line input from the user; dispatched to the appropriate handler based on prefix |
| query | str | Yes (search) | Search query string to execute against the loaded application or embeddings |
Outputs
| Name | Type | Description |
|---|---|---|
| search output | Rich Table | Formatted table printed to the terminal with search results (id, score, text, etc.) |
| workflow output | list | Printed list of results from the named workflow execution |
| config output | dict | Printed application configuration dictionary |
Usage Examples
from txtai.console.base import Console
# Launch interactive console with an initial index
console = Console(path="/path/to/embeddings/index")
console.cmdloop()
# In the REPL session:
# >>> machine learning techniques
# (displays search results in a rich table)
#
# >>> .load /path/to/app.yml
# Loading application /path/to/app.yml
#
# >>> .highlight #00ff00
# Set highlight to #00ff00
#
# >>> .limit 20
# Set limit to 20
#
# >>> .workflow summary "text to summarize"
# (displays workflow output)
#
# >>> .config
# (displays current configuration)