TechSetupGuides
Advancedragllmaipythonelasticsearchminioredismysqlagentsdocument-processingvector-database

RAGFlow - Open-source RAG engine with Agent capabilities

Deploy RAGFlow, a leading open-source Retrieval-Augmented Generation (RAG) engine that fuses cutting-edge RAG with Agent capabilities to create a superior context layer for LLMs.

  1. Step 1

    Overview

    RAGFlow is a leading open-source Retrieval-Augmented Generation (RAG) engine that combines advanced RAG capabilities with Agent functionalities. It offers deep document understanding, template-based chunking, grounded citations, and agentic workflows for building production-ready AI systems.

    Key capabilities:

    • Deep document understanding from complex formats (PDF, DOCX, PPT, Excel, images, scanned copies)
    • Template-based intelligent chunking with human-in-the-loop refinement
    • Grounded citations with visual chunk inspection to reduce hallucinations
    • Agentic workflows with MCP (Model Context Protocol) support
    • Multi-modal document processing with image understanding
    • Orchestrable ingestion pipelines with data synchronization from Confluence, S3, Notion, Discord, Google Drive
    • Python/JavaScript code executor sandbox for agent capabilities
    • Cross-language query support
    • Memory system for AI agents
    • Production-ready deployment with horizontal scaling
  2. Step 2

    Tech Stack Reference

    RAGFlow is built on a modern Python-based architecture with modular components for RAG orchestration, document processing, and agent capabilities.

    Backend:

    • Python 3.13+ (Quart async web framework)
    • LangChain (RAG orchestration)
    • Deep document understanding pipeline (custom DeepDoc module)
    • Document parsers: pdfplumber, pypdf, python-docx, python-pptx, mammoth, Tika
    • Advanced parsers: MinerU, Docling (for complex document layouts)
    • NLP: spacy, sentence-transformers
    • OCR & Vision: opencv-python, onnxruntime-gpu
    • LLM integrations: OpenAI, Anthropic, Google Gemini, Ollama, Mistral, DeepSeek, Groq, Cohere, Replicate
    • Agent frameworks: browser-use, Crawl4AI, agentrun-sdk, MCP (Model Context Protocol)
    • Code execution: sandbox-executor-manager (gVisor-isolated)

    Data Layer:

    • Vector stores: Elasticsearch (default), Infinity, OpenSearch
    • Database: MySQL 8.0+ or OceanBase/SeekDB
    • Object storage: MinIO (S3-compatible)
    • Cache/Sessions: Redis (Valkey 8)
    • Full-text search: Elasticsearch/OpenSearch with vector similarity

    Infrastructure:

    • Docker/Docker Compose (containerized deployment)
    • NGINX (reverse proxy, TLS termination)
    • Kubernetes (Helm charts available for scale-out)
    • gVisor (sandbox isolation for code execution)
    • OpenTelemetry (observability)

    Frontend:

    • React-based web UI (served via NGINX)
    • Admin dashboard for user management and system configuration
  3. Step 3

    Prerequisites

    Before installing RAGFlow, ensure your system meets the following requirements:

    Hardware:

    • CPU: >= 4 cores (8+ recommended for production)
    • RAM: >= 16 GB (32+ GB recommended with GPU acceleration)
    • Disk: >= 50 GB free space (100+ GB for production datasets)
    • GPU: Optional but recommended (NVIDIA with CUDA support for faster embedding and document processing)

    Software:

    • Docker >= 24.0.0
    • Docker Compose >= v2.26.1
    • Python >= 3.13 (for source installation)
    • gVisor (required only for code executor/sandbox features)

    System Configuration:

    • Increase vm.max_map_count to at least 262144 (required for Elasticsearch)
    ⚠ Heads up: The vm.max_map_count setting is critical for Elasticsearch. Without it, the vector database will fail to start.
  4. Step 4

    System Configuration

    Configure kernel parameters required for Elasticsearch vector storage.

    # Check current vm.max_map_count value
    sysctl vm.max_map_count
    
    # Set to required minimum (262144)
    sudo sysctl -w vm.max_map_count=262144
    
    # Make the change permanent (survives reboot)
    echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf
    
    # Verify the change
    sysctl vm.max_map_count
  5. Step 5

    Quick Start with Docker (CPU-only)

    The fastest way to get RAGFlow running is with Docker Compose using pre-built images. This setup uses CPU for document processing and is suitable for development and small-scale production.

    # Clone the repository
    git clone https://github.com/infiniflow/ragflow.git
    cd ragflow/
    
    # Optional: checkout a stable release tag
    # git checkout v0.25.6
    # This ensures the entrypoint.sh matches the Docker image version
    
    # Navigate to docker directory
    cd docker/
    
    # Start all services (CPU mode)
    docker compose -f docker-compose.yml up -d
    
    # Monitor startup logs (wait for "Running on all addresses (0.0.0.0)")
    docker logs -f docker-ragflow-cpu-1
    
    # Expected output when ready:
    #      ____   ___    ______ ______ __
    #     / __ \ /   |  / ____// ____// /____  _      __
    #    / /_/ // /| | / / __ / /_   / // __ \| | /| / /
    #   / _, _// ___ |/ /_/ // __/  / // /_/ /| |/ |/ /
    #  /_/ |_|/_/  |_|\____//_/    /_/ \____/ |__/|__/
    #
    # * Running on all addresses (0.0.0.0)
    ⚠ Heads up: Do not log in before seeing the startup confirmation message. Logging in too early may cause "network abnormal" errors.
  6. Step 6

    Quick Start with GPU Acceleration

    For production workloads with large document sets, enable GPU acceleration for embedding models, OCR, and document processing. This requires NVIDIA Container Toolkit.

    # Install NVIDIA Container Toolkit (Ubuntu/Debian)
    sudo apt-get update
    sudo apt-get install -y nvidia-container-toolkit
    sudo systemctl restart docker
    
    # Verify GPU is accessible
    nvidia-smi
    docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
    
    # Navigate to docker directory
    cd ragflow/docker/
    
    # Enable GPU mode by uncommenting DEVICE=gpu in .env
    sed -i '1i DEVICE=gpu' .env
    
    # Start with GPU support
    docker compose -f docker-compose.yml up -d
    
    # Verify GPU is being used
    docker logs docker-ragflow-gpu-1 | grep -i cuda
  7. Step 7

    Access the Web Interface

    Once the containers are running, access RAGFlow through your web browser. The default configuration serves on port 80.

    # With default settings (port 80):
    # Open browser to: http://localhost
    # Or from another machine: http://<SERVER_IP>
    
    # To check which port is configured:
    grep SVR_WEB_HTTP_PORT docker/.env
    
    # Default .env values:
    # SVR_WEB_HTTP_PORT=80     # HTTP
    # SVR_WEB_HTTPS_PORT=443   # HTTPS (if configured)
    # SVR_HTTP_PORT=9380       # API endpoint
    # SVR_MCP_PORT=9382        # MCP server
    
    # First-time login creates an admin account
  8. Step 8

    Configure LLM Provider

    RAGFlow requires an LLM provider for question answering and agentic workflows. Configure your preferred provider in the service configuration template.

    Supported providers: OpenAI, Anthropic, Google Gemini, Ollama, Mistral, DeepSeek, Groq, Cohere, Replicate, Zhipu, Qianfan, Volcengine, Dashscope.

    # Edit docker/service_conf.yaml.template
    # Set the default LLM and add your API key
    
    # Example for OpenAI:
    user_default_llm:
      factory: "OpenAI"
      api_key: "sk-your-openai-api-key-here"
      base_url: "https://api.openai.com/v1"  # optional
    
    # Example for Anthropic Claude:
    user_default_llm:
      factory: "Anthropic"
      api_key: "sk-ant-your-anthropic-api-key"
    
    # Example for local Ollama:
    user_default_llm:
      factory: "Ollama"
      base_url: "http://host.docker.internal:11434"
    
    # After editing, restart the container:
    # docker compose -f docker-compose.yml restart ragflow-cpu
    ⚠ Heads up: API keys in service_conf.yaml.template are mounted into the container. Treat this file as sensitive and never commit it with real keys.
  9. Step 9

    Switch Vector Database to Infinity

    By default, RAGFlow uses Elasticsearch for vector storage. For high-performance workloads, switch to Infinity, a purpose-built vector database.

    Why Infinity:

    • Optimized for hybrid full-text + vector search
    • Lower memory footprint than Elasticsearch
    • Faster indexing for large document sets
    • Native support for RAGFlow's chunking strategy
    # Stop all running containers (WARNING: -v deletes volumes)
    cd ragflow/docker/
    docker compose -f docker-compose.yml down -v
    
    # Edit .env to enable Infinity
    sed -i 's/DOC_ENGINE=.*/DOC_ENGINE=infinity/' .env
    
    # Verify the change
    grep DOC_ENGINE .env
    # Expected: DOC_ENGINE=infinity
    
    # Start with Infinity backend
    docker compose -f docker-compose.yml up -d
    
    # Check Infinity health
    docker logs docker-infinity-1
    ⚠ Heads up: Using docker-compose down -v will delete all indexed documents and knowledge bases. Only use this when switching storage backends on a fresh install.
  10. Step 10

    Production Configuration

    For production deployments, customize environment variables in docker/.env and mount persistent volumes.

    Key configurations:

    • SVR_WEB_HTTP_PORT: HTTP serving port (default: 80)
    • SVR_HTTP_PORT: API endpoint port (default: 9380)
    • MYSQL_PASSWORD: Root password for MySQL (change from default)
    • MINIO_USER / MINIO_PASSWORD: S3-compatible object storage credentials
    • REDIS_PASSWORD: Redis password for session management
    • ELASTIC_PASSWORD: Elasticsearch password (if using ES backend)
    • MEM_LIMIT: Memory limit for Elasticsearch/Infinity (e.g., 8g)
    • STACK_VERSION: Elasticsearch version (default: 8.x)

    Security best practices:

    • Change all default passwords in .env
    • Use HTTPS with a reverse proxy (NGINX/Traefik)
    • Enable authentication for MySQL, MinIO, Redis, Elasticsearch
    • Restrict Docker network access with firewall rules
    • Mount /ragflow/logs for centralized logging
    # Generate strong passwords
    openssl rand -base64 32  # Use output for MYSQL_PASSWORD
    openssl rand -base64 32  # Use output for MINIO_PASSWORD
    openssl rand -base64 32  # Use output for REDIS_PASSWORD
    
    # Edit docker/.env with your production values
    vi docker/.env
    
    # Example production .env snippet:
    # SVR_WEB_HTTP_PORT=80
    # MYSQL_PASSWORD=<strong-password-here>
    # MINIO_PASSWORD=<strong-password-here>
    # REDIS_PASSWORD=<strong-password-here>
    # MEM_LIMIT=16g
    
    # Start with production config
    docker compose -f docker-compose.yml up -d
  11. Step 11

    Enable Code Executor (Sandbox)

    RAGFlow agents can execute Python and JavaScript code in isolated sandboxes using gVisor. This enables advanced agentic capabilities like data transformation, API calls, and computational tasks.

    Prerequisites:

    • gVisor installed on the host
    • Docker with seccomp support
    • At least 4 GB extra RAM for sandbox pool
    # Install gVisor (Ubuntu/Debian)
    sudo apt-get update
    sudo apt-get install -y apt-transport-https ca-certificates curl gnupg
    curl -fsSL https://gvisor.dev/archive.key | sudo gpg --dearmor -o /usr/share/keyrings/gvisor-archive-keyring.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/gvisor-archive-keyring.gpg] https://storage.googleapis.com/gvisor/releases release main" | sudo tee /etc/apt/sources.list.d/gvisor.list > /dev/null
    sudo apt-get update
    sudo apt-get install -y runsc
    
    # Configure Docker to use gVisor (optional)
    sudo runsc install
    sudo systemctl restart docker
    
    # Enable sandbox in docker-compose.yml by uncommenting the sandbox profile
    cd ragflow/docker/
    vi docker-compose-base.yml
    # Ensure 'sandbox-executor-manager' service is enabled
    
    # Start with sandbox enabled
    docker compose --profile sandbox -f docker-compose.yml up -d
    
    # Verify sandbox manager is running
    docker logs docker-sandbox-executor-manager-1
  12. Step 12

    Enable MCP Server for Agent Integration

    RAGFlow can run as an MCP (Model Context Protocol) server, allowing external agents (like Claude Desktop, OpenClaw) to query your knowledge bases via a standardized protocol.

    MCP transports:

    • SSE (Server-Sent Events) - legacy endpoints
    • Streamable HTTP - modern bidirectional streaming

    Use cases:

    • Expose RAGFlow datasets to Claude Desktop
    • Integrate with OpenClaw agentic workflows
    • Build custom agent tools using RAGFlow as a context engine
    # Edit docker/docker-compose.yml to enable MCP server
    # Uncomment the MCP command section:
    
    services:
      ragflow-cpu:
        command:
          - --enable-mcpserver
          - --mcp-host=0.0.0.0
          - --mcp-port=9382
          - --mcp-base-url=http://127.0.0.1:9380
          - --mcp-script-path=/ragflow/mcp/server/server.py
          - --mcp-mode=self-host
          - --mcp-host-api-key=ragflow-<your-secret-key-here>
          # Disable SSE transport (keep only Streamable HTTP):
          # - --no-transport-sse-enabled
    
    # Restart to apply:
    # docker compose -f docker-compose.yml up -d
    
    # MCP endpoint is now available at:
    # http://<server-ip>:9382/mcp
  13. Step 13

    Data Synchronization and Connectors

    RAGFlow supports automated data ingestion from external sources via orchestrable pipelines.

    Supported connectors:

    • Confluence (wiki pages)
    • S3-compatible storage (AWS S3, MinIO, Google Cloud Storage, Azure Blob)
    • Notion (databases and pages)
    • Discord (messages and threads)
    • Google Drive (documents and sheets)
    • SharePoint/OneDrive (Office365)
    • Slack (messages)
    • GitHub (repositories, issues, PRs)
    • Jira (issues and comments)
    • Asana, GitLab, DingTalk, Airtable

    How it works:

    1. Configure connector credentials in the UI (Settings → Data Sources)
    2. Create a knowledge base and select a connector
    3. Set sync schedule (manual, hourly, daily, weekly)
    4. RAGFlow automatically pulls new/updated documents and indexes them
    # Example: Sync from S3 bucket
    # 1. Add S3 credentials in RAGFlow UI:
    #    - Settings → Data Sources → Add S3
    #    - Enter: Bucket name, Access Key ID, Secret Access Key, Region
    #
    # 2. Create knowledge base:
    #    - Knowledge Bases → New → Select S3 connector
    #    - Configure file filters (e.g., *.pdf, *.docx)
    #    - Set sync interval: daily at 2 AM UTC
    #
    # 3. RAGFlow will:
    #    - Download files matching filters
    #    - Process documents with DeepDoc pipeline
    #    - Chunk, embed, and index into vector database
    #    - Track sync state (last sync time, new files, errors)
    
    # Monitor sync logs:
    docker logs -f docker-ragflow-cpu-1 | grep -i "sync"
  14. Step 14

    Document Processing Pipeline

    RAGFlow's core strength is deep document understanding. It supports multiple parsing strategies based on document complexity.

    Parsing methods:

    • Naive: Fast, layout-unaware text extraction (good for plain text, simple PDFs)
    • General: Balanced parsing with structure detection (tables, lists, sections)
    • Advanced: Deep layout analysis with MinerU or Docling (handles multi-column, complex tables, figures)
    • Vision: Multi-modal parsing using LLM vision models (GPT-4V, Gemini Vision) to describe images within documents

    Chunking strategies:

    • Template-based: Pre-defined strategies (Q&A pairs, sections, paragraphs, tables)
    • Token-based: Fixed token windows with overlap
    • Semantic: Coherent chunks based on topic boundaries
    • Manual: Human-in-the-loop chunk refinement with visual editor

    Embedding models:

    • Default: sentence-transformers/all-MiniLM-L6-v2
    • Recommended for multilingual: intfloat/multilingual-e5-large
    • High-performance: OpenAI text-embedding-3-large, Cohere embed-english-v3.0
    • Local GPU: infinity-emb with TEI (Text Embeddings Inference)
  15. Step 15

    Building a RAG Workflow

    Create a knowledge base, upload documents, and build a conversational agent with retrieval-augmented responses.

    # Step 1: Create a knowledge base via UI
    # - Navigate to Knowledge Bases → New
    # - Name: "Technical Documentation"
    # - Parsing method: Advanced (MinerU)
    # - Chunking: Template (Sections)
    # - Embedding model: all-MiniLM-L6-v2
    
    # Step 2: Upload documents
    # - Click "Upload" → Select PDFs, DOCX, web pages
    # - RAGFlow processes in background (check Status column)
    # - View chunks: Click document → Chunks tab → Visual chunk editor
    
    # Step 3: Create an agent
    # - Agents → New Agent
    # - Name: "Tech Support Assistant"
    # - System prompt: "You are a helpful technical support agent. Use retrieved context to answer questions accurately."
    # - Attach knowledge base: Select "Technical Documentation"
    # - Retrieval settings: Top-K = 5, Similarity threshold = 0.7
    # - Enable citations: Show source references
    
    # Step 4: Chat interface
    # - Open agent chat
    # - Ask: "How do I configure the vector database?"
    # - Response includes grounded citations with chunk references
    # - Click citation to see original document chunk
    
    # Step 5: API integration (optional)
    # curl -X POST http://localhost:9380/api/v1/chat \
    #   -H "Authorization: Bearer <api-key>" \
    #   -H "Content-Type: application/json" \
    #   -d '{
    #     "agent_id": "<agent-uuid>",
    #     "messages": [{"role": "user", "content": "How do I configure the vector database?"}]
    #   }'
  16. Step 16

    Agentic Workflows

    RAGFlow supports agentic workflows where agents can use tools, call APIs, execute code, and perform multi-step reasoning.

    Agent capabilities:

    • Memory: Persistent context across conversations
    • Tool calling: Built-in tools (web search, calculator, weather, stock prices, Wikipedia)
    • Custom tools: Define Python/JavaScript functions as tools
    • Code execution: Run code in isolated sandboxes
    • Web browsing: Crawl and extract web content with Crawl4AI
    • Multi-agent orchestration: Agents calling other agents

    Example: Web search + summarization agent

    1. Create agent with system prompt: "You are a research assistant. Search the web and summarize findings."
    2. Enable tools: Web Search (DuckDuckGo or Tavily)
    3. Enable code executor for data processing
    4. User query: "Find the latest RAGFlow release notes and summarize key features"
    5. Agent workflow:
      • Calls web search tool → retrieves GitHub release page
      • Extracts content with Crawl4AI
      • Executes Python code to parse release notes
      • Returns structured summary with citations
  17. Step 17

    Horizontal Scaling for Production

    Scale RAGFlow to handle high concurrency and large document sets using Kubernetes and external services.

    Scaling strategy:

    • Stateless API servers: Deploy multiple ragflow-cpu replicas behind a load balancer
    • Redis session store: Share sessions across replicas
    • External MySQL/PostgreSQL: Replace Docker MySQL with managed RDS/CloudSQL
    • External Elasticsearch: Use AWS OpenSearch, Elastic Cloud, or self-hosted cluster
    • S3 object storage: Replace MinIO with AWS S3, GCS, or Azure Blob
    • Task queue: Offload document processing to dedicated worker nodes
    # Example Kubernetes deployment (Helm chart available)
    # Install with Helm:
    helm repo add ragflow https://infiniflow.github.io/ragflow-helm
    helm install ragflow ragflow/ragflow \
      --set mysql.external.enabled=true \
      --set mysql.external.host=mysql.prod.example.com \
      --set mysql.external.password=<password> \
      --set elasticsearch.external.enabled=true \
      --set elasticsearch.external.host=https://es.prod.example.com:9200 \
      --set minio.external.enabled=true \
      --set minio.external.endpoint=s3.amazonaws.com \
      --set minio.external.bucket=ragflow-prod \
      --set replicas=5
    
    # Autoscaling with HPA:
    kubectl autoscale deployment ragflow \
      --cpu-percent=70 \
      --min=3 \
      --max=20
  18. Step 18

    Observability and Monitoring

    RAGFlow includes OpenTelemetry support for distributed tracing, metrics, and logs. Integrate with Prometheus, Grafana, and Jaeger for production observability.

    # Enable OpenTelemetry in service_conf.yaml.template
    opentelemetry:
      enabled: true
      exporter: otlp
      endpoint: http://otel-collector:4317
      service_name: ragflow
    
    # Prometheus metrics endpoint (after enabling):
    # http://localhost:9380/metrics
    
    # Key metrics to monitor:
    # - ragflow_documents_processed_total (counter)
    # - ragflow_chunk_count (gauge)
    # - ragflow_query_latency_seconds (histogram)
    # - ragflow_embedding_batch_size (histogram)
    # - ragflow_llm_token_usage_total (counter)
    # - ragflow_vector_search_latency_seconds (histogram)
    
    # Sample Prometheus scrape config:
    # scrape_configs:
    #   - job_name: 'ragflow'
    #     static_configs:
    #       - targets: ['ragflow:9380']
  19. Step 19

    Development Setup (Source Install)

    For contributors and advanced users who want to modify RAGFlow's source code, run from source instead of Docker.

    # Install uv and pre-commit
    pipx install uv pre-commit
    
    # Clone repository
    git clone https://github.com/infiniflow/ragflow.git
    cd ragflow/
    
    # Create Python virtual environment and install dependencies
    uv sync --python 3.13
    uv run python3 download_deps.py  # Downloads models and resources
    pre-commit install
    
    # Start infrastructure services only (MySQL, Redis, MinIO, Elasticsearch)
    docker compose -f docker/docker-compose-base.yml up -d
    
    # Add hosts to /etc/hosts
    echo "127.0.0.1 es01 infinity mysql minio redis sandbox-executor-manager" | sudo tee -a /etc/hosts
    
    # Set HuggingFace mirror (if needed)
    export HF_ENDPOINT=https://hf-mirror.com
    
    # Install jemalloc (memory allocator)
    sudo apt-get install -y libjemalloc-dev  # Ubuntu/Debian
    
    # Activate virtual environment and start backend
    source .venv/bin/activate
    export PYTHONPATH=$(pwd)
    bash docker/launch_backend_service.sh &
    
    # In another terminal, start frontend
    cd web/
    npm install
    npm run dev
    
    # Access at http://localhost:5173 (Vite dev server)
    
    # Stop services when done
    pkill -f "ragflow_server.py|task_executor.py"
    docker compose -f docker/docker-compose-base.yml down
  20. Step 20

    Troubleshooting

    Elasticsearch fails to start:

    • Check vm.max_map_count: sysctl vm.max_map_count should be >= 262144
    • Check disk space: Elasticsearch needs at least 5 GB free
    • Increase memory limit in .env: MEM_LIMIT=8g

    Documents fail to process:

    • Check parser logs: docker logs docker-ragflow-cpu-1 | grep -i "parse"
    • For scanned PDFs, ensure OCR is enabled and onnxruntime-gpu is available
    • Try switching parsing method: Naive → General → Advanced

    Slow embedding/chunking:

    • Enable GPU: Switch to ragflow-gpu profile and verify nvidia-smi
    • Use local embedding server (TEI): Uncomment tei-gpu in docker-compose-base.yml
    • Reduce chunk size or batch size in knowledge base settings

    High memory usage:

    • Limit Elasticsearch heap: Set MEM_LIMIT=4g in .env
    • Reduce concurrent document processing: Lower task_executor workers
    • Use Infinity instead of Elasticsearch for lower memory footprint

    MCP server not accessible:

    • Verify port mapping in docker-compose.yml: SVR_MCP_PORT:9382
    • Check firewall rules: sudo ufw allow 9382/tcp
    • Test endpoint: curl http://localhost:9382/healthz
    # Check container health
    docker ps --filter name=ragflow
    
    # View logs for specific service
    docker logs docker-ragflow-cpu-1 --tail 100 -f
    docker logs docker-es01-1 --tail 100 -f
    docker logs docker-mysql-1 --tail 100 -f
    
    # Restart specific service
    docker compose -f docker/docker-compose.yml restart ragflow-cpu
    
    # Check resource usage
    docker stats
    
    # Verify connectivity between services
    docker exec -it docker-ragflow-cpu-1 ping es01
    docker exec -it docker-ragflow-cpu-1 nc -zv mysql 3306
    
    # Reset entire stack (WARNING: deletes all data)
    cd docker/
    docker compose -f docker-compose.yml down -v
    docker compose -f docker-compose.yml up -d
  21. Step 21

    API Integration

    RAGFlow exposes a RESTful API for programmatic access to knowledge bases, agents, and chat.

    Authentication:

    • Obtain API key: Settings → API Keys → Generate
    • Pass in header: Authorization: Bearer <api-key>

    Common endpoints:

    • POST /api/v1/dataset - Create knowledge base
    • POST /api/v1/dataset/{id}/document - Upload document
    • GET /api/v1/dataset/{id}/chunks - List chunks
    • POST /api/v1/agent - Create agent
    • POST /api/v1/chat - Send chat message
    • GET /api/v1/chat/{conversation_id}/messages - Retrieve history

    Example: Programmatic document upload and query

    import requests
    
    API_BASE = "http://localhost:9380/api/v1"
    API_KEY = "your-api-key-here"
    headers = {"Authorization": f"Bearer {API_KEY}"}
    
    # Create knowledge base
    resp = requests.post(f"{API_BASE}/dataset", json={
        "name": "Product Docs",
        "chunk_method": "general",
        "embedding_model": "all-MiniLM-L6-v2"
    }, headers=headers)
    dataset_id = resp.json()["id"]
    
    # Upload document
    with open("manual.pdf", "rb") as f:
        files = {"file": f}
        resp = requests.post(
            f"{API_BASE}/dataset/{dataset_id}/document",
            files=files,
            headers=headers
        )
    doc_id = resp.json()["id"]
    
    # Wait for processing (poll status)
    import time
    while True:
        resp = requests.get(f"{API_BASE}/document/{doc_id}", headers=headers)
        status = resp.json()["status"]
        if status == "completed":
            break
        time.sleep(5)
    
    # Query the knowledge base
    resp = requests.post(f"{API_BASE}/retrieval", json={
        "dataset_id": dataset_id,
        "query": "How do I reset my password?",
        "top_k": 5
    }, headers=headers)
    chunks = resp.json()["chunks"]
    for chunk in chunks:
        print(f"Score: {chunk['score']:.3f} | {chunk['text'][:100]}...")
  22. Step 22

    RAGFlow Skill for OpenClaw

    Integrate RAGFlow with OpenClaw (agentic workflow orchestrator) using the official RAGFlow skill. This allows OpenClaw agents to query your RAGFlow knowledge bases as a tool.

    How it works:

    1. Deploy RAGFlow with MCP server enabled (see earlier step)
    2. Install the RAGFlow skill in OpenClaw from ClawHub
    3. Configure the skill with your RAGFlow endpoint and API key
    4. OpenClaw agents can now call ragflow_search(query, dataset_id) to retrieve grounded context

    Use case: Multi-agent system where one agent specializes in document retrieval (RAGFlow) and others handle reasoning, code generation, or user interaction.

    # Install RAGFlow skill in OpenClaw
    # Visit: https://clawhub.ai/yingfeng/ragflow-skill
    
    # Or add to OpenClaw config.yaml:
    skills:
      - name: ragflow
        source: clawhub://yingfeng/ragflow-skill
        config:
          endpoint: http://localhost:9380
          api_key: your-ragflow-api-key
          default_dataset_id: <your-dataset-uuid>
    
    # Example OpenClaw agent using RAGFlow:
    # agent:
    #   name: customer_support
    #   skills:
    #     - ragflow
    #   prompt: |
    #     You are a customer support agent.
    #     Use the ragflow_search tool to find relevant information from our knowledge base.
    #     Always cite your sources.

Feature requests

Sign in to suggest features or vote on existing ones.

No feature requests yet.

Discussion

0 people marked this as worked·Sign in to mark your own.

Sign in to join the discussion.

No comments yet.