Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
9 |
import hashlib
|
10 |
import shutil
|
11 |
import time
|
12 |
-
from functools import lru_cache
|
13 |
from threading import Thread
|
14 |
import re
|
15 |
import tempfile
|
@@ -19,7 +18,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
19 |
src_path = os.path.abspath(os.path.join(current_dir, "src"))
|
20 |
sys.path.insert(0, src_path)
|
21 |
|
22 |
-
# Cache directories
|
23 |
base_dir = "/data"
|
24 |
model_cache_dir = os.path.join(base_dir, "txagent_models")
|
25 |
tool_cache_dir = os.path.join(base_dir, "tool_cache")
|
@@ -148,10 +146,6 @@ def create_ui(agent: TxAgent):
|
|
148 |
|
149 |
def analyze_potential_oversights(message: str, history: list, conversation: list, files: list):
|
150 |
try:
|
151 |
-
history.append({"role": "user", "content": message})
|
152 |
-
history.append({"role": "assistant", "content": "⏳ Analyzing records for potential oversights..."})
|
153 |
-
yield history, None
|
154 |
-
|
155 |
extracted_data = ""
|
156 |
file_hash_value = ""
|
157 |
|
@@ -190,18 +184,23 @@ Medical Records:\n{extracted_data[:15000]}
|
|
190 |
if not cleaned:
|
191 |
cleaned = "No clear oversights identified. Recommend comprehensive review."
|
192 |
|
|
|
|
|
|
|
|
|
|
|
193 |
report_path = None
|
194 |
if file_hash_value:
|
195 |
possible_report = os.path.join(report_dir, f"{file_hash_value}_report.txt")
|
196 |
if os.path.exists(possible_report):
|
197 |
report_path = possible_report
|
198 |
|
199 |
-
|
200 |
-
yield history, report_path
|
201 |
|
202 |
except Exception as e:
|
203 |
-
history
|
204 |
-
|
|
|
205 |
|
206 |
inputs = [msg_input, chatbot, conversation_state, file_upload]
|
207 |
outputs = [chatbot, download_output]
|
|
|
9 |
import hashlib
|
10 |
import shutil
|
11 |
import time
|
|
|
12 |
from threading import Thread
|
13 |
import re
|
14 |
import tempfile
|
|
|
18 |
src_path = os.path.abspath(os.path.join(current_dir, "src"))
|
19 |
sys.path.insert(0, src_path)
|
20 |
|
|
|
21 |
base_dir = "/data"
|
22 |
model_cache_dir = os.path.join(base_dir, "txagent_models")
|
23 |
tool_cache_dir = os.path.join(base_dir, "tool_cache")
|
|
|
146 |
|
147 |
def analyze_potential_oversights(message: str, history: list, conversation: list, files: list):
|
148 |
try:
|
|
|
|
|
|
|
|
|
149 |
extracted_data = ""
|
150 |
file_hash_value = ""
|
151 |
|
|
|
184 |
if not cleaned:
|
185 |
cleaned = "No clear oversights identified. Recommend comprehensive review."
|
186 |
|
187 |
+
updated_history = history + [
|
188 |
+
{"role": "user", "content": message},
|
189 |
+
{"role": "assistant", "content": cleaned}
|
190 |
+
]
|
191 |
+
|
192 |
report_path = None
|
193 |
if file_hash_value:
|
194 |
possible_report = os.path.join(report_dir, f"{file_hash_value}_report.txt")
|
195 |
if os.path.exists(possible_report):
|
196 |
report_path = possible_report
|
197 |
|
198 |
+
yield updated_history, report_path
|
|
|
199 |
|
200 |
except Exception as e:
|
201 |
+
updated_history = history + [{"role": "user", "content": message},
|
202 |
+
{"role": "assistant", "content": f"❌ Analysis failed: {str(e)}"}]
|
203 |
+
yield updated_history, None
|
204 |
|
205 |
inputs = [msg_input, chatbot, conversation_state, file_upload]
|
206 |
outputs = [chatbot, download_output]
|