moazx commited on
Commit
7a527fe
Β·
1 Parent(s): bf93b8f

Add export router to app.py and update requirements.txt for document generation libraries

Browse files
api/__pycache__/app.cpython-313.pyc CHANGED
Binary files a/api/__pycache__/app.cpython-313.pyc and b/api/__pycache__/app.cpython-313.pyc differ
 
api/app.py CHANGED
@@ -6,7 +6,7 @@ from fastapi.exceptions import RequestValidationError
6
  from starlette.exceptions import HTTPException as StarletteHTTPException
7
 
8
  # Import routers
9
- from api.routers import medical, health
10
  from api.middleware import (
11
  ProcessTimeMiddleware,
12
  LoggingMiddleware,
@@ -73,6 +73,7 @@ app.add_exception_handler(Exception, general_exception_handler)
73
  # Include routers
74
  app.include_router(health.router)
75
  app.include_router(medical.router)
 
76
 
77
  # Root endpoint
78
  @app.get("/")
@@ -87,7 +88,8 @@ async def root():
87
  "endpoints": {
88
  "ask": "/ask",
89
  "ask_stream": "/ask/stream",
90
- "initialization_status": "/health/initialization"
 
91
  }
92
  }
93
 
 
6
  from starlette.exceptions import HTTPException as StarletteHTTPException
7
 
8
  # Import routers
9
+ from api.routers import medical, health, export
10
  from api.middleware import (
11
  ProcessTimeMiddleware,
12
  LoggingMiddleware,
 
73
  # Include routers
74
  app.include_router(health.router)
75
  app.include_router(medical.router)
76
+ app.include_router(export.router)
77
 
78
  # Root endpoint
79
  @app.get("/")
 
88
  "endpoints": {
89
  "ask": "/ask",
90
  "ask_stream": "/ask/stream",
91
+ "initialization_status": "/health/initialization",
92
+ "export": "/export/{format}?session_id={session_id}"
93
  }
94
  }
95
 
