Metadata-Version: 2.3
Name: agent-brain-rag
Version: 1.2.0
Summary: Agent Brain RAG - Intelligent document indexing and semantic search server that gives AI agents long-term memory
License: MIT
Keywords: agent-brain,rag,semantic-search,ai-memory,llm-memory,documentation,indexing,llama-index,chromadb,ai-agent,claude-code,agent-memory
Author: Spillwave Solutions
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Text Processing :: Indexing
Requires-Dist: anthropic (>=0.40.0,<0.41.0)
Requires-Dist: chromadb (>=0.5.0,<0.6.0)
Requires-Dist: click (>=8.1.0,<9.0.0)
Requires-Dist: fastapi (>=0.115.0,<0.116.0)
Requires-Dist: llama-index-core (>=0.14.0,<0.15.0)
Requires-Dist: llama-index-embeddings-openai (>=0.5.0,<0.6.0)
Requires-Dist: llama-index-llms-openai (>=0.6.12,<0.7.0)
Requires-Dist: llama-index-readers-file (>=0.5.0,<0.6.0)
Requires-Dist: llama-index-retrievers-bm25 (>=0.6.0,<0.7.0)
Requires-Dist: openai (>=1.57.0,<2.0.0)
Requires-Dist: pydantic (>=2.10.0,<3.0.0)
Requires-Dist: pydantic-settings (>=2.6.0,<3.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: rank-bm25 (>=0.2.2,<0.3.0)
Requires-Dist: tiktoken (>=0.8.0,<0.9.0)
Requires-Dist: tree-sitter-language-pack (>=0.7.3,<0.8.0)
Requires-Dist: uvicorn[standard] (>=0.32.0,<0.33.0)
Project-URL: Documentation, https://github.com/SpillwaveSolutions/doc-serve#readme
Project-URL: Homepage, https://github.com/SpillwaveSolutions/doc-serve
Project-URL: Repository, https://github.com/SpillwaveSolutions/doc-serve
Description-Content-Type: text/markdown

# Agent Brain RAG Server

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

## Installation

```bash
pip install agent-brain-rag
```

## Quick Start

1. Set environment variables:
   ```bash
   export OPENAI_API_KEY=your-key
   export ANTHROPIC_API_KEY=your-key
   ```

2. Start the server:
   ```bash
   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

```bash
cd doc-serve-server
poetry install
```

### Configuration

Copy the environment template and configure:

```bash
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

```bash
# 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:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
- OpenAPI JSON: http://127.0.0.1:8000/openapi.json

## 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

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

### Query Documents

```bash
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

```bash
poetry run pytest
```

### Code Formatting

```bash
poetry run black agent_brain_server/
poetry run ruff check agent_brain_server/
```

### Type Checking

```bash
poetry run mypy agent_brain_server/
```

## License

MIT

