archivartaunik commited on
Commit
e42ffa0
·
verified ·
1 Parent(s): 1b3fc01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -286,8 +286,9 @@ def ui_fetch_calls(date_str: str):
286
  body = e.response.text[:800]
287
  except Exception:
288
  pass
289
- return pd.DataFrame(), gr.update(choices=[], value=None), f"HTTP error: {e}
290
- {body}"
 
291
  except Exception as e:
292
  return pd.DataFrame(), gr.update(choices=[], value=None), f"Load error: {e}"
293
 
@@ -306,7 +307,7 @@ def ui_play_audio(selected_idx: Optional[int], df: pd.DataFrame):
306
  # Download only if not exists (avoid re-fetch)
307
  if not os.path.exists(fpath) or os.path.getsize(fpath) == 0:
308
  fpath, url_used = fetch_mp3_by_unique_id(unique_id)
309
- html = f'URL: <a href="{url_used}" target="_blank">{url_used}</a>'
310
  return html, fpath, fpath, "Ready ✅"
311
  except requests.HTTPError as e:
312
  body = ""
@@ -390,9 +391,7 @@ def ui_analyze(selected_idx: Optional[int], df: pd.DataFrame,
390
  msg = str(e)
391
  try:
392
  if hasattr(e, "args") and e.args:
393
- msg = msg + "
394
-
395
- " + str(e.args[0])
396
  except Exception:
397
  pass
398
  return f"Error during model call: {msg}"
@@ -613,9 +612,7 @@ def ui_analyze_calls_by_date(
613
  return (info, None, info, gr.update())
614
 
615
  # Save to .txt and return
616
- results_text = "
617
-
618
- ".join(results_blocks)
619
  fname = f"/tmp/batch_analysis_{(date_str or _today_str()).strip()}_{t_from.replace(':','')}-{t_to.replace(':','')}_{int(time.time())}.txt"
620
  with open(fname, "w", encoding="utf-8") as f:
621
  f.write(results_text)
 
286
  body = e.response.text[:800]
287
  except Exception:
288
  pass
289
+ # CORRECTED LINE: Use triple quotes for multi-line f-string
290
+ return pd.DataFrame(), gr.update(choices=[], value=None), f"""HTTP error: {e}
291
+ {body}"""
292
  except Exception as e:
293
  return pd.DataFrame(), gr.update(choices=[], value=None), f"Load error: {e}"
294
 
 
307
  # Download only if not exists (avoid re-fetch)
308
  if not os.path.exists(fpath) or os.path.getsize(fpath) == 0:
309
  fpath, url_used = fetch_mp3_by_unique_id(unique_id)
310
+ html = f'<a href="{url_used}" target="_blank">Recording URL</a>'
311
  return html, fpath, fpath, "Ready ✅"
312
  except requests.HTTPError as e:
313
  body = ""
 
391
  msg = str(e)
392
  try:
393
  if hasattr(e, "args") and e.args:
394
+ msg = msg + "\n\n" + str(e.args[0])
 
 
395
  except Exception:
396
  pass
397
  return f"Error during model call: {msg}"
 
612
  return (info, None, info, gr.update())
613
 
614
  # Save to .txt and return
615
+ results_text = "\n\n".join(results_blocks)
 
 
616
  fname = f"/tmp/batch_analysis_{(date_str or _today_str()).strip()}_{t_from.replace(':','')}-{t_to.replace(':','')}_{int(time.time())}.txt"
617
  with open(fname, "w", encoding="utf-8") as f:
618
  f.write(results_text)