Production-ready document QA architecture, now with an in-app AI generation demo.
This companion app includes the complete Python project structure requested and now integrates GenMB AI text generation directly in the UI so users can test answer drafting, prompt flows, and chat interactions without leaving the app.
Deployment checklist
Ready- Environment variables are externalized in
.env.example. - No hardcoded local paths; uploads persist in the project
data/directory. - Requirements include Streamlit, LangChain, Sentence Transformers, Transformers, and Endee.
- The web companion now uses the GenMB AI completion service via
/api/ai/completion.
RAG pipeline architecture
The generated backend follows the exact retrieval flow requested for Endee-powered semantic search.
User Question
A user asks a document-grounded question from the Streamlit chat interface.
Embedding Model
The question is embedded with all-MiniLM-L6-v2 using Sentence Transformers.
Endee Search
Endee stores chunk vectors and runs semantic similarity search for top-k matches.
Retriever Context
Relevant chunks and metadata are assembled into a context package.
Mistral LLM
The prompt is sent to Mistral-7B-Instruct to generate a grounded answer.
Answer + Sources
The app returns the final answer along with cited source chunks and scores.
Included improvements
The backend package upgrades structure, usability, observability, and deployability.
Multi-document upload
Supports PDF, TXT, and DOCX uploads with chunking and metadata tracking.
Similarity visibility
Retrieved chunks and similarity scores can be shown for transparency.
Source citations
Answers include source filenames and chunk identifiers for auditing.
AI generation enabled
The browser app now integrates GenMB AI text generation with proper chat history, loading, and error states.
Integrated capability
AI text generation
This panel uses the platform AI proxy at /api/ai/completion with conversation history, loading states,
disabled controls, empty states, and user-visible feedback.
Try a starter prompt
Behavior notes
- Maintains the latest 10 conversation turns in the prompt.
- Extracts and renders
json.data.textonly. - Shows explicit errors, loading state, and success confirmation.
AI chat playground
Use it to draft answers, summaries, or deployment guidance.
Streamlit sidebar preview
Upload-awareUpload documents
PDF, TXT, DOCX
Indexed files
- security-policy.pdf
- operations-runbook.docx
- support-guidelines.txt
Chat and retrieval preview
Sources visibleRetrieved sources
top-k chunkssecurity-policy.pdf
score 0.92Critical severity incidents require immediate triage, acknowledgement within 15 minutes, and executive communication within 60 minutes.
operations-runbook.docx
score 0.87After containment, the incident commander prepares a concise root cause summary and remediation plan for stakeholders.
Generated project files
All of these backend files are included in the response payload for direct use.
app.py
Streamlit AppProduction-ready UI with upload, chat, sources, and clear session controls.
utils/document_loader.py
IngestionLoads PDF, TXT, and DOCX files and converts them into LangChain Documents.
utils/embeddings.py
EmbeddingsWraps SentenceTransformer all-MiniLM-L6-v2 for document and query embeddings.
utils/vector_store.py
Vector DBEncapsulates Endee upsert, search, listing, and collection management.
utils/rag_pipeline.py
RAGBuilds prompt context, retrieves chunks, and generates answers with sources.
README.md
DocumentationProfessional setup, architecture, deployment, and environment guidance.