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 <james@jcbdevelopment.co.uk>
This commit is contained in:
James Barker 2025-02-10 14:58:44 +00:00
parent 9c480aaac2
commit b85960ba2a
No known key found for this signature in database

View file

@ -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)