dineshb commited on
Commit
f26fd6b
·
verified ·
1 Parent(s): af990e8

Bound hosted Gemini request latency

Browse files

Use short connect and response deadlines so an unavailable AI provider cannot hold a hosted Streamlit session open.

Files changed (1) hide show
  1. datapilot/analyst.py +2 -2
datapilot/analyst.py CHANGED
@@ -220,12 +220,12 @@ DATA:\n"""
220
  "X-Server-Timeout": "30",
221
  },
222
  json=payload,
223
- timeout=(5, 15),
224
  )
225
  logger.warning("gemini_response_received status=%d", response.status_code)
226
  except requests.Timeout as exc:
227
  logger.warning("gemini_request_timed_out")
228
- raise ValueError("Gemini timed out after 15 seconds. Please try again.") from exc
229
  except requests.ConnectionError as exc:
230
  logger.warning("gemini_connection_failed")
231
  raise ValueError("DataPilot could not connect to Gemini. Please try again.") from exc
 
220
  "X-Server-Timeout": "30",
221
  },
222
  json=payload,
223
+ timeout=(3, 8),
224
  )
225
  logger.warning("gemini_response_received status=%d", response.status_code)
226
  except requests.Timeout as exc:
227
  logger.warning("gemini_request_timed_out")
228
+ raise ValueError("Gemini timed out after 8 seconds. Please try again.") from exc
229
  except requests.ConnectionError as exc:
230
  logger.warning("gemini_connection_failed")
231
  raise ValueError("DataPilot could not connect to Gemini. Please try again.") from exc