Ali2206 commited on
Commit
5450461
·
verified ·
1 Parent(s): aeab9ad

Update ui/ui_core.py

Browse files
Files changed (1) hide show
  1. ui/ui_core.py +15 -10
ui/ui_core.py CHANGED
@@ -15,17 +15,22 @@ def sanitize_utf8(text: str) -> str:
15
 
16
  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
- final = sections[1].strip()
21
- formatted_final = final.replace("\n", "</li><li style='margin-bottom:0.75em;'>")
22
- return (
23
- "<div style='padding:1em;border:2px solid #4B4CED;background:#242C3B;border-radius:12px;color:#fff;'>"
24
- "<h3 style='margin-top:0;color:#37B6E9;'>🧠 Final Analysis</h3>"
25
- f"<ul><li style='margin-bottom:0.75em;'>{formatted_final}</li></ul>"
26
- "</div>"
 
 
 
 
 
27
  )
28
- return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
29
 
30
  def extract_all_text_from_csv_or_excel(file_path: str, progress=None, index=0, total=1) -> str:
31
  try:
 
15
 
16
  def clean_final_response(text: str) -> str:
17
  cleaned = text.replace("[TOOL_CALLS]", "").strip()
18
+ responses = cleaned.split("[Final Analysis]")
19
+
20
+ if len(responses) <= 1:
21
+ return f"<div style='padding:1em;border:1px solid #ccc;border-radius:12px;color:#fff;background:#353F54;'><p>{cleaned}</p></div>"
22
+
23
+ # Support multiple [Final Analysis] sections
24
+ panels = []
25
+ for i, section in enumerate(responses[1:], 1):
26
+ final = section.strip()
27
+ panels.append(
28
+ f"<details style='background:#242C3B;color:#fff;border-radius:12px;margin-bottom:1em;border:1px solid #4B4CED;'>"
29
+ f"<summary style='font-size:1.1em;font-weight:bold;padding:0.75em;background:#4B4CED;color:#fff;border-radius:12px 12px 0 0;'>🧠 Final Analysis #{i}</summary>"
30
+ f"<div style='padding:1em;line-height:1.6;'>{final.replace(chr(10), '<br>')}</div>"
31
+ f"</details>"
32
  )
33
+ return "".join(panels)
34
 
35
  def extract_all_text_from_csv_or_excel(file_path: str, progress=None, index=0, total=1) -> str:
36
  try: