Harden LLM prompt to stop small models parroting passages
Claude+1: Claude Opus 4.8
Unverified signature
d7c63ed
Remove [Passage N] labels, delimit excerpts, and instruct a single
in-your-own-words paragraph with an explicit 'not covered' fallback.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Surface LLM provider/model/last-error on /health for diagnostics
Claude+1: Claude Opus 4.8
Unverified signature
ca80acf
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Bump to 0.2.0 and expose version + llm_enabled on /health
Claude+1: Claude Opus 4.8
Unverified signature
282bc7c
/health now reports the running version and whether an LLM key is
configured, so a deploy can be verified at a glance (GET /api/health).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Add LLM_PROVIDER preset (groq/gemini/openrouter) for the free LLM
Claude+1: Claude Opus 4.8
Unverified signature
4775f5f
Lets the answer provider be chosen with one variable instead of typing the
base URL and model. Gemini and OpenRouter offer Google/email sign-in for
users who can't sign up via GitHub. LLM_BASE_URL / LLM_MODEL still override
the preset. Docs updated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Switch LLM answers to a free OpenAI-compatible API (Groq default)
Claude+1: Claude Opus 4.8
Unverified signature
52fe15e
Replace the Anthropic client with an OpenAI-compatible one so answers can be
powered by a free provider. /ask uses LLM_API_KEY when set (defaults to Groq's
free API); LLM_BASE_URL and LLM_MODEL point it at any OpenAI-compatible
endpoint (Groq, Google Gemini's OpenAI endpoint, OpenRouter, ...). Still falls
back to the extractive answer with no key, so CI and keyless runs are
unaffected.
- requirements: anthropic -> openai.
- .env.example and README document LLM_API_KEY / LLM_BASE_URL / LLM_MODEL and
where to get a free key.
23 tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Add optional Claude-generated answers with extractive fallback
Claude+1: Claude Opus 4.8
Unverified signature
913d26e
/ask now synthesizes a grounded answer from the retrieved passages using the
Anthropic API when ANTHROPIC_API_KEY is set, and falls back to the extractive
best-sentence answer otherwise (no key, no cost, no network — CI unaffected).
- app/generate.py: lazy Anthropic client; grounded system prompt over the top
passages; never raises (missing key/package, network error, or refusal all
return None). Model defaults to claude-opus-5, overridable via ANTHROPIC_MODEL.
- /ask returns a 'generated' flag and measures latency around generation; the
chat UI shows an 'AI answer' badge while still displaying the source passage.
- requirements add anthropic; .env.example and README document the key.
- test_generate.py covers the keyless fallback path.
Full suite is 23 tests, green; frontend builds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Point live demo at the working Railway deployment
Claude+1: Claude Opus 4.8
Unverified signature
1874e21
Railway built the combined image (root Dockerfile), serving the frontend
and API from one origin. Verified end to end (upload -> ask -> feedback ->
stats). Update the README live link and check off the Session 5 acceptance
criteria.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Fail HF sync loudly on manual dispatch when HF_TOKEN is missing
Claude+1: Claude Opus 4.8
Unverified signature
6509d5c
A missing secret was silently skipping the push and reporting a green
'success', which hid the real problem. On workflow_dispatch, error out with
an explicit message; automatic pushes still skip quietly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Match HF sync default to the created Space name (Docuask)
Claude+1: Claude Opus 4.8
Unverified signature
c9c222c
The Space was created as Sri-28/Docuask (capital D); HF repo paths are
case-sensitive, so default HF_SPACE to Docuask and update the docs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Add Railway deploy config for the API
Claude+1: Claude Opus 4.8
Unverified signature
5ab35ee
backend/railway.json pins the Dockerfile builder so a Railway service with
root directory 'backend' builds backend/Dockerfile (libgomp1 + $PORT).
README backend section rewritten with Railway-specific steps.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Switch deploy to HF Static Space (frontend) + separate API
Claude+1: Claude Opus 4.8
Unverified signature
abf3c4b
Hugging Face only offers free Static Spaces (Docker requires a paid plan),
so the frontend now deploys to a Static Space and the API to any Python
host:
- README front matter -> sdk: static with app_build_command building
frontend/ and serving frontend/dist.
- Frontend resolves the API base at runtime from the HF Space variable
DOCUASK_API_URL (via window.huggingface.variables), then VITE_API_URL,
then /api — so the API URL changes without a rebuild.
- Backend CORS default now includes the Static Space origin; backend
Dockerfile honors and a Procfile is added for native-Python hosts.
- Deploy docs rewritten for the split; the single-image Docker option
(root Dockerfile + app/server.py) is kept as an alternative.
Sync workflow and tests unchanged in behavior; 21 backend tests pass and
the frontend builds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Default HF sync to Sri-28/docuask and fill in demo link
Claude+1: Claude Opus 4.8
Unverified signature
24361e0
Defaults HF_USERNAME to Sri-28 so only the HF_TOKEN secret is required to
enable auto-sync; sets the live-demo link to the target Space URL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Add GitHub Action to auto-sync main to Hugging Face Space
Claude+1: Claude Opus 4.8
Unverified signature
1520970
On every push to main (and manual dispatch), mirrors the branch to the HF
Space so the live demo tracks main. Parameterized via HF_TOKEN secret and
HF_USERNAME/HF_SPACE variables; no-ops when HF_TOKEN is unset so it never
fails the branch. README documents the one-time setup.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Polish, tests & single-image deploy (Session 5)
Claude+1: Claude Opus 4.8
Unverified signature
821ccae
Deploy (Hugging Face Spaces, Docker SDK):
- Root Dockerfile builds a single image: stage 1 builds the React frontend,
stage 2 runs FastAPI serving the built assets plus the API under /api on
port 7860 (same origin, no CORS, one live URL).
- app/server.py: combined ASGI entrypoint mounting the API at /api and the
static frontend at / (guarded so tests import cleanly without a build).
- README front matter (sdk: docker, app_port: 7860) so a Space builds it
directly; .dockerignore for build-context hygiene.
- backend/.env.example and frontend/.env.example document CORS_ORIGINS,
DOCUASK_DB, and VITE_API_URL for split-hosting setups.
Polish:
- README rewritten for a recruiter: description, chat + dashboard
screenshots, feature list, API table, deploy steps, project structure.
- test_server.py verifies the API is reachable under /api in the combined
app.
Verified the combined server locally: /api/health, static index, and
/api/ask all serve correctly from one origin.
Co-Auth…
Add data-collection & feedback layer (Session 4)
Claude+1: Claude Opus 4.8
Unverified signature
44215ae
Backend:
- SQLite telemetry store (db.py): interactions table logging every /ask
with its measured latency_ms. Single shared connection guarded by a lock
(FastAPI threadpool-safe); DB path from DOCUASK_DB.
- /ask now logs each turn and returns interaction_id + latency_ms.
- POST /feedback attaches a 'up'/'down' rating to an interaction
(422 on invalid value, 404 on unknown id).
- GET /stats returns total questions, median latency, thumbs-up rate,
up/down counts, and questions-over-time buckets.
- docker-compose mounts a volume for the DB so telemetry survives restarts.
Frontend:
- 👍/👎 feedback buttons under each answer, posting to /feedback with an
optimistic update.
- Dashboard page (hash route /#/dashboard) with three KPI tiles and a
questions-over-time bar chart (per-bar hover tooltip), plus a header nav
to switch between Chat and Dashboard.
Tests:
- conftest.py points the DB at in-memory SQLite per test for isolation.
- test_stats.py covers latency persistence, fe…
Add retrieval + chat loop (Session 3)
Claude+1: Claude Opus 4.8
Unverified signature
d9f07b6
Backend:
- POST /ask takes {document_id, question}, runs hybrid retrieval over the
document's chunks, and returns an extractive answer plus the source
passage it came from (with chunk index and score).
- retrieval.py: a per-document index combining BM25 (rank_bm25) with a
FAISS cosine search over TF-IDF vectors; scores are min-max normalised
and averaged. The index is built lazily on first /ask and cached.
- Empty question -> 400, unknown document id -> 404.
- Dockerfile installs libgomp1 (faiss-cpu OpenMP runtime dep).
Frontend:
- Chat interface: question input, message history, a typing indicator
while /ask is in flight, and each answer shows a collapsible source
passage underneath. App swaps the uploader for the chat once a document
is ready, with a 'New document' reset.
Tests:
- test_ask.py covers index ranking, sentence extraction, the /ask happy
path, empty-question, and unknown-document paths.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Sess…
Add upload & parse flow (Session 2)
Claude+1: Claude Opus 4.8
Unverified signature
52739ad
Backend:
- POST /documents accepts a PDF (pypdf) or raw text, extracts and chunks
the text, and stores it in an in-memory store keyed by document id.
- GET /documents/{id} returns document metadata.
- Visible, logged failure handling: non-PDF (415), broken/encrypted PDF
(400, friendly message), empty input (400), oversize input (413).
- pytest suite covers the happy path plus every parse-failure path.
Frontend:
- Drag-and-drop PDF uploader (also click-to-browse and a paste-text mode)
with idle/uploading/ready/error states and inline error messages.
- Client-side guards for non-PDF and oversize files before upload.
Also adds a .gitignore (Python + Node) so build artifacts stay untracked.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Add CI workflow: pytest backend + frontend build
Claude+1: Claude Opus 4.8
Unverified signature
74266cd
Runs on every push and pull request. Backend job installs deps and runs
pytest; frontend job runs npm ci and vite build. Matches the CI badge
referenced in the README.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY
Full-stack document Q&A skeleton with a health-check wired end to end
browser -> API. Includes FastAPI backend with pytest suite, Vite + React +
Tailwind frontend, Docker Compose orchestration, and project spec.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN4QRr6dTE2W7hQ2SDnLmY