fix: increase default timeout for jina

pull/689/head
Travis Fischer 2025-02-26 00:22:00 +07:00
rodzic 4cc7bb6f26
commit c693fddbb6
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -116,10 +116,12 @@ export class JinaClient extends AIFunctionsProvider {
constructor({ constructor({
apiKey = getEnv('JINA_API_KEY'), apiKey = getEnv('JINA_API_KEY'),
timeoutMs = 60_000,
throttle = true, throttle = true,
ky = defaultKy ky = defaultKy
}: { }: {
apiKey?: string apiKey?: string
timeoutMs?: number
throttle?: boolean throttle?: boolean
ky?: KyInstance ky?: KyInstance
} = {}) { } = {}) {
@ -131,12 +133,14 @@ export class JinaClient extends AIFunctionsProvider {
ky = ky.extend({ headers: { Authorization: `Bearer ${apiKey}` } }) ky = ky.extend({ headers: { Authorization: `Bearer ${apiKey}` } })
} }
ky = ky.extend({ timeout: timeoutMs })
const throttledKyReader = throttle const throttledKyReader = throttle
? throttleKy( ? throttleKy(
ky, ky,
pThrottle({ pThrottle({
limit: apiKey ? 200 : 20, limit: apiKey ? 200 : 20,
interval: 60 * 60 * 1000 interval: 60 * 60 * 1000 // 60 minutes
}) })
) )
: ky : ky
@ -147,11 +151,11 @@ export class JinaClient extends AIFunctionsProvider {
ky, ky,
pThrottle({ pThrottle({
limit: apiKey ? 40 : 5, limit: apiKey ? 40 : 5,
interval: 60 * 60 * 1000 interval: 60 * 60 * 1000 // 60 minutes
}) })
) )
: ky : ky
this.kySearch = throttledKySearch.extend({ prefixUrl: 'https://s.jina.ai ' }) this.kySearch = throttledKySearch.extend({ prefixUrl: 'https://s.jina.ai' })
} }
@aiFunction({ @aiFunction({