Sign inSign up

godbehere/rag-server

By godbehere

•Updated about 1 year ago

A Retrieval-Augmented Generation (RAG) backend. Required rag-worker image

Image
Machine learning & AI
Data science
0

302

godbehere/rag-server repository overview

⁠RAG Project

A Retrieval-Augmented Generation (RAG) backend for document ingestion, semantic search, and LLM-powered question answering.

⁠Features

  • Ingest and chunk documents (PDF, DOCX, TXT, web pages)
  • Store and search embeddings using Qdrant
  • Queue-based processing with BullMQ and Redis
  • REST API for ingestion and retrieval

⁠1. Ingest Plain Text

Endpoint:
POST /api/ingest/text
Content-Type: application/json

Request Example:

curl -X POST http://localhost:3000/api/ingest/text \
  -H "Content-Type: application/json" \
  -d '{
    "text": "This is a test document for ingestion.",
    "title": "Test Doc",
    "sourceType": "txt"
  }'

Response Example:

{
  "status": "queued",
  "docId": "<generated-uuid>"
}

⁠2. Ingest Files and/or URLs

Endpoint:
POST /api/ingest/files
Content-Type: multipart/form-data

  • Field files: one or more files (PDF, DOCX, TXT)
  • Field urls: JSON array of URLs as a string (e.g., '["https://example.com⁠"]')

File Upload Example:

curl -X POST http://localhost:3000/api/ingest/files \
  -F "files=@/path/to/your/file.pdf"

URL Ingestion Example:

curl -X POST http://localhost:3000/api/ingest/files \
  -H "Content-Type: application/json"
  -d '{"urls":[
        "https://en.wikipedia.org/wiki/Space_exploration",
        "https://en.wikipedia.org/wiki/Apollo_program"
      ]}'

Response Example:

{
  "message": "Ingestion jobs queued",
  "count": 2,
  "errors": []
}

⁠3. Query for Retrieval

Endpoint:
POST /api/query
Content-Type: application/json

Request Example:

curl -X POST http://localhost:3000/api/query \
  -H "Content-Type: application/json" \
  -d '{
    "query": "Tell me about space exploration on the Moon and Mars",
    "topK": 15,
    "generate": true
  }'

Response Example (with generate=false):

{
  "results": [
    {
      "id": "chunk-uuid",
      "docId": "doc-uuid",
      "title": "Test Doc",
      "sourceType": "txt",
      "score": 0.92
    }
    // ...more results
  ]
}

Response Example (with generate=true):

{
  "answer": "OpenAI is an AI research and deployment company...",
  "citations": [
    {
      "id": "chunk-uuid",
      "docId": "doc-uuid",
      "title": "Test Doc",
      "sourceType": "txt",
      "score": 0.92
    }
    // ...more results
  ]
}

⁠4. Clear Vector Store (Admin)

Endpoint:
POST /api/vectorstore/clear
Content-Type: application/json

Request Example:

curl -X POST http://localhost:3000/api/vectorstore/clear

Response Example:

{
  "status": "ok",
  "message": "Vector store cleared."
}

Refer to this document for quick manual testing of the API endpoints. For more details, see the README or source code.

⁠Setup

⁠docker-compose.yml
version: '3.8'
services:
  app:
    image: godbehere/rag-server:latest
    container_name: rag-app
    ports:
      - "3000:3000"
    env_file: .env.docker
    environment:
      - NODE_ENV=development
      - PORT=3000
      - REDIS_URL=redis://redis:6379
      - QDRANT_URL=http://qdrant:6333
      # Add other env vars as needed
    depends_on:
      - redis
      - qdrant
    command: npm run dev

  worker:
    image: godbehere/rag-worker:latest
    container_name: rag-worker
    env_file: .env.docker
    environment:
      - NODE_ENV=development
      - REDIS_URL=redis://redis:6379
      - QDRANT_URL=http://qdrant:6333
    depends_on:
      - redis
      - qdrant
    command: npm run worker

  redis:
    image: redis:7-alpine
    container_name: rag-redis
    ports:
      - "6379:6379"

  qdrant:
    image: qdrant/qdrant:latest
    container_name: rag-qdrant
    ports:
      - "6333:6333"
      - "6334:6334"
    volumes:
      - qdrant_data:/qdrant/storage

volumes:
  qdrant_data:

Tag summary

Content type

Image

Digest

sha256:d7991edfc…

Size

114.9 MB

Last updated

about 1 year ago

docker pull godbehere/rag-server