Lilly AI Assistant: RAG-based Conversational System
Retrieval-Augmented Generation (RAG) system providing accurate answers from internal documents
🖥️ User Interface Layer
⚙️ Application Logic Layer
🧠 Core Processing Layer
🔍 Information Retrieval Layer
☁️ External API Layer
💾 Data Stores
1
2
3
4
5
6
7
8
9
10
🌐
Streamlit Web Application
User interface for employee interactions
📊
Performance Tracker
Monitors query performance and logs metrics
👍
Feedback Manager
Collects and manages user feedback
🤖
ContentfulChatbot
Core chatbot orchestration logic
💭
In-Memory Chat History
Stores last 10 conversations; uses 3 for context
🔍
Hybrid Search
Combines semantic and keyword search
🗃️
FAISS Vector Index
Vector embeddings for semantic search
📊
TF-IDF Model
Keyword matching with term frequencies
🧠
Sentence Transformer
all-MiniLM-L6-v2 for query/doc embeddings
☁️
Claude API Client
External LLM request handling
🧠
Claude 3.7 Sonnet
External LLM service
📋
Metadata Store
Document metadata (metadata.pkl)
📈
Performance Logs
Query performance metrics
📊
Feedback Storage
User feedback data (feedback.xlsx)
User Interface Layer
Application Logic
Core Processing
Information Retrieval
External API
Data Stores

📋 Typical Request Flow Sequence

1User sends question via Streamlit UI
2ContentfulChatbot processes request
3Hybrid Search retrieves relevant documents
4Chat history context is added
5Prompt is constructed and sent to Claude API
6Response is processed and returned
7Chat history is updated
8Answer is displayed to user with sources
9Performance metrics are logged
10User provides feedback (optional)

🔧 ContentfulChatbot Internal Methods

Detailed view of the core chatbot component's internal method flow during query processing:

_validate_api_config()
_load_models_and_data()
_initialize_api_client()
ask()
_retrieve_relevant_documents()
_format_document_context()
_build_chat_context()
_create_prompt()
_call_api()
_extract_answer_from_response()
_update_chat_history()
Return Response
Method Execution Flow: Initialization methods run once → ask() triggered by user query → retrieval & context building → API call → response processing → history update