api/routers/export.py ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Export Router for Conversation History
3
+ """
4
+ import io
5
+ import sys
6
+ import os
7
+ from datetime import datetime
8
+ from fastapi import APIRouter, HTTPException
9
+ from fastapi.responses import StreamingResponse
10
+ from docx import Document
11
+ from docx.shared import Pt, RGBColor, Inches
12
+ from docx.enum.text import WD_ALIGN_PARAGRAPH
13
+ from reportlab.lib.pagesizes import letter
14
+ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
15
+ from reportlab.lib.units import inch
16
+ from reportlab.lib.colors import Color, HexColor
17
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
18
+ from reportlab.lib.enums import TA_LEFT, TA_RIGHT
19
+
20
+ # Add src to path for imports
21
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
22
+
23
+ from core.agent import _memory_manager
24
+
25
+ router = APIRouter(tags=["export"])
26
+
27
+
28
+ def get_conversation_history(session_id: str):
29
+ """
30
+ Retrieve conversation history from memory manager.
31
+
32
+ Args:
33
+ session_id: Session identifier
34
+
35
+ Returns:
36
+ List of message dictionaries with 'role' and 'content'
37
+ """
38
+ try:
39
+ memory = _memory_manager.get_memory(session_id)
40
+ messages = []
41
+
42
+ # Get chat history from memory
43
+ if hasattr(memory, 'chat_memory') and hasattr(memory.chat_memory, 'messages'):
44
+ for msg in memory.chat_memory.messages:
45
+ # LangChain messages have type and content
46
+ role = "User" if msg.type == "human" else "Assistant"
47
+ messages.append({
48
+ "role": role,
49
+ "content": msg.content
50
+ })
51
+
52
+ return messages
53
+ except Exception as e:
54
+ raise HTTPException(
55
+ status_code=500,
56
+ detail=f"Error retrieving conversation history: {str(e)}"
57
+ )
58
+
59
+
60
+ def generate_docx(session_id: str, messages: list) -> io.BytesIO:
61
+ """
62
+ Generate a Word document from conversation history.
63
+
64
+ Args:
65
+ session_id: Session identifier
66
+ messages: List of message dictionaries
67
+
68
+ Returns:
69
+ BytesIO object containing the Word document
70
+ """
71
+ doc = Document()
72
+
73
+ # Add title
74
+ title = doc.add_heading('Conversation History', 0)
75
+ title.alignment = WD_ALIGN_PARAGRAPH.CENTER
76
+
77
+ # Add metadata
78
+ doc.add_paragraph(f'Session ID: {session_id}')
79
+ doc.add_paragraph(f'Export Date: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}')
80
+ doc.add_paragraph('') # Empty line
81
+
82
+ # Add separator
83
+ doc.add_paragraph('_' * 80)
84
+ doc.add_paragraph('')
85
+
86
+ # Add messages
87
+ for msg in messages:
88
+ # Add role heading
89
+ role_para = doc.add_paragraph()
90
+ role_run = role_para.add_run(f"{msg['role']}:")
91
+ role_run.bold = True
92
+ role_run.font.size = Pt(12)
93
+
94
+ if msg['role'] == 'User':
95
+ role_run.font.color.rgb = RGBColor(255, 107, 53) # Orange color
96
+ else:
97
+ role_run.font.color.rgb = RGBColor(51, 51, 51) # Dark gray
98
+
99
+ # Add message content
100
+ content_para = doc.add_paragraph(msg['content'])
101
+ content_para.paragraph_format.left_indent = Inches(0.25)
102
+
103
+ # Add spacing
104
+ doc.add_paragraph('')
105
+
106
+ # Save to BytesIO
107
+ buffer = io.BytesIO()
108
+ doc.save(buffer)
109
+ buffer.seek(0)
110
+
111
+ return buffer
112
+
113
+
114
+ def generate_pdf(session_id: str, messages: list) -> io.BytesIO:
115
+ """
116
+ Generate a PDF document from conversation history.
117
+
118
+ Args:
119
+ session_id: Session identifier
120
+ messages: List of message dictionaries
121
+
122
+ Returns:
123
+ BytesIO object containing the PDF document
124
+ """
125
+ buffer = io.BytesIO()
126
+ doc = SimpleDocTemplate(buffer, pagesize=letter,
127
+ rightMargin=72, leftMargin=72,
128
+ topMargin=72, bottomMargin=18)
129
+
130
+ # Container for the 'Flowable' objects
131
+ elements = []
132
+
133
+ # Define styles
134
+ styles = getSampleStyleSheet()
135
+
136
+ # Title style
137
+ title_style = ParagraphStyle(
138
+ 'CustomTitle',
139
+ parent=styles['Heading1'],
140
+ fontSize=24,
141
+ textColor=HexColor('#000000'),
142
+ spaceAfter=30,
143
+ alignment=TA_LEFT
144
+ )
145
+
146
+ # Metadata style
147
+ meta_style = ParagraphStyle(
148
+ 'MetaStyle',
149
+ parent=styles['Normal'],
150
+ fontSize=10,
151
+ textColor=HexColor('#666666'),
152
+ spaceAfter=6
153
+ )
154
+
155
+ # User message style
156
+ user_style = ParagraphStyle(
157
+ 'UserStyle',
158
+ parent=styles['Normal'],
159
+ fontSize=11,
160
+ textColor=HexColor('#FF6B35'),
161
+ fontName='Helvetica-Bold',
162
+ spaceAfter=6
163
+ )
164
+
165
+ # Assistant message style
166
+ assistant_style = ParagraphStyle(
167
+ 'AssistantStyle',
168
+ parent=styles['Normal'],
169
+ fontSize=11,
170
+ textColor=HexColor('#333333'),
171
+ fontName='Helvetica-Bold',
172
+ spaceAfter=6
173
+ )
174
+
175
+ # Content style
176
+ content_style = ParagraphStyle(
177
+ 'ContentStyle',
178
+ parent=styles['Normal'],
179
+ fontSize=10,
180
+ leftIndent=20,
181
+ spaceAfter=12
182
+ )
183
+
184
+ # Add title
185
+ elements.append(Paragraph('Conversation History', title_style))
186
+ elements.append(Spacer(1, 12))
187
+
188
+ # Add metadata
189
+ elements.append(Paragraph(f'Session ID: {session_id}', meta_style))
190
+ elements.append(Paragraph(f'Export Date: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}', meta_style))
191
+ elements.append(Spacer(1, 20))
192
+
193
+ # Add separator line
194
+ elements.append(Paragraph('_' * 100, meta_style))
195
+ elements.append(Spacer(1, 12))
196
+
197
+ # Add messages
198
+ for msg in messages:
199
+ # Add role
200
+ role_style = user_style if msg['role'] == 'User' else assistant_style
201
+ elements.append(Paragraph(f"{msg['role']}:", role_style))
202
+
203
+ # Add content (escape HTML special characters)
204
+ content = msg['content'].replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
205
+ elements.append(Paragraph(content, content_style))
206
+ elements.append(Spacer(1, 12))
207
+
208
+ # Build PDF
209
+ doc.build(elements)
210
+ buffer.seek(0)
211
+
212
+ return buffer
213
+
214
+
215
+ @router.get("/export/{format}")
216
+ async def export_conversation(format: str, session_id: str = "default"):
217
+ """
218
+ Export conversation history as Word (.docx) or PDF (.pdf) file.
219
+
220
+ Args:
221
+ format: Export format ('docx' or 'pdf')
222
+ session_id: Session identifier (default: "default")
223
+
224
+ Returns:
225
+ StreamingResponse with the generated document
226
+ """
227
+ # Validate format
228
+ if format.lower() not in ['docx', 'pdf']:
229
+ raise HTTPException(
230
+ status_code=400,
231
+ detail="Invalid format. Use 'docx' or 'pdf'"
232
+ )
233
+
234
+ # Get conversation history
235
+ messages = get_conversation_history(session_id)
236
+
237
+ if not messages:
238
+ raise HTTPException(
239
+ status_code=404,
240
+ detail="No conversation history found for this session"
241
+ )
242
+
243
+ try:
244
+ # Generate document based on format
245
+ if format.lower() == 'docx':
246
+ buffer = generate_docx(session_id, messages)
247
+ media_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
248
+ filename = f"conversation_{session_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.docx"
249
+ else: # pdf
250
+ buffer = generate_pdf(session_id, messages)
251
+ media_type = "application/pdf"
252
+ filename = f"conversation_{session_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf"
253
+
254
+ return StreamingResponse(
255
+ buffer,
256
+ media_type=media_type,
257
+ headers={
258
+ "Content-Disposition": f"attachment; filename={filename}"
259
+ }
260
+ )
261
+
262
+ except Exception as e:
263
+ raise HTTPException(
264
+ status_code=500,
265
+ detail=f"Error generating {format.upper()} document: {str(e)}"
266
+ )
core/__pycache__/agent.cpython-313.pyc CHANGED
Binary files a/core/__pycache__/agent.cpython-313.pyc and b/core/__pycache__/agent.cpython-313.pyc differ
 
logs/app.log CHANGED
@@ -2810,3 +2810,219 @@ Medicatio...
2810
  2025-10-14 19:13:14,886 - AgenticMedicalRAG - INFO - Successfully processed user input: what is my name...
2811
  2025-10-14 19:13:24,367 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): hi what is my name...
2812
  2025-10-14 19:13:26,466 - AgenticMedicalRAG - INFO - Successfully processed user input: hi what is my name...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2810
  2025-10-14 19:13:14,886 - AgenticMedicalRAG - INFO - Successfully processed user input: what is my name...
2811
  2025-10-14 19:13:24,367 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): hi what is my name...
2812
  2025-10-14 19:13:26,466 - AgenticMedicalRAG - INFO - Successfully processed user input: hi what is my name...
2813
+ 2025-10-15 11:55:21,110 - AgenticMedicalRAG - INFO - Configuration validation completed
2814
+ 2025-10-15 11:55:22,611 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2815
+ 2025-10-15 11:55:22,612 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2816
+ 2025-10-15 11:55:22,612 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2817
+ 2025-10-15 11:55:22,613 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2818
+ 2025-10-15 11:55:34,494 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2819
+ 2025-10-15 11:55:34,495 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2820
+ 2025-10-15 11:55:34,496 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2821
+ 2025-10-15 11:55:34,496 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2822
+ 2025-10-15 11:55:34,496 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2823
+ 2025-10-15 11:55:35,068 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2824
+ 2025-10-15 11:55:35,089 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2825
+ 2025-10-15 11:55:35,089 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2826
+ 2025-10-15 11:55:35,445 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2827
+ 2025-10-15 11:55:35,445 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2828
+ 2025-10-15 11:55:35,446 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2829
+ 2025-10-15 11:55:35,446 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2830
+ 2025-10-15 11:55:35,446 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2831
+ 2025-10-15 11:56:29,506 - AgenticMedicalRAG - INFO - Configuration validation completed
2832
+ 2025-10-15 11:56:30,251 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2833
+ 2025-10-15 11:56:30,252 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2834
+ 2025-10-15 11:56:30,253 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2835
+ 2025-10-15 11:56:30,253 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2836
+ 2025-10-15 11:56:37,823 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2837
+ 2025-10-15 11:56:37,824 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2838
+ 2025-10-15 11:56:37,824 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2839
+ 2025-10-15 11:56:37,825 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2840
+ 2025-10-15 11:56:37,825 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2841
+ 2025-10-15 11:56:37,896 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2842
+ 2025-10-15 11:56:37,912 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2843
+ 2025-10-15 11:56:37,913 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2844
+ 2025-10-15 11:56:38,314 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2845
+ 2025-10-15 11:56:38,315 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2846
+ 2025-10-15 11:56:38,316 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2847
+ 2025-10-15 11:56:38,316 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2848
+ 2025-10-15 11:56:38,316 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2849
+ 2025-10-15 11:56:39,646 - AgenticMedicalRAG - INFO - LLM initialized successfully
2850
+ 2025-10-15 11:56:39,646 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
2851
+ 2025-10-15 11:56:39,646 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
2852
+ 2025-10-15 12:03:09,903 - AgenticMedicalRAG - INFO - Configuration validation completed
2853
+ 2025-10-15 12:03:10,683 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2854
+ 2025-10-15 12:03:10,684 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2855
+ 2025-10-15 12:03:10,685 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2856
+ 2025-10-15 12:03:10,686 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2857
+ 2025-10-15 12:03:18,456 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2858
+ 2025-10-15 12:03:18,456 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2859
+ 2025-10-15 12:03:18,456 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2860
+ 2025-10-15 12:03:18,456 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2861
+ 2025-10-15 12:03:18,456 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2862
+ 2025-10-15 12:03:18,562 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2863
+ 2025-10-15 12:03:18,588 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2864
+ 2025-10-15 12:03:18,589 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2865
+ 2025-10-15 12:03:18,983 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2866
+ 2025-10-15 12:03:18,983 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2867
+ 2025-10-15 12:03:18,984 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2868
+ 2025-10-15 12:03:18,984 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2869
+ 2025-10-15 12:03:18,984 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2870
+ 2025-10-15 12:03:20,251 - AgenticMedicalRAG - INFO - LLM initialized successfully
2871
+ 2025-10-15 12:03:20,251 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
2872
+ 2025-10-15 12:03:20,252 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
2873
+ 2025-10-15 12:04:12,798 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): What is the role of durvalumab in stage III NSCLC ...
2874
+ 2025-10-15 12:04:23,412 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
2875
+ 2025-10-15 12:04:24,235 - AgenticMedicalRAG - INFO - Medical answer validator initialized successfully
2876
+ 2025-10-15 12:04:24,235 - AgenticMedicalRAG - INFO - GitHub storage initialized for MoazEldsouky/cloud-data-store
2877
+ 2025-10-15 12:04:37,308 - AgenticMedicalRAG - INFO - Starting validation for interaction 36
2878
+ 2025-10-15 12:04:52,405 - AgenticMedicalRAG - INFO - Assigned unique interaction ID: 36
2879
+ 2025-10-15 12:04:56,153 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/evaluation_results.json to GitHub
2880
+ 2025-10-15 12:04:56,154 - AgenticMedicalRAG - INFO - Evaluation saved to GitHub with ID: 36
2881
+ 2025-10-15 12:04:56,154 - AgenticMedicalRAG - INFO - Background validation completed - Interaction ID: 36
2882
+ 2025-10-15 12:04:56,155 - AgenticMedicalRAG - INFO - Validation scores - Overall: 90/100, Accuracy: 95/100, Coherence: 90/100, Relevance: 100/100
2883
+ 2025-10-15 12:04:56,155 - AgenticMedicalRAG - INFO - Successfully processed user input: What is the role of durvalumab in stage III NSCLC ...
2884
+ 2025-10-15 12:04:56,159 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): What is the recommended first-line treatment for a...
2885
+ 2025-10-15 12:05:03,904 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
2886
+ 2025-10-15 12:05:05,234 - AgenticMedicalRAG - INFO - Starting validation for interaction 37
2887
+ 2025-10-15 12:05:13,869 - AgenticMedicalRAG - INFO - Assigned unique interaction ID: 37
2888
+ 2025-10-15 12:05:18,504 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/evaluation_results.json to GitHub
2889
+ 2025-10-15 12:05:18,505 - AgenticMedicalRAG - INFO - Evaluation saved to GitHub with ID: 37
2890
+ 2025-10-15 12:05:18,506 - AgenticMedicalRAG - INFO - Background validation completed - Interaction ID: 37
2891
+ 2025-10-15 12:05:18,506 - AgenticMedicalRAG - INFO - Validation scores - Overall: 90/100, Accuracy: 95/100, Coherence: 90/100, Relevance: 88/100
2892
+ 2025-10-15 12:05:18,506 - AgenticMedicalRAG - INFO - Successfully processed user input: What is the recommended first-line treatment for a...
2893
+ 2025-10-15 12:06:42,357 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): i found that Afinitor has these side effects fever...
2894
+ 2025-10-15 12:06:51,917 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/side_effects_reports.csv to GitHub
2895
+ 2025-10-15 12:06:53,527 - AgenticMedicalRAG - INFO - Successfully processed user input: i found that Afinitor has these side effects fever...
2896
+ 2025-10-15 13:53:10,922 - AgenticMedicalRAG - INFO - Configuration validation completed
2897
+ 2025-10-15 13:53:14,459 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2898
+ 2025-10-15 13:53:14,460 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2899
+ 2025-10-15 13:53:14,461 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2900
+ 2025-10-15 13:53:14,461 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2901
+ 2025-10-15 13:53:37,561 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2902
+ 2025-10-15 13:53:37,561 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2903
+ 2025-10-15 13:53:37,562 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2904
+ 2025-10-15 13:53:37,562 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2905
+ 2025-10-15 13:53:37,562 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2906
+ 2025-10-15 13:53:38,204 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2907
+ 2025-10-15 13:53:38,256 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2908
+ 2025-10-15 13:53:38,257 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2909
+ 2025-10-15 13:53:38,599 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2910
+ 2025-10-15 13:53:38,599 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2911
+ 2025-10-15 13:53:38,600 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2912
+ 2025-10-15 13:53:38,600 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2913
+ 2025-10-15 13:53:38,600 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2914
+ 2025-10-15 13:53:40,070 - AgenticMedicalRAG - INFO - LLM initialized successfully
2915
+ 2025-10-15 13:53:40,071 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
2916
+ 2025-10-15 13:53:40,071 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
2917
+ 2025-10-15 15:15:32,001 - AgenticMedicalRAG - INFO - Configuration validation completed
2918
+ 2025-10-15 15:21:28,032 - AgenticMedicalRAG - INFO - Configuration validation completed
2919
+ 2025-10-15 15:25:20,165 - AgenticMedicalRAG - INFO - Configuration validation completed
2920
+ 2025-10-15 15:26:11,107 - AgenticMedicalRAG - INFO - Configuration validation completed
2921
+ 2025-10-15 15:28:26,020 - AgenticMedicalRAG - INFO - Configuration validation completed
2922
+ 2025-10-15 15:31:26,481 - AgenticMedicalRAG - INFO - Configuration validation completed
2923
+ 2025-10-15 15:31:27,943 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2924
+ 2025-10-15 15:31:27,944 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2925
+ 2025-10-15 15:31:27,945 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2926
+ 2025-10-15 15:31:27,945 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2927
+ 2025-10-15 15:31:37,240 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2928
+ 2025-10-15 15:31:37,240 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2929
+ 2025-10-15 15:31:37,240 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2930
+ 2025-10-15 15:31:37,241 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2931
+ 2025-10-15 15:31:37,241 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2932
+ 2025-10-15 15:31:37,355 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2933
+ 2025-10-15 15:31:37,381 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2934
+ 2025-10-15 15:31:37,381 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2935
+ 2025-10-15 15:31:37,816 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2936
+ 2025-10-15 15:31:37,816 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2937
+ 2025-10-15 15:31:37,816 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2938
+ 2025-10-15 15:31:37,817 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2939
+ 2025-10-15 15:31:37,817 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2940
+ 2025-10-15 15:31:39,116 - AgenticMedicalRAG - INFO - LLM initialized successfully
2941
+ 2025-10-15 15:31:39,117 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
2942
+ 2025-10-15 15:31:39,117 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
2943
+ 2025-10-15 15:43:17,615 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): hi...
2944
+ 2025-10-15 15:43:20,246 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
2945
+ 2025-10-15 15:43:20,246 - AgenticMedicalRAG - INFO - Skipping validation: insufficient context
2946
+ 2025-10-15 15:43:20,247 - AgenticMedicalRAG - INFO - Successfully processed user input: hi...
2947
+ 2025-10-15 15:43:38,087 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): What is the role of durvalumab in stage III NSCLC ...
2948
+ 2025-10-15 15:43:47,023 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
2949
+ 2025-10-15 15:43:48,038 - AgenticMedicalRAG - INFO - Medical answer validator initialized successfully
2950
+ 2025-10-15 15:43:48,038 - AgenticMedicalRAG - INFO - GitHub storage initialized for MoazEldsouky/cloud-data-store
2951
+ 2025-10-15 15:43:49,398 - AgenticMedicalRAG - INFO - Starting validation for interaction 38
2952
+ 2025-10-15 15:44:05,399 - AgenticMedicalRAG - INFO - Assigned unique interaction ID: 38
2953
+ 2025-10-15 15:44:09,466 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/evaluation_results.json to GitHub
2954
+ 2025-10-15 15:44:09,467 - AgenticMedicalRAG - INFO - Evaluation saved to GitHub with ID: 38
2955
+ 2025-10-15 15:44:09,468 - AgenticMedicalRAG - INFO - Background validation completed - Interaction ID: 38
2956
+ 2025-10-15 15:44:09,468 - AgenticMedicalRAG - INFO - Validation scores - Overall: 90/100, Accuracy: 95/100, Coherence: 90/100, Relevance: 100/100
2957
+ 2025-10-15 15:44:09,468 - AgenticMedicalRAG - INFO - Successfully processed user input: What is the role of durvalumab in stage III NSCLC ...
2958
+ 2025-10-15 15:48:15,410 - AgenticMedicalRAG - INFO - Configuration validation completed
2959
+ 2025-10-15 15:48:19,805 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2960
+ 2025-10-15 15:48:19,807 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2961
+ 2025-10-15 15:48:19,807 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2962
+ 2025-10-15 15:48:19,808 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2963
+ 2025-10-15 15:48:32,796 - AgenticMedicalRAG - INFO - Configuration validation completed
2964
+ 2025-10-15 15:48:34,304 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2965
+ 2025-10-15 15:48:34,305 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2966
+ 2025-10-15 15:48:34,306 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2967
+ 2025-10-15 15:48:34,307 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2968
+ 2025-10-15 15:48:56,261 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2969
+ 2025-10-15 15:48:56,262 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2970
+ 2025-10-15 15:48:56,263 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2971
+ 2025-10-15 15:48:56,263 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2972
+ 2025-10-15 15:48:56,263 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2973
+ 2025-10-15 15:48:56,812 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2974
+ 2025-10-15 15:48:56,857 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2975
+ 2025-10-15 15:48:56,857 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2976
+ 2025-10-15 15:48:57,268 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2977
+ 2025-10-15 15:48:57,268 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2978
+ 2025-10-15 15:48:57,268 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
2979
+ 2025-10-15 15:48:57,269 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
2980
+ 2025-10-15 15:48:57,269 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
2981
+ 2025-10-15 15:48:58,999 - AgenticMedicalRAG - INFO - LLM initialized successfully
2982
+ 2025-10-15 15:48:59,000 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
2983
+ 2025-10-15 15:48:59,000 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
2984
+ 2025-10-15 16:00:25,963 - AgenticMedicalRAG - INFO - Configuration validation completed
2985
+ 2025-10-15 16:00:27,014 - AgenticMedicalRAG - INFO - πŸš€ Starting background initialization...
2986
+ 2025-10-15 16:00:27,015 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Starting background initialization... (0%)
2987
+ 2025-10-15 16:00:27,015 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Loading embedding model... (10%)
2988
+ 2025-10-15 16:00:27,016 - AgenticMedicalRAG - INFO - Loading embedding model (first time)...
2989
+ 2025-10-15 16:00:35,116 - AgenticMedicalRAG - INFO - Embedding model loaded successfully
2990
+ 2025-10-15 16:00:35,117 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Embedding model loaded successfully (40%)
2991
+ 2025-10-15 16:00:35,117 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Initializing retrievers and loading chunks... (50%)
2992
+ 2025-10-15 16:00:35,117 - AgenticMedicalRAG - INFO - πŸ”„ Initializing retrievers (first time use)...
2993
+ 2025-10-15 16:00:35,117 - AgenticMedicalRAG - INFO - πŸ”„ Processing new data and updating vector store if needed...
2994
+ 2025-10-15 16:00:35,207 - AgenticMedicalRAG - INFO - πŸ“¦ Loading chunks cache for BM25 retriever...
2995
+ 2025-10-15 16:00:35,225 - AgenticMedicalRAG - INFO - πŸ” Creating vector retriever...
2996
+ 2025-10-15 16:00:35,225 - AgenticMedicalRAG - INFO - πŸ“ Creating BM25 retriever...
2997
+ 2025-10-15 16:00:35,521 - AgenticMedicalRAG - INFO - πŸ”„ Creating hybrid retriever...
2998
+ 2025-10-15 16:00:35,522 - AgenticMedicalRAG - INFO - βœ… Retrievers initialized successfully.
2999
+ 2025-10-15 16:00:35,522 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Retrievers initialized successfully (90%)
3000
+ 2025-10-15 16:00:35,522 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: Warming up LLM... (95%)
3001
+ 2025-10-15 16:00:35,522 - AgenticMedicalRAG - INFO - Initializing LLM (first time)...
3002
+ 2025-10-15 16:00:36,475 - AgenticMedicalRAG - INFO - LLM initialized successfully
3003
+ 2025-10-15 16:00:36,475 - AgenticMedicalRAG - INFO - πŸ”„ Background Init: All components initialized successfully (100%)
3004
+ 2025-10-15 16:00:36,475 - AgenticMedicalRAG - INFO - βœ… Background initialization completed successfully
3005
+ 2025-10-15 16:00:59,757 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): hi...
3006
+ 2025-10-15 16:01:02,437 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
3007
+ 2025-10-15 16:01:02,437 - AgenticMedicalRAG - INFO - Skipping validation: insufficient context
3008
+ 2025-10-15 16:01:02,438 - AgenticMedicalRAG - INFO - Successfully processed user input: hi...
3009
+ 2025-10-15 16:01:04,703 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): What is the role of durvalumab in stage III NSCLC ...
3010
+ 2025-10-15 16:01:11,862 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
3011
+ 2025-10-15 16:01:13,014 - AgenticMedicalRAG - INFO - Medical answer validator initialized successfully
3012
+ 2025-10-15 16:01:13,015 - AgenticMedicalRAG - INFO - GitHub storage initialized for MoazEldsouky/cloud-data-store
3013
+ 2025-10-15 16:01:13,844 - AgenticMedicalRAG - INFO - Starting validation for interaction 39
3014
+ 2025-10-15 16:01:27,985 - AgenticMedicalRAG - INFO - Assigned unique interaction ID: 39
3015
+ 2025-10-15 16:01:31,979 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/evaluation_results.json to GitHub
3016
+ 2025-10-15 16:01:31,980 - AgenticMedicalRAG - INFO - Evaluation saved to GitHub with ID: 39
3017
+ 2025-10-15 16:01:31,980 - AgenticMedicalRAG - INFO - Background validation completed - Interaction ID: 39
3018
+ 2025-10-15 16:01:31,980 - AgenticMedicalRAG - INFO - Validation scores - Overall: 90/100, Accuracy: 95/100, Coherence: 90/100, Relevance: 88/100
3019
+ 2025-10-15 16:01:31,981 - AgenticMedicalRAG - INFO - Successfully processed user input: What is the role of durvalumab in stage III NSCLC ...
3020
+ 2025-10-15 17:12:17,907 - AgenticMedicalRAG - INFO - Processing user input (attempt 1): What first-line systemic therapy does ASCO recomme...
3021
+ 2025-10-15 17:12:24,603 - AgenticMedicalRAG - INFO - Performing background validation for streaming response...
3022
+ 2025-10-15 17:12:25,574 - AgenticMedicalRAG - INFO - Starting validation for interaction 40
3023
+ 2025-10-15 17:12:34,757 - AgenticMedicalRAG - INFO - Assigned unique interaction ID: 40
3024
+ 2025-10-15 17:12:39,210 - AgenticMedicalRAG - INFO - Successfully uploaded medical_data/evaluation_results.json to GitHub
3025
+ 2025-10-15 17:12:39,211 - AgenticMedicalRAG - INFO - Evaluation saved to GitHub with ID: 40
3026
+ 2025-10-15 17:12:39,212 - AgenticMedicalRAG - INFO - Background validation completed - Interaction ID: 40
3027
+ 2025-10-15 17:12:39,212 - AgenticMedicalRAG - INFO - Validation scores - Overall: 90/100, Accuracy: 95/100, Coherence: 90/100, Relevance: 88/100
3028
+ 2025-10-15 17:12:39,212 - AgenticMedicalRAG - INFO - Successfully processed user input: What first-line systemic therapy does ASCO recomme...
requirements.txt CHANGED
@@ -31,3 +31,8 @@ rank-bm25==0.2.2
31
  numpy<2
32
  torch==2.2.2+cpu
33
  --extra-index-url https://download.pytorch.org/whl/cpu
 
 
 
 
 
 
31
  numpy<2
32
  torch==2.2.2+cpu
33
  --extra-index-url https://download.pytorch.org/whl/cpu
34
+
35
+ # Document generation
36
+ python-docx==1.1.2
37
+ reportlab==4.2.5
38
+