ProximileAdmin commited on
Commit
73ff673
·
verified ·
1 Parent(s): e0b5376

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -80,12 +80,12 @@ def start_ssh_tunnel():
80
  else:
81
  logger.warning("Failed to start SSH tunnel. Falling back to Hyperbolic API.")
82
  use_fallback = True
83
- tunnel_status = {"is_running": False, "message": "Failed to connect"}
84
 
85
  except Exception as e:
86
  logger.error(f"Error starting SSH tunnel: {str(e)}")
87
  use_fallback = True
88
- tunnel_status = {"is_running": False, "message": f"Error: {str(e)}"}
89
 
90
  def check_vllm_api_health():
91
  """
@@ -140,13 +140,15 @@ def monitor_tunnel():
140
  use_fallback = True
141
  tunnel_status = {
142
  "is_running": False,
143
- "message": f"Tunnel connected but vLLM API unhealthy: {message}"
144
  }
145
  else:
 
 
146
  use_fallback = True
147
  tunnel_status = {
148
  "is_running": False,
149
- "message": f"Disconnected: {ssh_status['error'] or 'Unknown error'}"
150
  }
151
  else:
152
  use_fallback = True
@@ -155,7 +157,7 @@ def monitor_tunnel():
155
  except Exception as e:
156
  logger.error(f"Error monitoring tunnel: {str(e)}")
157
  use_fallback = True
158
- tunnel_status = {"is_running": False, "message": f"Monitoring error: {str(e)}"}
159
 
160
  time.sleep(5) # Check every 5 seconds
161
 
@@ -382,12 +384,12 @@ def process_chat(message_dict, history):
382
 
383
  except Exception as fallback_error:
384
  logger.error(f"Fallback API error: {str(fallback_error)}")
385
- error_msg = f"Error with both primary and fallback APIs. Primary: {str(primary_error)}. Fallback: {str(fallback_error)}"
386
  history.append({"role": "assistant", "content": error_msg})
387
  return history
388
  else:
389
  # Already using fallback, just report the error
390
- error_msg = f"An error occurred with the model: {str(primary_error)}"
391
  history.append({"role": "assistant", "content": error_msg})
392
  return history
393
 
 
80
  else:
81
  logger.warning("Failed to start SSH tunnel. Falling back to Hyperbolic API.")
82
  use_fallback = True
83
+ tunnel_status = {"is_running": False, "message": "Connection failed"}
84
 
85
  except Exception as e:
86
  logger.error(f"Error starting SSH tunnel: {str(e)}")
87
  use_fallback = True
88
+ tunnel_status = {"is_running": False, "message": "Connection error"}
89
 
90
  def check_vllm_api_health():
91
  """
 
140
  use_fallback = True
141
  tunnel_status = {
142
  "is_running": False,
143
+ "message": "Tunnel connected but vLLM API unhealthy"
144
  }
145
  else:
146
+ # Log the actual error for troubleshooting but don't expose it in the UI
147
+ logger.error(f"SSH tunnel disconnected: {ssh_status['error'] or 'Unknown error'}")
148
  use_fallback = True
149
  tunnel_status = {
150
  "is_running": False,
151
+ "message": "Disconnected - Check server status"
152
  }
153
  else:
154
  use_fallback = True
 
157
  except Exception as e:
158
  logger.error(f"Error monitoring tunnel: {str(e)}")
159
  use_fallback = True
160
+ tunnel_status = {"is_running": False, "message": "Monitoring error"}
161
 
162
  time.sleep(5) # Check every 5 seconds
163
 
 
384
 
385
  except Exception as fallback_error:
386
  logger.error(f"Fallback API error: {str(fallback_error)}")
387
+ error_msg = "Error connecting to both primary and fallback APIs."
388
  history.append({"role": "assistant", "content": error_msg})
389
  return history
390
  else:
391
  # Already using fallback, just report the error
392
+ error_msg = "An error occurred with the model service."
393
  history.append({"role": "assistant", "content": error_msg})
394
  return history
395