Spaces:
Running
Running
Tecnhotron
commited on
Commit
·
614893b
1
Parent(s):
4c3cc4a
First
Browse files
api.py
CHANGED
|
@@ -506,7 +506,16 @@ async def list_models():
|
|
| 506 |
raise HTTPException(status_code=503, detail="Service unavailable: The backend driver is not ready.")
|
| 507 |
except Exception as e:
|
| 508 |
logger.error(f"An unexpected error occurred while fetching models: {e}", exc_info=True)
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
|
| 511 |
@app.post("/chat/completions", response_model=ChatCompletionResponse)
|
| 512 |
async def chat_completions(request: ChatCompletionRequest):
|
|
|
|
| 506 |
raise HTTPException(status_code=503, detail="Service unavailable: The backend driver is not ready.")
|
| 507 |
except Exception as e:
|
| 508 |
logger.error(f"An unexpected error occurred while fetching models: {e}", exc_info=True)
|
| 509 |
+
# Attempt captcha resolution then retry
|
| 510 |
+
try:
|
| 511 |
+
drv = driver_manager.get_driver()
|
| 512 |
+
driver_manager._perform_sync_captcha_checks(drv)
|
| 513 |
+
logger.info("Retrying model fetch after captcha checks...")
|
| 514 |
+
model_ids = await get_available_models()
|
| 515 |
+
return ModelListResponse(data=[ModelInfo(id=mid) for mid in model_ids])
|
| 516 |
+
except Exception as retry_e:
|
| 517 |
+
logger.error(f"Retry after captcha checks failed: {retry_e}", exc_info=True)
|
| 518 |
+
raise HTTPException(status_code=500, detail=f"An unexpected error occurred while fetching models: {str(retry_e)}")
|
| 519 |
|
| 520 |
@app.post("/chat/completions", response_model=ChatCompletionResponse)
|
| 521 |
async def chat_completions(request: ChatCompletionRequest):
|