subhash4face commited on
Commit
dbbbc60
Β·
verified Β·
1 Parent(s): 8d69194
Files changed (1) hide show
  1. app.py +40 -14
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
- # Detailed human-readable
282
- lines = [f"πŸ”§ Tool: {tool_name}", f"🎯 Why: {reason}", f"βš™οΈ Backend: {backend}"]
 
 
 
283
  if duration is not None:
284
- lines.append(f"⏱ Duration: {duration:.2f}s")
 
 
 
 
285
  lines.append(f"πŸ“ Output: {str(output)}")
286
- return "
287
- ".join(lines)
 
 
 
288
  if style == "C":
289
- # Ultra-visual
290
- s = f"πŸ”§ {tool_name} β€’ Reason: {reason} β€’ Backend: {backend}"
 
 
 
291
  if duration is not None:
292
- s += f" β€’ {duration:.2f}s"
293
- s += f"
294
- β†’ {str(output)}"
295
- return s
296
- # D -> both
 
 
 
 
 
 
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: