Skip to content
Back to search

flask-hybrid-rag-app

SkillWorks with Claude CodeGitHubIncomplete

Build a lightweight Python Flask web application with a clean light theme and a hybrid RAG (dense + BM25 keyword, fused with Reciprocal Rank Fusion) pipeline on ChromaDB, using AWS Bedrock Amazon Nova Pro for generation and Amazon Titan Text Embeddings V2 for embeddings, all configured through a .env file and served on port 5050. Use this skill whenever the user wants a Flask RAG app, document Q&A or knowledge-base chat, a "chat with your documents" prototype, a ChromaDB + Bedrock demo, a Nova Pro / Titan embeddings web app, a pre-sales or client-facing RAG prototype, or says "hybrid search", "Chroma", "Bedrock RAG", or "lightweight Flask app", even if they do not name every component. Also use it to extend or re-theme an app that was already generated from this skill.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/ajaychandra-nexusflow--flask-hybrid-rag-app/badge.svg)](/listings/ajaychandra-nexusflow--flask-hybrid-rag-app)

HTML

<a href="/listings/ajaychandra-nexusflow--flask-hybrid-rag-app"><img src="/api/listings/ajaychandra-nexusflow--flask-hybrid-rag-app/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 90 lines
  1. ---
  2. name: flask-hybrid-rag-app
  3. description: Build a lightweight Python Flask web application with a clean light theme and a hybrid RAG (dense + BM25 keyword, fused with Reciprocal Rank Fusion) pipeline on ChromaDB, using AWS Bedrock Amazon Nova Pro for generation and Amazon Titan Text Embeddings V2 for embeddings, all configured through a .env file and served on port 5050. Use this skill whenever the user wants a Flask RAG app, document Q&A or knowledge-base chat, a "chat with your documents" prototype, a ChromaDB + Bedrock demo, a Nova Pro / Titan embeddings web app, a pre-sales or client-facing RAG prototype, or says "hybrid search", "Chroma", "Bedrock RAG", or "lightweight Flask app", even if they do not name every component. Also use it to extend or re-theme an app that was already generated from this skill.
  4. ---
  5. # Flask Hybrid RAG App
  6. Generates a small, production-shaped Flask application: upload documents, index them in ChromaDB with Titan embeddings, search with **hybrid retrieval** (dense vectors + BM25, fused by RRF), and answer with **Nova Pro** through the Bedrock Converse API, with source citations. Light theme, `.env` driven, runs on **port 5050**.
  7. ## Fast path
  8. 1. Scaffold into the target folder (this copies the tested template and creates `.env` from `.env.example`):
  9. ```bash
  10. python /mnt/skills/user/flask-hybrid-rag-app/scripts/scaffold.py --dest ./my-rag-app --name "My RAG App"
  11. ```
  12. (Use the real skill path if it differs; the script lives next to this file.)
  13. 2. Customise (see "Customisation points" below): app name, accent colour, system prompt, sample documents.
  14. 3. Tell the user to fill in AWS settings in `.env`, then run:
  15. ```bash
  16. cd my-rag-app
  17. python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
  18. pip install -r requirements.txt
  19. python app.py # http://localhost:5050
  20. ```
  21. 4. Verify: `GET /api/health` returns `{"status":"ok", ...}`, upload a `.txt`/`.md`/`.pdf`, ask a question, confirm citations appear.
  22. Deliver the finished project as a zip (and/or present the folder) rather than pasting every file into chat.
  23. ## What the template contains
  24. ```
  25. app.py Flask routes, JSON errors, port from .env (default 5050)
  26. config.py All settings loaded from .env via python-dotenv
  27. rag/bedrock.py Titan embeddings (InvokeModel) + Nova Pro (Converse API)
  28. rag/store.py ChromaDB persistent store + in-memory BM25 + RRF fusion
  29. rag/chunking.py Paragraph-aware chunker with overlap
  30. rag/loaders.py txt / md / csv / pdf text extraction
  31. rag/pipeline.py retrieve -> build grounded prompt -> generate -> sources
  32. templates/ static/ Single-page light-theme UI (vanilla JS, no build step)
  33. .env.example Every configurable value, documented
  34. Dockerfile Optional container, exposes 5050
  35. ```
  36. ## Hard requirements (do not change unless the user asks)
  37. - **Port 5050**, read from `PORT` in `.env`; `.env.example` ships with `PORT=5050`.
  38. - **All configuration in `.env`**. Never hard-code credentials, model IDs, paths or weights in Python. New settings get added to both `config.py` and `.env.example`.
  39. - **Models**: generation `amazon.nova-pro-v1:0`, embeddings `amazon.titan-embed-text-v2:0` (1024 dims, normalized). Both are overridable in `.env`.
  40. - **Hybrid retrieval** means both signals are always available: dense (Chroma, cosine) and keyword (BM25), fused with weighted Reciprocal Rank Fusion. The UI lets the user switch between `hybrid`, `dense` and `keyword`.
  41. - **Light theme only**: white/near-white surfaces, dark slate text, one accent colour via CSS variables in `static/style.css`.
  42. - **Grounded answers**: the system prompt tells Nova Pro to answer only from retrieved context, cite `[n]`, and say so when the context lacks the answer.
  43. - **Credentials**: prefer the default AWS credential chain (profile, SSO, instance role). `.env` keys are optional and only for local use. Never echo secrets back to the user or commit `.env`.
  44. ## Customisation points
  45. | Want to change | Where |
  46. |---|---|
  47. | App title / tagline | `APP_NAME`, `APP_TAGLINE` in `.env` |
  48. | Accent colour, fonts | CSS variables at top of `static/style.css` |
  49. | Assistant behaviour / domain wording | `SYSTEM_PROMPT` in `.env` |
  50. | Chunk size / overlap | `CHUNK_SIZE`, `CHUNK_OVERLAP` |
  51. | Dense vs keyword balance | `HYBRID_DENSE_WEIGHT`, `HYBRID_KEYWORD_WEIGHT`, `RRF_K` |
  52. | Retrieval depth | `TOP_K` |
  53. | Model IDs / region | `BEDROCK_CHAT_MODEL_ID`, `EMBED_MODEL_ID`, `AWS_REGION` |
  54. | New file types | add an extractor in `rag/loaders.py` and its extension to `ALLOWED_EXTENSIONS` |
  55. | Chroma location / collection | `CHROMA_DIR`, `CHROMA_COLLECTION` |
  56. For domain re-theming (for example a media, broadcast or retail look), change the app name, accent colour, system prompt and sample questions; keep the architecture intact.
  57. ## Bedrock gotchas (tell the user when relevant)
  58. - **Model access must be enabled** in the Bedrock console for Nova Pro and Titan Text Embeddings V2 in the chosen region, otherwise calls fail with `AccessDeniedException`.
  59. - If Nova Pro rejects on-demand invocation in the region, set `BEDROCK_CHAT_MODEL_ID` to a cross-region inference profile such as `us.amazon.nova-pro-v1:0` (or `apac.` / `eu.` equivalent).
  60. - Changing `EMBED_MODEL_ID` or `EMBED_DIMENSIONS` after documents are indexed requires a fresh Chroma folder, because vector sizes must match. Delete `CHROMA_DIR` and re-upload.
  61. - Throttling is retried by boto3 (`standard` mode); large uploads embed chunks with a small thread pool (`EMBED_WORKERS`).
  62. ## Extending safely
  63. Read `references/rag-design.md` before changing retrieval. Common extensions: reranking step after RRF, metadata filters (`where=` in Chroma), streaming answers (`converse_stream`), basic auth/login, S3 as the document source. Keep each addition behind a `.env` flag so the base app stays lightweight.
  64. ## Troubleshooting
  65. | Symptom | Likely cause |
  66. |---|---|
  67. | `AccessDeniedException` | Model access not enabled, or IAM missing `bedrock:InvokeModel` |
  68. | `ValidationException` on chat | Use an inference-profile ID for Nova Pro in that region |
  69. | `NoCredentialsError` | Set a profile/role, or the three `AWS_*` values in `.env` |
  70. | Empty answers, "no context" | No documents uploaded, or scanned PDF with no extractable text |
  71. | Port already in use | Another process on 5050; change `PORT` in `.env` |
  72. | Dimension mismatch error | Embedding settings changed; wipe `CHROMA_DIR` |

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.