Update ui/ui_core.py
Browse files- ui/ui_core.py +6 -11
ui/ui_core.py
CHANGED
@@ -17,14 +17,12 @@ def clean_final_response(text: str) -> str:
|
|
17 |
cleaned = text.replace("[TOOL_CALLS]", "").strip()
|
18 |
sections = cleaned.split("[Final Analysis]")
|
19 |
if len(sections) > 1:
|
|
|
20 |
return (
|
21 |
-
f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;margin-bottom:1em;color:#fff;background:#353F54;'>"
|
22 |
-
f"<h3 style='margin-top:0;color:#37B6E9;'>📝 Summary</h3><p>{sections[0].strip()}</p></div>"
|
23 |
f"<div style='padding:1em;border:2px solid #4B4CED;background:#242C3B;border-radius:12px;color:#fff;'>"
|
24 |
f"<h3 style='margin-top:0;color:#37B6E9;'>🧠 Final Analysis</h3>"
|
25 |
-
f"<ul style='
|
26 |
-
|
27 |
-
"</ul></div>"
|
28 |
)
|
29 |
return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
|
30 |
|
@@ -41,14 +39,11 @@ def extract_all_text_from_csv_or_excel(file_path: str, progress=None, index=0, t
|
|
41 |
elif file_path.endswith((".xls", ".xlsx")):
|
42 |
try:
|
43 |
df = pd.read_excel(file_path, engine="openpyxl")
|
44 |
-
except
|
45 |
df = pd.read_excel(file_path, engine="xlrd")
|
46 |
else:
|
47 |
return f"Unsupported spreadsheet format: {file_path}"
|
48 |
|
49 |
-
if df.empty:
|
50 |
-
return f"[Warning] {os.path.basename(file_path)} is empty or has no readable data."
|
51 |
-
|
52 |
lines = []
|
53 |
for _, row in df.iterrows():
|
54 |
line = " | ".join(str(cell) for cell in row if pd.notna(cell))
|
@@ -118,7 +113,7 @@ def create_ui(agent: TxAgent):
|
|
118 |
"Provide a **detailed and structured response**, including examples, supporting evidence from the form, and clinical rationale for why these items matter. "
|
119 |
"Ensure the output is informative and helpful for improving patient care. "
|
120 |
"Do not hallucinate. Base the response only on the provided form content. "
|
121 |
-
"End with a section labeled '
|
122 |
)
|
123 |
|
124 |
try:
|
@@ -198,4 +193,4 @@ def create_ui(agent: TxAgent):
|
|
198 |
["Is there anything abnormal in the attached blood work report?"]
|
199 |
], inputs=message_input)
|
200 |
|
201 |
-
return demo
|
|
|
17 |
cleaned = text.replace("[TOOL_CALLS]", "").strip()
|
18 |
sections = cleaned.split("[Final Analysis]")
|
19 |
if len(sections) > 1:
|
20 |
+
final = sections[1].strip()
|
21 |
return (
|
|
|
|
|
22 |
f"<div style='padding:1em;border:2px solid #4B4CED;background:#242C3B;border-radius:12px;color:#fff;'>"
|
23 |
f"<h3 style='margin-top:0;color:#37B6E9;'>🧠 Final Analysis</h3>"
|
24 |
+
f"<ul><li style='margin-bottom:0.75em;'>{final.replace(chr(10), '</li><li style=\'margin-bottom:0.75em;\'>')}</li></ul>"
|
25 |
+
f"</div>"
|
|
|
26 |
)
|
27 |
return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
|
28 |
|
|
|
39 |
elif file_path.endswith((".xls", ".xlsx")):
|
40 |
try:
|
41 |
df = pd.read_excel(file_path, engine="openpyxl")
|
42 |
+
except:
|
43 |
df = pd.read_excel(file_path, engine="xlrd")
|
44 |
else:
|
45 |
return f"Unsupported spreadsheet format: {file_path}"
|
46 |
|
|
|
|
|
|
|
47 |
lines = []
|
48 |
for _, row in df.iterrows():
|
49 |
line = " | ".join(str(cell) for cell in row if pd.notna(cell))
|
|
|
113 |
"Provide a **detailed and structured response**, including examples, supporting evidence from the form, and clinical rationale for why these items matter. "
|
114 |
"Ensure the output is informative and helpful for improving patient care. "
|
115 |
"Do not hallucinate. Base the response only on the provided form content. "
|
116 |
+
"End with a section labeled '[Final Analysis]' where you summarize key findings the doctor may have missed."
|
117 |
)
|
118 |
|
119 |
try:
|
|
|
193 |
["Is there anything abnormal in the attached blood work report?"]
|
194 |
], inputs=message_input)
|
195 |
|
196 |
+
return demo
|