Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ from txagent.txagent import TxAgent
|
|
| 37 |
MAX_MODEL_TOKENS = 131072
|
| 38 |
MAX_NEW_TOKENS = 4096
|
| 39 |
MAX_CHUNK_TOKENS = 8192
|
| 40 |
-
BATCH_SIZE =
|
| 41 |
PROMPT_OVERHEAD = 300
|
| 42 |
SAFE_SLEEP = 0.5
|
| 43 |
|
|
@@ -263,8 +263,8 @@ def generate_pdf_report_with_charts(summary: str, report_path: str, detailed_bat
|
|
| 263 |
pdf.ln(5)
|
| 264 |
for idx, detail in enumerate(detailed_batches):
|
| 265 |
pdf.multi_cell(0, 10, txt=f"Tool Result #{idx + 1}", align="L")
|
| 266 |
-
for line in remove_non_ascii(detail).split("
|
| 267 |
-
|
| 268 |
pdf.multi_cell(0, 10, txt=line)
|
| 269 |
pdf.ln(5)
|
| 270 |
pdf.output(pdf_path)
|
|
@@ -289,6 +289,7 @@ def process_report(agent, file, messages: List[Dict[str, str]]) -> Tuple[List[Di
|
|
| 289 |
messages.append({"role": "assistant", "content": f"π Split into {len(batches)} batches. Analyzing..."})
|
| 290 |
|
| 291 |
batch_results = analyze_batches(agent, batches)
|
|
|
|
| 292 |
valid = [res for res in batch_results if not res.startswith("β")]
|
| 293 |
|
| 294 |
if not valid:
|
|
@@ -301,7 +302,7 @@ def process_report(agent, file, messages: List[Dict[str, str]]) -> Tuple[List[Di
|
|
| 301 |
with open(report_path, 'w', encoding='utf-8') as f:
|
| 302 |
f.write(f"# Final Medical Report\n\n{summary}")
|
| 303 |
|
| 304 |
-
pdf_path = generate_pdf_report_with_charts(summary, report_path, detailed_batches=
|
| 305 |
|
| 306 |
end_time = time.time()
|
| 307 |
elapsed_time = end_time - start_time
|
|
|
|
| 37 |
MAX_MODEL_TOKENS = 131072
|
| 38 |
MAX_NEW_TOKENS = 4096
|
| 39 |
MAX_CHUNK_TOKENS = 8192
|
| 40 |
+
BATCH_SIZE = 1
|
| 41 |
PROMPT_OVERHEAD = 300
|
| 42 |
SAFE_SLEEP = 0.5
|
| 43 |
|
|
|
|
| 263 |
pdf.ln(5)
|
| 264 |
for idx, detail in enumerate(detailed_batches):
|
| 265 |
pdf.multi_cell(0, 10, txt=f"Tool Result #{idx + 1}", align="L")
|
| 266 |
+
for line in remove_non_ascii(detail).split("
|
| 267 |
+
"):
|
| 268 |
pdf.multi_cell(0, 10, txt=line)
|
| 269 |
pdf.ln(5)
|
| 270 |
pdf.output(pdf_path)
|
|
|
|
| 289 |
messages.append({"role": "assistant", "content": f"π Split into {len(batches)} batches. Analyzing..."})
|
| 290 |
|
| 291 |
batch_results = analyze_batches(agent, batches)
|
| 292 |
+
all_tool_outputs = batch_results.copy()
|
| 293 |
valid = [res for res in batch_results if not res.startswith("β")]
|
| 294 |
|
| 295 |
if not valid:
|
|
|
|
| 302 |
with open(report_path, 'w', encoding='utf-8') as f:
|
| 303 |
f.write(f"# Final Medical Report\n\n{summary}")
|
| 304 |
|
| 305 |
+
pdf_path = generate_pdf_report_with_charts(summary, report_path, detailed_batches=all_tool_outputs)
|
| 306 |
|
| 307 |
end_time = time.time()
|
| 308 |
elapsed_time = end_time - start_time
|