mirror of
https://github.com/larchanka/manbot.git
synced 2026-05-13 21:42:08 +00:00
Fix: further improve Ollama reliability with retry delays and increased attempts
This commit is contained in:
committed by
Mikhail Larchanka
parent
b398bba68a
commit
36a812c29a
@@ -394,14 +394,21 @@ export class OllamaAdapter {
|
||||
(err.name === "AbortError" ||
|
||||
err.message.includes("fetch") ||
|
||||
err.message.includes("ECONNREFUSED") ||
|
||||
err.message.includes("network"));
|
||||
err.message.includes("network") ||
|
||||
err.message.includes("reset") ||
|
||||
err.message.includes("hangup"));
|
||||
|
||||
if (attempt === this.retries || !isRetryable) {
|
||||
if (err instanceof Error && (err as any).cause) {
|
||||
err.message += ` (Cause: ${(err as any).cause})`;
|
||||
const cause = (err as any).cause;
|
||||
const causeMsg = cause instanceof Error ? cause.message : String(cause);
|
||||
err.message += ` (Cause: ${causeMsg})`;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
// Wait before retry: 1s, 2s...
|
||||
console.warn(`[ollama-adapter] Fetch failed: ${err.message}. Retrying in ${(attempt + 1)}s... (Attempt ${attempt + 1}/${this.retries})`);
|
||||
await new Promise((resolve) => setTimeout(resolve, (attempt + 1) * 1000));
|
||||
}
|
||||
}
|
||||
throw lastError;
|
||||
|
||||
@@ -140,7 +140,7 @@ const DEFAULT_CONFIG: AppConfig = {
|
||||
ollama: {
|
||||
baseUrl: "http://127.0.0.1:11434",
|
||||
timeoutMs: 600_000, // 10 minutes default
|
||||
retries: 2,
|
||||
retries: 3,
|
||||
numCtx: 16384,
|
||||
},
|
||||
telegram: {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user