How dunh-real/tpv-chatbot-btl works
TPV Chatbot BTL is an internal enterprise AI server combining conversational RAG, structured-data queries, document ingestion, and document generation. The main workflow accepts a chat request, retrieves relevant vector and MSSQL context, reranks and prompts an LLM, and retains conversation history. Separate branches process uploaded PDFs into indexed chunks, generate department reports and template-based documents, and turn Markdown into PowerPoint. The graph follows shown imports/calls and README capability descriptions; some detailed implementations were not sampled, so uncertain links are omitted.
Main entry points: chat.py Chat session · presentation.py Presentation endpoint · upload.py PDF processing · main.py FastAPI application
Components 30
API and orchestration
- FastAPI application
main.py - Chat endpoint
src/api/chat.py - Upload endpoint
src/api/upload.py - Presentation endpoint
src/api/presentation.py
Chat and retrieval
- Chat session
src/core/chat.py - Prompt assembly
src/services/prompt_service.py - Context reranking
src/services/rerank_service.py - Ollama LLM
src/services/llm_service.py - Vector retrieval
src/services/qdrant_service.py - SQL retrieval
src/services/mssql_retrieval_service.py - Text-to-SQL
src/services/text2sql_service.py - Conversation memory
src/services/memory_service.py - Department reports
src/services/report_service.py
Document ingestion
- PDF processing
src/core/upload.py - OCR extraction
src/services/ocr_service.py - Chunking
src/services/chunking_service.py - Vector embedding
src/services/embedding_service.py - Object storage
src/services/storage_service.py
Document generation
- Template document API
src/api/doc_generator_api.py - Template document creation
src/services/docs_create_service.py - Slide planning
src/services/presentation/content_planner.py - Markdown parsing
src/services/presentation/markdown_parser.py - Deck composition
src/services/presentation/composer.py - Renderer client
src/services/presentation/renderer_client.py - PowerPoint renderer
src/services/presentation/renderer - Document templates
src/templates
Other components
- Backend / user
- MSSQL database
- Ollama service
- Redis
Connections 32
- Backend / user → FastAPI application: calls API
README.md - FastAPI application → Chat endpoint: registers route
main.py - FastAPI application → Upload endpoint: registers route
main.py - FastAPI application → Presentation endpoint: registers route
main.py - Chat endpoint → Chat session: handles chat
README.md - Chat session → Conversation memory: reads and saves
src/core/chat.py - Chat session → Vector retrieval: retrieves context
src/core/chat.py - Chat session → SQL retrieval: retrieves context
src/core/chat.py - Chat session → Context reranking: reranks context
src/core/chat.py - Chat session → Prompt assembly: builds prompt
src/core/chat.py - Chat session → Ollama LLM: requests answer
src/core/chat.py - Chat session → Department reports: generates report
src/core/chat.py - SQL retrieval → Text-to-SQL: creates SQL
src/services/mssql_retrieval_service.py - SQL retrieval → MSSQL database: queries
README.md - Ollama LLM → Ollama service: invokes model
src/services/llm_service.py - Vector retrieval → Vector embedding: embeds queries
src/services/qdrant_service.py - Upload endpoint → PDF processing: queues processing
src/api/upload.py - PDF processing → OCR extraction: extracts text
src/core/upload.py - PDF processing → Chunking: chunks text
src/core/upload.py - Chunking → Vector embedding: embeds chunks
src/services/chunking_service.py - PDF processing → Vector retrieval: indexes chunks
src/core/upload.py - PDF processing → Object storage: stores OCR text
src/core/upload.py - Template document API → Template document creation: creates document
src/api/doc_generator_api.py - Template document creation → Ollama LLM: generates field text
src/services/docs_create_service.py - Template document creation → Prompt assembly: uses prompts
src/services/docs_create_service.py - Template document creation → Document templates: fills template
README.md - Presentation endpoint → Markdown parsing: parses Markdown
src/api/presentation.py - Presentation endpoint → Slide planning: plans slides
src/api/presentation.py - Presentation endpoint → Deck composition: composes deck
src/api/presentation.py - Slide planning → Markdown parsing: uses parsed source
src/services/presentation/content_planner.py - Presentation endpoint → Renderer client: renders plan
src/api/presentation.py - Renderer client → PowerPoint renderer: dispatches rendering