From b85960ba2ae6d33ca93598e9ba051d17919ada1e Mon Sep 17 00:00:00 2001 From: James Barker Date: Mon, 10 Feb 2025 14:58:44 +0000 Subject: [PATCH] updated to fix no break condition on loop and to use the same number of retries and delay as the glama provider (for consistency) Signed-off-by: James Barker --- src/api/providers/openrouter.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 633b6baa52..5d6b79577f 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -184,9 +184,9 @@ export class OpenRouterHandler implements ApiHandler, SingleCompletionHandler { } // retry fetching generation details - let retries = 0 - while (retries < 3) { - await delay(500) // FIXME: necessary delay to ensure generation endpoint is ready + let attempt = 0 + while (attempt++ < 10) { + await delay(200) // FIXME: necessary delay to ensure generation endpoint is ready try { const response = await axios.get(`https://openrouter.ai/api/v1/generation?id=${genId}`, { headers: { @@ -207,6 +207,7 @@ export class OpenRouterHandler implements ApiHandler, SingleCompletionHandler { totalCost: generation?.total_cost || 0, fullResponseText, } as OpenRouterApiStreamUsageChunk + return } catch (error) { // ignore if fails console.error("Error fetching OpenRouter generation details:", error)