Skip to content

About

RAG Chatbot over the Upwork API documentation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

Upwork API Support Bot

A retrieval-augmented technical-support bot that answers developer questions about the Upwork API. Grounded only in the official documentation (the provided PDF). Built for the ProAnalyst Associate AI Developer take-home.

Stack

Layer Choice
RAG framework LangChain
Vector store ChromaDB (persisted at ./chroma_db/)
Embeddings BAAI/bge-small-en-v1.5 (local, free)
PDF extraction pdfplumber with table-row serialization
LLM Meta-Llama-3.1-8B-Instruct-Turbo via DeepInfra (streaming)
UI Streamlit (chat layout, live reasoning trace, sidebar)

Project layout

.
├── app.py                       # Streamlit chat UI (run from project root)
├── src/
│   ├── config.py                # paths, model names, chunk params
│   ├── prompts.py               # SYSTEM_PROMPT with 4-case decision logic
│   ├── loaders/
│   │   ├── pdf.py               # pdfplumber loader, serializes tables
│   ├── ingest.py                # PDF → chunks → Chroma
│   ├── rag.py                   # load Chroma, retrieve top-k chunks
│   └── llm.py                   # DeepInfra client; answer() + stream_answer()
├── docs/                        # source PDFs (gitignored — keep local)
├── chroma_db/                   # generated by ingest.py, committed for deploy
├── requirements.txt
├── .env.example
└── SUMMARY.md                   # ½-1 page technical summary deliverable

Run

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

cp .env.example .env                # then paste your DeepInfra API key

python -m src.ingest                # one-time: builds ./chroma_db/
streamlit run app.py

Then open http://localhost:8501 and ask a question.

Deploy to Streamlit Community Cloud

This repo is already organized for Streamlit Community Cloud:

  • Repository: hemangsengar/RAG-Chatbot-on-Docs
  • Branch: main
  • App file: app.py
  • Dependencies: requirements.txt
  • Secret to add in Streamlit Advanced settings:
DEEPINFRA_API_KEY = "your_deepinfra_api_key_here"

The generated chroma_db/ index is committed so Streamlit can start without private source PDFs in the repo. Keep .env, .streamlit/secrets.toml, and the original source documents out of git.

Design notes

  • Chunking: 500-char chunks with 50-char overlap, as specified by the assignment. Overlap matters for technical content (curl examples, OAuth flow steps, parameter tables) that frequently span chunk boundaries.
  • Source boundary: the bot indexes only the provided PDF. Hyperlinked web pages are intentionally not indexed, so facts absent from the assignment document trigger the hallucination guard instead of pulling in outside pages.
  • Prompt cases: prompts.py enforces four mutually-exclusive response modes — greeting / small-talk, direct quote, reasoned inference, and the verbatim hallucination-guard fallback. The case label is never shown to the user.
  • Streaming: the answer renders token-by-token via the OpenAI SDK's stream=True; a live reasoning trace (st.status) shows which chunks were retrieved before generation starts.
  • @st.cache_resource: the embedding model + Chroma collection load once per session, not per query.

See SUMMARY.md for the full write-up.

About

RAG Chatbot over the Upwork API documentation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages