Ensure all fallback AI models are tried before giving up
This commit is contained in:
+6
-1
@@ -268,11 +268,16 @@ function fociz_ai_chat_gemini(array $messages, array $options, array $aiSettings
|
||||
continue;
|
||||
}
|
||||
|
||||
// Bij autorisatiefouten (zoals ongeldige API key 400/403) direct stoppen
|
||||
// Alleen bij expliciete autorisatiefouten (ongeldige API key 400/401/403) stoppen
|
||||
if (in_array($res['status'], [400, 401, 403], true)) {
|
||||
$response = $res;
|
||||
break;
|
||||
}
|
||||
|
||||
// Voor alle andere fouten (serverfout 500, timeout, etc.): probeer volgende kandidaat
|
||||
continue;
|
||||
}
|
||||
|
||||
// Als alle directe kandidaten een 404 gaven, probeer dynamisch via ListModels een passend gemini model te vinden
|
||||
if (!$response && ($lastError && (str_contains($lastError, 'not found') || str_contains($lastError, 'not supported')))) {
|
||||
$listUrl = "https://generativelanguage.googleapis.com/v1beta/models?key=" . urlencode($apiKey);
|
||||
|
||||
Reference in New Issue
Block a user