turtle170 commited on
Commit
9598592
Β·
verified Β·
1 Parent(s): 3d77e8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -58,8 +58,8 @@ class BackendProcessor:
58
 
59
  # Try with authentication if available
60
  client_kwargs = {}
61
- if HF_TOKEN:
62
- client_kwargs["hf_token"] = HF_TOKEN
63
 
64
  start_time = time.time()
65
  self.client = Client(url, **client_kwargs)
@@ -1798,18 +1798,18 @@ with gr.Blocks(title="ZeroEngine V0.2") as demo:
1798
  def on_scan(repo):
1799
  try:
1800
  if not repo:
1801
- return gr.update(choices=[], value=None), "⚠️ Please enter a repository ID"
1802
 
1803
  logger.info(f"Scanning repository: {repo}")
1804
  files = kernel.list_ggufs(repo)
1805
 
1806
  if not files:
1807
- return gr.update(choices=[], value=None), f"❌ No GGUFs found in {repo}"
1808
 
1809
  return gr.update(choices=files, value=files[0]), f"βœ… Found {len(files)} GGUF file(s)"
1810
  except Exception as e:
1811
  logger.error(f"Scan error: {e}")
1812
- return gr.update(choices=[], value=None), f"πŸ”΄ Scan failed: {str(e)}"
1813
 
1814
  def on_boot(repo, file, profile: gr.OAuthProfile | None):
1815
  username = profile.username if profile else "anonymous"
@@ -1850,21 +1850,18 @@ with gr.Blocks(title="ZeroEngine V0.2") as demo:
1850
  success_rate = health.get("success_rate", 0)
1851
  avg_response_time = health.get("avg_response_time", 0)
1852
 
1853
- # Create status label with metrics
1854
  if connected and status == "healthy":
1855
  status_text = f"βœ… Connected ({success_rate}% success, {avg_response_time:.3f}s avg)"
1856
- status_label = "Connected"
1857
  elif connected:
1858
  status_text = f"⚠️ Degraded ({success_rate}% success, {avg_response_time:.3f}s avg)"
1859
- status_label = "Degraded"
1860
  else:
1861
  status_text = "❌ Disconnected"
1862
- status_label = "Disconnected"
1863
 
1864
- return status_label, status_text
1865
  except Exception as e:
1866
  logger.error(f"Backend status update error: {e}")
1867
- return "Error", "❌ Status Error"
1868
 
1869
  def on_backend_health_check():
1870
  """Perform detailed backend health check"""
@@ -2013,7 +2010,7 @@ if __name__ == "__main__":
2013
  logger.info("[LAUNCH] Setting up queue...")
2014
  demo.queue(max_size=20)
2015
 
2016
- logger.info("[LAUNCH] Starting server on port 7861...")
2017
  demo.launch(
2018
  server_name="0.0.0.0",
2019
  server_port=7860,
 
58
 
59
  # Try with authentication if available
60
  client_kwargs = {}
61
+ # Note: hf_token parameter not supported in this Gradio version
62
+ # Authentication will be handled by the backend service itself
63
 
64
  start_time = time.time()
65
  self.client = Client(url, **client_kwargs)
 
1798
  def on_scan(repo):
1799
  try:
1800
  if not repo:
1801
+ return gr.update(choices=[]), "⚠️ Please enter a repository ID"
1802
 
1803
  logger.info(f"Scanning repository: {repo}")
1804
  files = kernel.list_ggufs(repo)
1805
 
1806
  if not files:
1807
+ return gr.update(choices=[]), f"❌ No GGUFs found in {repo}"
1808
 
1809
  return gr.update(choices=files, value=files[0]), f"βœ… Found {len(files)} GGUF file(s)"
1810
  except Exception as e:
1811
  logger.error(f"Scan error: {e}")
1812
+ return gr.update(choices=[]), f"πŸ”΄ Scan failed: {str(e)}"
1813
 
1814
  def on_boot(repo, file, profile: gr.OAuthProfile | None):
1815
  username = profile.username if profile else "anonymous"
 
1850
  success_rate = health.get("success_rate", 0)
1851
  avg_response_time = health.get("avg_response_time", 0)
1852
 
1853
+ # Create status text with metrics
1854
  if connected and status == "healthy":
1855
  status_text = f"βœ… Connected ({success_rate}% success, {avg_response_time:.3f}s avg)"
 
1856
  elif connected:
1857
  status_text = f"⚠️ Degraded ({success_rate}% success, {avg_response_time:.3f}s avg)"
 
1858
  else:
1859
  status_text = "❌ Disconnected"
 
1860
 
1861
+ return status_text # Return only the string, not tuple
1862
  except Exception as e:
1863
  logger.error(f"Backend status update error: {e}")
1864
+ return "❌ Status Error"
1865
 
1866
  def on_backend_health_check():
1867
  """Perform detailed backend health check"""
 
2010
  logger.info("[LAUNCH] Setting up queue...")
2011
  demo.queue(max_size=20)
2012
 
2013
+ logger.info("[LAUNCH] Starting server on port 7860...")
2014
  demo.launch(
2015
  server_name="0.0.0.0",
2016
  server_port=7860,