From c693fddbb6f7959ed82ce90dde38627781c4580b Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 26 Feb 2025 00:22:00 +0700 Subject: [PATCH] fix: increase default timeout for jina --- packages/jina/src/jina-client.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/jina/src/jina-client.ts b/packages/jina/src/jina-client.ts index 429073e..81ff3de 100644 --- a/packages/jina/src/jina-client.ts +++ b/packages/jina/src/jina-client.ts @@ -116,10 +116,12 @@ export class JinaClient extends AIFunctionsProvider { constructor({ apiKey = getEnv('JINA_API_KEY'), + timeoutMs = 60_000, throttle = true, ky = defaultKy }: { apiKey?: string + timeoutMs?: number throttle?: boolean ky?: KyInstance } = {}) { @@ -131,12 +133,14 @@ export class JinaClient extends AIFunctionsProvider { ky = ky.extend({ headers: { Authorization: `Bearer ${apiKey}` } }) } + ky = ky.extend({ timeout: timeoutMs }) + const throttledKyReader = throttle ? throttleKy( ky, pThrottle({ limit: apiKey ? 200 : 20, - interval: 60 * 60 * 1000 + interval: 60 * 60 * 1000 // 60 minutes }) ) : ky @@ -147,11 +151,11 @@ export class JinaClient extends AIFunctionsProvider { ky, pThrottle({ limit: apiKey ? 40 : 5, - interval: 60 * 60 * 1000 + interval: 60 * 60 * 1000 // 60 minutes }) ) : ky - this.kySearch = throttledKySearch.extend({ prefixUrl: 'https://s.jina.ai ' }) + this.kySearch = throttledKySearch.extend({ prefixUrl: 'https://s.jina.ai' }) } @aiFunction({