Notes for contributors and coding agents working on this repo.
chat_with_pdf_query.py: default app. UsesCouchbaseQueryVectorStore(Query + Index services, Hyperscale/Composite vector indexes).chat_with_pdf.py: usesCouchbaseSearchVectorStore(Search service, needsINDEX_NAME).tests/smoke/: Streamlit + Playwright smoke tests for both entrypoints (no credentials).tests/provider/: optional live OpenAI provider smoke test (needsOPENAI_API_KEY, no Couchbase)..github/workflows/smoke.yml: runs the smoke tests on every PR and push tomain, plus the optional provider job.
| Tier | What | When | Required? |
|---|---|---|---|
| 1 | tests/smoke Streamlit + Playwright smoke, no secrets |
Every PR, push to main, manual dispatch |
Yes. The required PR check |
| 2 | tests/provider live OpenAI provider smoke |
CI job openai-provider-smoke when OPENAI_API_KEY is available; skips with a notice otherwise |
No. Optional signal |
| 3 | Full Couchbase-backed RAG run (checklist below) | Manually, by a maintainer, before merging dependency updates | Yes. Evidence goes in the PR |
Tiers 1 and 2 do not replace tier 3.
pip install -r requirements-dev.txt # app deps + pytest + playwright
python -m playwright install --with-deps chromiumrequirements.txt holds only the app's runtime dependencies. Dependabot bumps both files.
python -m pytest tests/smoke -vThese tests need no Couchbase cluster and no OpenAI key. They start each app headless on a free port, open it in headless Chromium, and fail if a Python traceback or st.exception appears in the page or the server log. For each entrypoint they check:
- Unconfigured start: the real app with no settings loads, imports every real dependency, and shows the
OPENAI_API_KEY environment variable is not setmessage. - Auth gate: with
AUTH_ENABLED=True, the password form renders and rejects a wrong password. - Stubbed full flow:
tests/smoke/stubbed_app.pyruns the app with the Couchbase cluster, vector store, and cache, plus the OpenAI embeddings and chat model, swapped for in-memory LangChain fakes. The test checks that the expected controls render, uploads a small generated PDF (realpypdfloader and text splitter), asks a question, and asserts that the RAG answer used the retrieved PDF context and the pure-LLM answer did not.
The tests set placeholder values for every app setting and use an isolated HOME, so a local .streamlit/secrets.toml or real credentials in your shell are never used.
What the smoke tests do not cover: real Couchbase connectivity, vector index definitions, langchain-couchbase query/search behaviour against a cluster, OpenAI API compatibility (model names, request shapes), and the LLM cache against a real collection. The optional provider smoke covers the OpenAI part. The rest is why live validation stays manual (below).
OPENAI_API_KEY=... python -m pytest tests/provider -v -rsThis calls the real OpenAI API and does not touch Couchbase. It reads the OpenAIEmbeddings(...) and ChatOpenAI(...) arguments from both app entrypoints, so it checks the exact models and options the apps use:
- Embeddings:
embed_queryreturns a 1536-dim vector of finite floats (the README index definitions use 1536 dims). - Chat: each distinct
ChatOpenAIconfiguration returns a non-empty reply to a one-line prompt.
Without OPENAI_API_KEY the tests are skipped with a clear reason. With an invalid key or a retired model they fail. In CI the openai-provider-smoke job uses the OPENAI_API_KEY Actions secret. Secrets are not passed to fork or Dependabot PRs, so there the job posts a "skipped" notice and passes. To check the live OpenAI path for such a PR, run the workflow manually (Actions → Streamlit smoke tests → Run workflow) on the PR branch.
A green smoke run is necessary but not sufficient to merge a dependency bump (for example langchain-*, couchbase, streamlit, pypdf). Before merging, a maintainer runs the app against a real cluster and records this evidence in the PR:
- App boot:
streamlit run chat_with_pdf_query.py(andstreamlit run chat_with_pdf.pyif the bump toucheslangchain-couchbase,couchbase, or Search) starts with no errors, and the installed versions match the PR (pip freeze | grep -iE "langchain|couchbase|streamlit|pypdf|openai"). - Couchbase / vector index state: the cluster version, the bucket/scope/collection used, and that the index exists. For the Query app that is the Hyperscale/Composite vector index from the README's "Index Configuration" section. For the Search app it is the Search index named by
INDEX_NAME(see "Create the Search Index"). - Provider credentials: confirm that
OPENAI_API_KEYwas available and that the configured models were accessible. State only that it was set, never the value. - Sample input / query: the PDF you uploaded (name and approximate size) and the question you asked.
- Observed response: the RAG answer and the pure-LLM answer. Ask the same question a second time to confirm the cached response is returned.
- Screenshots or traces of the upload confirmation and the chat answers, when practical.
Set these in .streamlit/secrets.toml (copy .streamlit/secrets.example.toml) or as environment variables. Never commit real values, and never paste them into PRs, issues, or logs.
| Name | Used by |
|---|---|
OPENAI_API_KEY |
both apps |
DB_CONN_STR, DB_USERNAME, DB_PASSWORD |
both apps |
DB_BUCKET, DB_SCOPE, DB_COLLECTION, CACHE_COLLECTION |
both apps |
INDEX_NAME |
chat_with_pdf.py only |
AUTH_ENABLED, LOGIN_PASSWORD |
optional app password gate |
The required CI smoke job needs no repository secrets. The optional openai-provider-smoke job uses the OPENAI_API_KEY Actions secret when it is available.