mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 23:02:26 +00:00
feat: Allow provider timeout override (#1982)
This commit is contained in:
@@ -320,9 +320,16 @@ export namespace Provider {
|
||||
const pkg = provider.npm ?? provider.id
|
||||
const mod = await import(await BunProc.install(pkg, "latest"))
|
||||
const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
|
||||
let options = { ...s.providers[provider.id]?.options }
|
||||
if (options["timeout"] !== undefined) {
|
||||
// Only override fetch if user explicitly sets timeout
|
||||
options["fetch"] = async (input: any, init?: any) => {
|
||||
return await fetch(input, { ...init, timeout: options["timeout"] })
|
||||
}
|
||||
}
|
||||
const loaded = fn({
|
||||
name: provider.id,
|
||||
...s.providers[provider.id]?.options,
|
||||
...options,
|
||||
})
|
||||
s.sdk.set(provider.id, loaded)
|
||||
return loaded as SDK
|
||||
|
||||
Reference in New Issue
Block a user