pgedge-rag-server

module
v1.0.0-alpha5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: PostgreSQL

README

pgEdge RAG Server

CI

A simple API server for performing Retrieval-Augmented Generation (RAG) of text based on content from a PostgreSQL database using pgvector.

Features

  • Multiple RAG pipelines with configurable embedding and LLM providers
  • Hybrid search combining vector similarity and BM25 text matching
  • Support for OpenAI, Anthropic, Voyage, and Ollama LLM providers
  • Token budget management to control LLM costs
  • Optional streaming responses via Server-Sent Events
  • TLS/HTTPS support

Quick Start

Prerequisites
  • Go 1.22 or later
  • PostgreSQL with pgvector extension
  • API keys for your chosen LLM providers
Installation
# Clone the repository
git clone https://github.com/pgEdge/pgedge-rag-server.git
cd pgedge-rag-server

# Build the binary
make build

# Run the server
./bin/pgedge-rag-server -config /path/to/config.yaml
Configuration

Create a configuration file (see docs/configuration.md for full reference):

server:
  listen_address: "0.0.0.0"
  port: 8080

pipelines:
  - name: "my-docs"
    description: "Search my documentation"
    database:
      host: "localhost"
      port: 5432
      database: "mydb"
    tables:
      - table: "documents"
        text_column: "content"
        vector_column: "embedding"
    embedding_llm:
      provider: "openai"
      model: "text-embedding-3-small"
    rag_llm:
      provider: "anthropic"
      model: "claude-sonnet-4-20250514"

API Usage

List Available Pipelines
curl http://localhost:8080/v1/pipelines
Query a Pipeline
curl -X POST http://localhost:8080/v1/pipelines/my-docs \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I configure replication?"}'
Query with Streaming
curl -X POST http://localhost:8080/v1/pipelines/my-docs \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I configure replication?", "stream": true}'

Development

# Run all checks (format, lint, test, build)
make all

# Run tests only
make test

# Run linter only
make lint

# Format code
make fmt

Documentation

Full documentation is available in the docs/ directory.

License

See LICENCE.md for license information.

Directories

Path Synopsis
cmd
internal
bm25
Package bm25 provides BM25 text search scoring.
Package bm25 provides BM25 text search scoring.
config
Package config handles configuration loading and validation for the pgEdge RAG Server.
Package config handles configuration loading and validation for the pgEdge RAG Server.
database
Package database provides PostgreSQL connectivity and vector search.
Package database provides PostgreSQL connectivity and vector search.
llm
Package llm provides interfaces and implementations for LLM providers.
Package llm provides interfaces and implementations for LLM providers.
llm/anthropic
Package anthropic provides an Anthropic API client.
Package anthropic provides an Anthropic API client.
llm/factory
Package factory provides functions to create LLM providers from configuration.
Package factory provides functions to create LLM providers from configuration.
llm/ollama
Package ollama provides an Ollama API client for local LLM inference.
Package ollama provides an Ollama API client for local LLM inference.
llm/openai
Package openai provides an OpenAI API client.
Package openai provides an OpenAI API client.
llm/voyage
Package voyage provides a Voyage AI embedding client.
Package voyage provides a Voyage AI embedding client.
pipeline
Package pipeline provides the RAG pipeline execution and management.
Package pipeline provides the RAG pipeline execution and management.
server
Package server provides the HTTP server for the RAG API.
Package server provides the HTTP server for the RAG API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL