Repository navigation
en 02 03 cli interactive guide and playground
The framework provides a unified command-line tool suite under ai-rag (and the rag-mcp standalone binary).
This CLI validates your environment, lets you interactively test models and embeddings in your terminal, and scaffolds production-ready microservices without writing boilerplate.
Before debugging unexpected connection errors, run:
ai-rag doctor-
Python Version: Confirms Python runtime is
$\ge 3.11$ . - SQLite FTS5 Extension: Checks that the local SQLite engine supports Full-Text Search (required for BM25 hybrid retrieval).
-
Configuration Loading: Validates
.envformatting and syntax. - API Key Presence: Verifies credentials for Gemini, OpenAI, Anthropic, etc.
-
Filesystem Permissions: Ensures write permissions for SQLite
.dbstorage. -
Local Model Connectivity: If
OLLAMA_BASE_URLis set, verifies that the Ollama daemon is reachable.
Checking AI RAG Common Framework Environment:
[PASS] Python Version: 3.11.9 (64-bit)
[PASS] SQLite FTS5 Full-Text Engine: Available
[PASS] Settings File: .env loaded successfully
[PASS] Provider 'gemini': API key configured (gemini-2.5-flash)
[INFO] Provider 'openai': Not configured (optional)
[PASS] Storage permissions: Write access OK (./data)
============================================================
Status: HEALTHY - Environment is ready for production.
The REPL (Read-Eval-Print Loop) is an interactive terminal session where you can query models, ingest documents on the fly, and inspect live token spend without writing Python scripts.
Launch the REPL with:
ai-rag repl| Command | Action |
|---|---|
/help |
Displays available commands. |
/provider <name> |
Switches active provider on the fly (gemini, openai, anthropic, ollama). |
/model <name> |
Switches active model (e.g., /model gpt-4o-mini). |
/ingest <path> |
Ingests a text or markdown file into the temporary vector store. |
/query <question> |
Executes a hybrid RAG query against ingested documents. |
/cost |
Displays accumulated tokens and dollar spend for the current session. |
/clear |
Clears terminal screen and conversation buffer. |
/exit or /quit
|
Exits the interactive session. |
ai-rag repl (v0.19.10) - Type /help for options or /exit to quit.
Active Provider: gemini (gemini-2.5-flash)
> /ingest ./docs/architecture_manual.md
Ingesting 'architecture_manual.md'... (12 chunks indexed in SQLiteVectorStore)
> /query What is the HTTP client timeout policy?
Searching hybrid index (BM25 + Dense)...
[RAG Answer]:
According to the architecture manual (section 3.2), the timeout policy enforces
a strict 30.0-second limit for full completions and 10.0 seconds for embeddings,
after which the client fails over to the next candidate in the pool.
> /cost
Current Session:
- Prompt tokens: 452
- Completion tokens: 78
- Estimated spend: $0.000057 USD
Generate a standardized, production-ready microservice project structure:
ai-rag init my-ai-servicemy-ai-service/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app pre-configured with /query, /metrics, /healthz
│ ├── config.py # Typed Settings schema
│ └── services/
│ └── rag.py # RAGEngine service with SQLiteVectorStore
├── tests/
│ ├── conftest.py
│ └── test_rag.py # Asynchronous unit tests with pytest
├── .env.example # Environment variable template
├── .gitignore # Security-hardened exclusions
├── Dockerfile # Ultra-lightweight container (< 100MB)
├── pyproject.toml # Clean package dependencies
└── README.md # Service bootstrap instructions
Run the new microservice immediately:
cd my-ai-service
pip install -e .
uvicorn app.main:app --reloadExpose your local knowledge base to tools like Claude Desktop or Cursor via the CLI:
rag-mcp --db-path ./knowledge.db --transport stdioEnglish Documentation | Documentación en Español
- Overview
- 01. Architecture & Concepts
- 02. Getting Started
- 03. Implementation & Components
- 04. Patterns & Recipes
- 05. Staff Guide & Production
- General
- 01. Arquitectura y Conceptos
- 02. Primeros Pasos
- 03. Implementación y Componentes
- 04. Patrones y Recetas
- 05. Guía Staff y Producción