rag-chatbot

maneeshanif's avatarfrom maneeshanif

Build the FastAPI-based RAG service using OpenAI Agents/ChatKit, Neon Postgres, and Qdrant for the textbook. Use when creating ingestion pipelines, query endpoints, or configuring vector storage for book content.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 7, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill provides a comprehensive blueprint for building a production-ready Retrieval-Augmented Generation (RAG) service. It automates the integration of FastAPI, Neon Postgres for metadata, and Qdrant for vector storage, enabling the creation of robust ingestion pipelines and semantic search endpoints. Designed for developers, it streamlines the process of transforming static content like textbooks into interactive, context-aware AI applications with grounded citations.

Use Cases

  • Educational Technology: Developing AI-powered textbook assistants that provide students with grounded answers and precise citations from course materials.
  • Enterprise Knowledge Management: Building scalable internal search engines that perform semantic queries across markdown-based documentation and technical manuals.
  • AI Backend Development: Rapidly prototyping and deploying high-performance RAG APIs with built-in support for incremental data ingestion and metadata tracking.
  • Hybrid Database Implementation: Configuring systems that require the combined power of relational data (Neon) and vector embeddings (Qdrant) for complex context management.
namerag-chatbot
descriptionBuild the FastAPI-based RAG service using OpenAI Agents/ChatKit, Neon Postgres, and Qdrant for the textbook. Use when creating ingestion pipelines, query endpoints, or configuring vector storage for book content.

RAG Chatbot Skill

Instructions

  1. Setup

    • Create Python virtual environment
    • Install dependencies:
      pip install fastapi uvicorn pydantic openai qdrant-client asyncpg langchain-text-splitters tenacity python-dotenv
      
    • Create .env.example with: OPENAI_API_KEY, QDRANT_URL, QDRANT_API_KEY, NEON_DATABASE_URL, EMBED_MODEL, CHAT_MODEL
  2. Data model

    • Neon tables:
      • documents(id, path, checksum, meta jsonb)
      • chunks(id, doc_id, content, meta jsonb)
      • sessions(id, user_id, prefs jsonb)
    • Qdrant collection book_chunks with payload: doc_path, module, week, tags, heading_path
  3. Ingestion

    • Walk markdown glob, parse frontmatter
    • Split chunks (by headings and tokens)
    • Embed via OpenAI, upsert to Qdrant
    • Store doc/chunk metadata in Neon
    • Track checksum for incremental ingest
  4. Query endpoints

    • /health - healthcheck
    • /ingest - trigger ingestion
    • /query - semantic search + LLM answer with sources
    • /query/selected - bypass vector search, inject user-selected text as context
  5. Ops

    • Configure CORS for Docusaurus origin
    • Add logging with request IDs
    • Include safety: max tokens, fallback answers, latency budget

Examples

# Query endpoint structure
@app.post("/query")
async def query(request: QueryRequest):
    # 1. Embed query
    # 2. Search Qdrant
    # 3. Build context from chunks
    # 4. Call OpenAI with context
    # 5. Return answer + sources
    pass
# Run server
uvicorn main:app --reload --port 8000

Definition of Done

  • FastAPI runs locally with env sample; healthcheck ok
  • Ingestion populates Qdrant + Neon with at least sample doc; idempotent reruns succeed
  • Query endpoints return grounded answers with cited headings
  • Selected-text mode echoes user selection
  • README snippet for running server and triggering ingest