weave icon indicating copy to clipboard operation
weave copied to clipboard

docs(weave): MVP Weave RAG docs QA with chat in UI and server

Open J2-D2-3PO opened this issue 9 months ago • 1 comments

Description

Implements an MVP RAG-based QA system for the Weave documentation site. This MVP establishes a solid foundation to explore more advanced RAG techniques and to improve docs quality through live usage.

image
  • Adds weave_rag.py to load, embed, and retrieve chunks from real markdown docs. Means you can also ask questions in the cli
  • Adds lightweight source bias via llms.yaml to improve retrieval relevance
  • Caches document embeddings to weave_rag_index.pkl for faster iteration
  • Exposes FastAPI endpoint via weave_rag_server.py for local serving
  • Adds basic CORS support to allow local Docusaurus UI calls
  • New React component WeaveRAGChat.tsx for in-docs interactive QA
  • UI now includes source doc and top 5 retrieved chunks with similarity scores
  • Adds demo page at docs/weave-rag-demo.md for easy usage and fast testing

Test the chat app

  1. Check out this branch:
git checkout weave-rag
gh pr checkout 4006
  1. Set up a Python virtual environment and start it:
python3 -m venv weaverag-venv
source weaverag-venv/bin/activate
  1. Install dependencies:
pip install numpy weave openai pyyaml langchain fastapi uvicorn pydantic
  1. Set your OpenAI API key
export OPENAI_API_KEY=sk-...
  1. From \scripts, run the FastAPI server
cd scripts
uvicorn weave_rag_server:app --reload

This starts a local server at http://localhost:8000 that powers the RAG endpoint.

  1. Open a second terminal and start the Docusaurus site
cd ../  # back to root if needed
yarn install
yarn start
  1. Navigate to your local docs chat at http://localhost:3000/weave-rag-demo
  2. Type a real docs question. Wait a moment, and watch the RAG assistant answer — with traceable source + top-5 context chunks.

J2-D2-3PO avatar Mar 31 '25 00:03 J2-D2-3PO