Skip to main content

RAG-based document indexing and semantic search server for AI agents

Project description

Doc-Serve Server

RAG-based document indexing and semantic search REST API service.

Installation

pip install doc-serve

Quick Start

  1. Set environment variables:

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

    doc-serve
    

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

Features

  • Document Indexing: Load and index documents from folders (PDF, Markdown, TXT, DOCX, HTML)
  • Context-Aware Chunking: Smart text splitting with configurable chunk sizes and overlap
  • 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 doc_serve_server.api.main:app --reload

# Or use the entry point
poetry run doc-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

doc_serve_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 doc_serve_server/
poetry run ruff check doc_serve_server/

Type Checking

poetry run mypy doc_serve_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.1.0.tar.gz (39.1 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.1.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_brain_rag-1.1.0.tar.gz
  • Upload date:
  • Size: 39.1 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.1.0.tar.gz
Algorithm Hash digest
SHA256 2d5da430ddcc5ad0286c5ea48709abdbe577fc70659ce3979203c8caa6e33d50
MD5 5503fbac68c3a3268dd6a42e504baa92
BLAKE2b-256 2843b1912fb12f1682931e5dff1cb49f919ecd6b5cca55a8a02b3489f8ab6f83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agent_brain_rag-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3027e607c996103c9be250d391b93338e4fc3dd2d6589602a4b870351c7b5b94
MD5 52ba449ed0caa6ab5659feb5d396a2c2
BLAKE2b-256 a0e5937f3cca988decf7007051686c647339c57caeb0dd788e115f8576d8130f

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