Update app.py
Browse files
app.py
CHANGED
@@ -151,7 +151,14 @@ def process_final_report(agent, file, chatbot_state: List[Dict[str, str]]) -> Tu
|
|
151 |
call_agent=False,
|
152 |
conversation=[],
|
153 |
):
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
except Exception as e:
|
156 |
return index, f"❌ Error analyzing chunk {index+1}: {str(e)}"
|
157 |
return index, clean_response(response)
|
@@ -183,7 +190,14 @@ def process_final_report(agent, file, chatbot_state: List[Dict[str, str]]) -> Tu
|
|
183 |
call_agent=False,
|
184 |
conversation=[],
|
185 |
):
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
cleaned = clean_response(final_report_text)
|
189 |
report_path = os.path.join(report_dir, f"report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md")
|
@@ -200,32 +214,38 @@ def process_final_report(agent, file, chatbot_state: List[Dict[str, str]]) -> Tu
|
|
200 |
|
201 |
def create_ui(agent):
|
202 |
with gr.Blocks(css="""
|
203 |
-
.gradio-container {
|
204 |
-
|
205 |
-
|
|
|
|
|
206 |
font-family: 'Segoe UI', sans-serif;
|
207 |
-
background-color: #
|
208 |
}
|
209 |
.gr-button.primary {
|
210 |
-
background: linear-gradient(to right, #
|
211 |
color: white;
|
212 |
-
|
213 |
-
border-radius:
|
214 |
}
|
215 |
.gr-chatbot, .gr-markdown, .gr-file-upload {
|
216 |
background-color: white;
|
217 |
border-radius: 10px;
|
218 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
219 |
}
|
220 |
""") as demo:
|
221 |
gr.Markdown("""
|
222 |
-
<h2 style='color:#
|
223 |
-
<p>Upload
|
224 |
""")
|
225 |
|
226 |
with gr.Row():
|
227 |
with gr.Column(scale=3):
|
228 |
-
chatbot = gr.Chatbot(label="Clinical Assistant", height=
|
229 |
with gr.Column(scale=1):
|
230 |
file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
231 |
analyze_btn = gr.Button("🧠 Analyze", variant="primary")
|
|
|
151 |
call_agent=False,
|
152 |
conversation=[],
|
153 |
):
|
154 |
+
if isinstance(result, str):
|
155 |
+
response += result
|
156 |
+
elif isinstance(result, list):
|
157 |
+
for r in result:
|
158 |
+
if hasattr(r, "content"):
|
159 |
+
response += r.content
|
160 |
+
elif hasattr(result, "content"):
|
161 |
+
response += result.content
|
162 |
except Exception as e:
|
163 |
return index, f"❌ Error analyzing chunk {index+1}: {str(e)}"
|
164 |
return index, clean_response(response)
|
|
|
190 |
call_agent=False,
|
191 |
conversation=[],
|
192 |
):
|
193 |
+
if isinstance(result, str):
|
194 |
+
final_report_text += result
|
195 |
+
elif isinstance(result, list):
|
196 |
+
for r in result:
|
197 |
+
if hasattr(r, "content"):
|
198 |
+
final_report_text += r.content
|
199 |
+
elif hasattr(result, "content"):
|
200 |
+
final_report_text += result.content
|
201 |
|
202 |
cleaned = clean_response(final_report_text)
|
203 |
report_path = os.path.join(report_dir, f"report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md")
|
|
|
214 |
|
215 |
def create_ui(agent):
|
216 |
with gr.Blocks(css="""
|
217 |
+
html, body, .gradio-container {
|
218 |
+
height: 100% !important;
|
219 |
+
width: 100% !important;
|
220 |
+
margin: 0;
|
221 |
+
padding: 0;
|
222 |
font-family: 'Segoe UI', sans-serif;
|
223 |
+
background-color: #f0f2f5;
|
224 |
}
|
225 |
.gr-button.primary {
|
226 |
+
background: linear-gradient(to right, #5c6bc0, #3949ab);
|
227 |
color: white;
|
228 |
+
font-weight: bold;
|
229 |
+
border-radius: 6px;
|
230 |
}
|
231 |
.gr-chatbot, .gr-markdown, .gr-file-upload {
|
232 |
background-color: white;
|
233 |
border-radius: 10px;
|
234 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
235 |
+
}
|
236 |
+
.gr-chatbot {
|
237 |
+
border-left: 4px solid #5c6bc0;
|
238 |
+
padding: 0.5rem;
|
239 |
}
|
240 |
""") as demo:
|
241 |
gr.Markdown("""
|
242 |
+
<h2 style='color:#3949ab; margin-bottom: 0.5em;'>🏥 Patient History Analysis Tool</h2>
|
243 |
+
<p style='color:#333; font-size: 1rem;'>Upload an Excel file to receive a structured, professional diagnostic summary.</p>
|
244 |
""")
|
245 |
|
246 |
with gr.Row():
|
247 |
with gr.Column(scale=3):
|
248 |
+
chatbot = gr.Chatbot(label="Clinical Assistant", height=650, type="messages")
|
249 |
with gr.Column(scale=1):
|
250 |
file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
251 |
analyze_btn = gr.Button("🧠 Analyze", variant="primary")
|