Source: factory.core/ObjAiRag.py
RAG system for codebase knowledge and custom document sets.
Indexes source code, YAML configs, markdown docs into ChromaDB
collections. Supports AST-based chunking for Python files.
Queries use Ollama embeddings + retrieval + LLM generation.
| Method | Signature | Description |
|---|---|---|
| create_collection | create_collection(name: str, description: str = '') -> Any |
Create (or get) a ChromaDB collection. |
| delete_collection | delete_collection(name: str) -> None |
Delete a ChromaDB collection. |
| list_collections | list_collections() -> list[dict[str, Any]] |
List all collections with document counts. |
| get_collection_stats | get_collection_stats(name: str) -> dict[str, Any] |
Detailed stats for a collection. |
| index_file | index_file(filepath: str, collection: str = DEFAULT_COLLECTION) -> int |
Index a single file into a collection. Returns chunk count. |
| index_directory | index_directory(dirpath: str, collection: str = DEFAULT_COLLECTION, patterns: Optional[list[str]] = None, exclude: Optional[list[str]] = None) -> dict[str, int] |
Index a directory. Returns dict with file_count and chunk_count. |
| index_codebase | index_codebase(collection: str = DEFAULT_COLLECTION) -> dict[str, int] |
Index the full Axion codebase. |
| reindex_changed | reindex_changed(collection: str = DEFAULT_COLLECTION, since_hours: int = 1) -> dict[str, int] |
Re-index only files changed in the last N hours. |
| search | search(query: str, collection: str = DEFAULT_COLLECTION, top_k: int = 10) -> list[dict[str, Any]] |
Vector search only — return matching chunks without LLM generation. |
| query | query(question: str, collection: str = DEFAULT_COLLECTION, top_k: int = 5) -> dict[str, Any] |
RAG query: embed question -> retrieve chunks -> LLM answer. |
| ask | ask(question: str, collection: str = DEFAULT_COLLECTION) -> str |
Simplified query — returns answer string only. |
Index the full Axion codebase.
Ask a question about the codebase.
Search for code/docs without LLM generation.
Show collection statistics.
List all RAG collections.
Re-index files changed in the last N hours.