Skip to main content

Agent Brain RAG - Intelligent document indexing and semantic search server that gives AI agents long-term memory

Project description

Agent Brain RAG Server

Intelligent document indexing and semantic search REST API service that gives AI agents long-term memory.

Installation

pip install agent-brain-rag

Quick Start

  1. Set environment variables:

    export OPENAI_API_KEY=your-key
    export ANTHROPIC_API_KEY=your-key
    
  2. Start the server:

    agent-brain-serve
    

The server will start at http://127.0.0.1:8000.

Note: The legacy command doc-serve is still available but deprecated. Please use agent-brain-serve for new installations.

Features

  • Document Indexing: Load and index documents from folders (PDF, Markdown, TXT, DOCX, HTML)
  • AST-Aware Code Ingestion: Smart parsing for Python, TypeScript, JavaScript, Java, Go, Rust, C, C++
  • Hybrid Search: Combines BM25 keyword matching with semantic similarity
  • Semantic Search: Query indexed documents using natural language
  • OpenAI Embeddings: Uses text-embedding-3-large for high-quality embeddings
  • Chroma Vector Store: Persistent, thread-safe vector database
  • FastAPI: Modern, high-performance REST API with OpenAPI documentation

Quick Start

Prerequisites

  • Python 3.10+
  • Poetry
  • OpenAI API key

Installation

cd doc-serve-server
poetry install

Configuration

Copy the environment template and configure:

cp ../.env.example .env
# Edit .env with your API keys

Required environment variables:

  • OPENAI_API_KEY: Your OpenAI API key for embeddings

Running the Server

# Development mode
poetry run uvicorn agent_brain_server.api.main:app --reload

# Or use the entry point
poetry run agent-brain-serve

The server will start at http://127.0.0.1:8000.

API Documentation

Once running, visit:

API Endpoints

Health

  • GET /health - Server health status
  • GET /health/status - Detailed indexing status

Indexing

  • POST /index - Start indexing documents from a folder
  • POST /index/add - Add documents to existing index
  • DELETE /index - Reset the index

Querying

  • POST /query - Semantic search query
  • GET /query/count - Get indexed document count

Example Usage

Index Documents

curl -X POST http://localhost:8000/index \
  -H "Content-Type: application/json" \
  -d '{"folder_path": "/path/to/docs"}'

Query Documents

curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I configure authentication?", "top_k": 5}'

Architecture

agent_brain_server/
├── api/
│   ├── main.py           # FastAPI application
│   └── routers/          # Endpoint handlers
├── config/
│   └── settings.py       # Configuration management
├── models/               # Pydantic request/response models
├── indexing/
│   ├── document_loader.py  # Document loading
│   ├── chunking.py         # Text chunking
│   └── embedding.py        # Embedding generation
├── services/
│   ├── indexing_service.py # Indexing orchestration
│   └── query_service.py    # Query execution
└── storage/
    └── vector_store.py     # Chroma vector store

Development

Running Tests

poetry run pytest

Code Formatting

poetry run black agent_brain_server/
poetry run ruff check agent_brain_server/

Type Checking

poetry run mypy agent_brain_server/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_brain_rag-1.2.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_brain_rag-1.2.0-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

Details for the file agent_brain_rag-1.2.0.tar.gz.

File metadata

  • Download URL: agent_brain_rag-1.2.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.3 Darwin/25.2.0

File hashes

Hashes for agent_brain_rag-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f580c8c15a1e5656bbcda55cfdf28e88801ffbca9001f59afc1a17c66c420651
MD5 06628fc610f32e4ae99483b1d7800bd6
BLAKE2b-256 9b57a22ce121e330cef47090afa03ddd6f1e856118268a555e8db84262731a5d

See more details on using hashes here.

File details

Details for the file agent_brain_rag-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: agent_brain_rag-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.3 Darwin/25.2.0

File hashes

Hashes for agent_brain_rag-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e87fe98fc4620a3dc823f1346a08360450a328163e9c42906c5d986b653bd8f5
MD5 bec278089ab9e3f4ec3cafd2f0045aa6
BLAKE2b-256 4bd8b1acb13e1e1cccd2f2b1c63db6c49d8d1f647f2fbffb49d8b61d47221a60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page