Spaces:
Sleeping
Sleeping
fix
Browse files
app.py
CHANGED
|
@@ -274,29 +274,55 @@ app_theme = {
|
|
| 274 |
def format_tool_log(tool_name, reason, meta, output, style="A"):
|
| 275 |
backend = meta.get("backend") if meta else "unknown"
|
| 276 |
duration = meta.get("duration") if meta else None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
if style == "A":
|
| 278 |
-
# Simple
|
| 279 |
return f"[{tool_name}] {backend} -> {str(output)[:200]}"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
if style == "B":
|
| 281 |
-
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
| 283 |
if duration is not None:
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
lines.append(f"π Output: {str(output)}")
|
| 286 |
-
return "
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
| 288 |
if style == "C":
|
| 289 |
-
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
| 291 |
if duration is not None:
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
return {
|
| 298 |
"simple": f"[{tool_name}] {backend} -> {str(output)[:200]}",
|
| 299 |
-
"detailed": format_tool_log(tool_name, reason, meta, output, style="B")
|
| 300 |
}
|
| 301 |
|
| 302 |
with gr.Blocks(css=".gradio-container {background:#f7fafc}") as demo:
|
|
|
|
| 274 |
def format_tool_log(tool_name, reason, meta, output, style="A"):
|
| 275 |
backend = meta.get("backend") if meta else "unknown"
|
| 276 |
duration = meta.get("duration") if meta else None
|
| 277 |
+
|
| 278 |
+
# ---------------------------
|
| 279 |
+
# Style A: Simple
|
| 280 |
+
# ---------------------------
|
| 281 |
if style == "A":
|
|
|
|
| 282 |
return f"[{tool_name}] {backend} -> {str(output)[:200]}"
|
| 283 |
+
|
| 284 |
+
# ---------------------------
|
| 285 |
+
# Style B: Detailed Human-Readable
|
| 286 |
+
# ---------------------------
|
| 287 |
if style == "B":
|
| 288 |
+
lines = [
|
| 289 |
+
f"π§ Tool: {tool_name}",
|
| 290 |
+
f"π― Why: {reason}",
|
| 291 |
+
f"βοΈ Backend: {backend}",
|
| 292 |
+
]
|
| 293 |
if duration is not None:
|
| 294 |
+
try:
|
| 295 |
+
lines.append(f"β± Duration: {float(duration):.2f}s")
|
| 296 |
+
except:
|
| 297 |
+
lines.append(f"β± Duration: {duration}")
|
| 298 |
+
|
| 299 |
lines.append(f"π Output: {str(output)}")
|
| 300 |
+
return "\n".join(lines)
|
| 301 |
+
|
| 302 |
+
# ---------------------------
|
| 303 |
+
# Style C: Ultra-visual
|
| 304 |
+
# ---------------------------
|
| 305 |
if style == "C":
|
| 306 |
+
parts = [
|
| 307 |
+
f"π§ {tool_name}",
|
| 308 |
+
f"β’ Reason: {reason}",
|
| 309 |
+
f"β’ Backend: {backend}",
|
| 310 |
+
]
|
| 311 |
if duration is not None:
|
| 312 |
+
try:
|
| 313 |
+
parts.append(f"β’ {float(duration):.2f}s")
|
| 314 |
+
except:
|
| 315 |
+
parts.append(f"β’ {duration}")
|
| 316 |
+
|
| 317 |
+
visual = " ".join(parts) + "\n" + f"β {str(output)}"
|
| 318 |
+
return visual
|
| 319 |
+
|
| 320 |
+
# ---------------------------
|
| 321 |
+
# Style D: Both Simple + Detailed
|
| 322 |
+
# ---------------------------
|
| 323 |
return {
|
| 324 |
"simple": f"[{tool_name}] {backend} -> {str(output)[:200]}",
|
| 325 |
+
"detailed": format_tool_log(tool_name, reason, meta, output, style="B"),
|
| 326 |
}
|
| 327 |
|
| 328 |
with gr.Blocks(css=".gradio-container {background:#f7fafc}") as demo:
|