Ali2206 commited on
Commit
3795cb9
·
verified ·
1 Parent(s): 9a76893

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -21,7 +21,8 @@ for d in [model_cache_dir, tool_cache_dir, report_dir]:
21
  os.environ["HF_HOME"] = model_cache_dir
22
  os.environ["TRANSFORMERS_CACHE"] = model_cache_dir
23
 
24
- sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "src"))
 
25
  from txagent.txagent import TxAgent
26
 
27
  MAX_MODEL_TOKENS = 32768
@@ -92,7 +93,7 @@ def init_agent():
92
  agent.init_model()
93
  return agent
94
 
95
- def process_final_report(agent, file, chatbot_state: List[Tuple[str, str]]) -> Tuple[List[Tuple[str, str]], str]:
96
  messages = chatbot_state.copy() if chatbot_state else []
97
 
98
  if file is None:
@@ -127,7 +128,6 @@ def process_final_report(agent, file, chatbot_state: List[Tuple[str, str]]) -> T
127
  cleaned = clean_response(response)
128
  full_report.append(cleaned)
129
 
130
- # Update progress in chat
131
  progress_msg = f"✅ Analyzed section {i}/{len(chunks)}"
132
  if len(messages) > 2 and "Analyzed section" in messages[-1][1]:
133
  messages[-1] = ("assistant", progress_msg)
@@ -135,7 +135,6 @@ def process_final_report(agent, file, chatbot_state: List[Tuple[str, str]]) -> T
135
  messages.append(("assistant", progress_msg))
136
  yield messages, None
137
 
138
- # Generate final report
139
  final_report = "## 🧠 Final Clinical Report\n\n" + "\n\n".join(full_report)
140
  report_path = os.path.join(report_dir, f"report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md")
141
  with open(report_path, 'w') as f:
@@ -200,9 +199,11 @@ def create_ui(agent):
200
  Upload clinical Excel records below and click **Analyze** to generate a medical summary.
201
  """)
202
 
 
 
 
 
203
  chatbot = gr.Chatbot(label="Chatbot", elem_classes="chatbot")
204
- file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
205
- analyze_btn = gr.Button("Analyze")
206
  report_output = gr.File(label="Download Report", visible=False)
207
  chatbot_state = gr.State([])
208
 
 
21
  os.environ["HF_HOME"] = model_cache_dir
22
  os.environ["TRANSFORMERS_CACHE"] = model_cache_dir
23
 
24
+ # Fixed the syntax error in this line:
25
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
26
  from txagent.txagent import TxAgent
27
 
28
  MAX_MODEL_TOKENS = 32768
 
93
  agent.init_model()
94
  return agent
95
 
96
+ def process_final_report(agent, file, chatbot_state: List[Tuple[str, str]]):
97
  messages = chatbot_state.copy() if chatbot_state else []
98
 
99
  if file is None:
 
128
  cleaned = clean_response(response)
129
  full_report.append(cleaned)
130
 
 
131
  progress_msg = f"✅ Analyzed section {i}/{len(chunks)}"
132
  if len(messages) > 2 and "Analyzed section" in messages[-1][1]:
133
  messages[-1] = ("assistant", progress_msg)
 
135
  messages.append(("assistant", progress_msg))
136
  yield messages, None
137
 
 
138
  final_report = "## 🧠 Final Clinical Report\n\n" + "\n\n".join(full_report)
139
  report_path = os.path.join(report_dir, f"report_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md")
140
  with open(report_path, 'w') as f:
 
199
  Upload clinical Excel records below and click **Analyze** to generate a medical summary.
200
  """)
201
 
202
+ with gr.Row():
203
+ file_upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
204
+ analyze_btn = gr.Button("Analyze", variant="primary")
205
+
206
  chatbot = gr.Chatbot(label="Chatbot", elem_classes="chatbot")
 
 
207
  report_output = gr.File(label="Download Report", visible=False)
208
  chatbot_state = gr.State([])
209