More bugfixes
This commit is contained in:
9
oai.py
9
oai.py
@@ -5034,9 +5034,18 @@ All queries are read-only. INSERT/UPDATE/DELETE are not allowed."""
|
|||||||
try:
|
try:
|
||||||
if hasattr(response, 'close'):
|
if hasattr(response, 'close'):
|
||||||
response.close()
|
response.close()
|
||||||
|
elif hasattr(response, '__exit__'):
|
||||||
|
response.__exit__(None, None, None)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Recreate client to be safe
|
||||||
|
try:
|
||||||
|
client = OpenRouter(api_key=API_KEY)
|
||||||
|
app_logger.info("Client recreated after stream interruption")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
continue # Now it's safe to continue
|
continue # Now it's safe to continue
|
||||||
else:
|
else:
|
||||||
full_response = response.choices[0].message.content if response.choices else ""
|
full_response = response.choices[0].message.content if response.choices else ""
|
||||||
|
|||||||
Reference in New Issue
Block a user