Agent skill
rag-chatbot
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.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/rag-chatbot
SKILL.md
RAG Chatbot Skill
Instructions
-
Setup
- Create Python virtual environment
- Install dependencies:
bash
pip install fastapi uvicorn pydantic openai qdrant-client asyncpg langchain-text-splitters tenacity python-dotenv - Create
.env.examplewith:OPENAI_API_KEY,QDRANT_URL,QDRANT_API_KEY,NEON_DATABASE_URL,EMBED_MODEL,CHAT_MODEL
-
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_chunkswith payload:doc_path,module,week,tags,heading_path
- Neon tables:
-
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
-
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
-
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
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?