fix: cloudflare workers ai provider (#12157)
This commit is contained in:
@@ -457,6 +457,29 @@ export namespace Provider {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"cloudflare-workers-ai": async (input) => {
|
||||||
|
const accountId = Env.get("CLOUDFLARE_ACCOUNT_ID")
|
||||||
|
if (!accountId) return { autoload: false }
|
||||||
|
|
||||||
|
const apiKey = await iife(async () => {
|
||||||
|
const envToken = Env.get("CLOUDFLARE_API_KEY")
|
||||||
|
if (envToken) return envToken
|
||||||
|
const auth = await Auth.get(input.id)
|
||||||
|
if (auth?.type === "api") return auth.key
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
autoload: !!apiKey,
|
||||||
|
options: {
|
||||||
|
apiKey,
|
||||||
|
baseURL: `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1`,
|
||||||
|
},
|
||||||
|
async getModel(sdk: any, modelID: string) {
|
||||||
|
return sdk.languageModel(modelID)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
"cloudflare-ai-gateway": async (input) => {
|
"cloudflare-ai-gateway": async (input) => {
|
||||||
const accountId = Env.get("CLOUDFLARE_ACCOUNT_ID")
|
const accountId = Env.get("CLOUDFLARE_ACCOUNT_ID")
|
||||||
const gateway = Env.get("CLOUDFLARE_GATEWAY_ID")
|
const gateway = Env.get("CLOUDFLARE_GATEWAY_ID")
|
||||||
|
|||||||
Reference in New Issue
Block a user