feat(fetch): add Ollama Cloud web fetch provider
This commit is contained in:
@@ -159,8 +159,13 @@ async function handleSingleProviderFetch(body, providerInput, request, apiKey, s
|
||||
let lastError = null;
|
||||
let lastStatus = null;
|
||||
|
||||
// Keep web-fetch failures scoped to this capability. Providers such as
|
||||
// Ollama use the same connection for chat and fetch, so an upstream fetch
|
||||
// failure must not take the account offline for LLM requests.
|
||||
const fetchLockKey = `webfetch:${providerId}`;
|
||||
|
||||
while (true) {
|
||||
const credentials = await getProviderCredentials(providerId, excludeConnectionIds);
|
||||
const credentials = await getProviderCredentials(providerId, excludeConnectionIds, fetchLockKey);
|
||||
|
||||
if (!credentials || credentials.allRateLimited) {
|
||||
if (credentials?.allRateLimited) {
|
||||
@@ -200,13 +205,19 @@ async function handleSingleProviderFetch(body, providerInput, request, apiKey, s
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
await clearAccountError(credentials.connectionId, credentials);
|
||||
await clearAccountError(credentials.connectionId, credentials, fetchLockKey);
|
||||
return new Response(JSON.stringify(result.data), {
|
||||
headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" }
|
||||
});
|
||||
}
|
||||
|
||||
const { shouldFallback } = await markAccountUnavailable(credentials.connectionId, result.status, result.error, providerId);
|
||||
const { shouldFallback } = await markAccountUnavailable(
|
||||
credentials.connectionId,
|
||||
result.status,
|
||||
result.error,
|
||||
providerId,
|
||||
fetchLockKey,
|
||||
);
|
||||
|
||||
if (shouldFallback) {
|
||||
log.warn("AUTH", `Account ${credentials.connectionName} unavailable (${result.status}), trying fallback`);
|
||||
|
||||
Reference in New Issue
Block a user