mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-02 07:03:45 +00:00
fix(provider): forward metadata options to cloudflare-ai-gateway provider (#15619)
This commit is contained in:
@@ -555,7 +555,25 @@ export namespace Provider {
|
||||
const { createAiGateway } = await import("ai-gateway-provider")
|
||||
const { createUnified } = await import("ai-gateway-provider/providers/unified")
|
||||
|
||||
const aigateway = createAiGateway({ accountId, gateway, apiKey: apiToken })
|
||||
const metadata = iife(() => {
|
||||
if (input.options?.metadata) return input.options.metadata
|
||||
try { return JSON.parse(input.options?.headers?.["cf-aig-metadata"]) }
|
||||
catch { return undefined }
|
||||
})
|
||||
const opts = {
|
||||
metadata,
|
||||
cacheTtl: input.options?.cacheTtl,
|
||||
cacheKey: input.options?.cacheKey,
|
||||
skipCache: input.options?.skipCache,
|
||||
collectLog: input.options?.collectLog,
|
||||
}
|
||||
|
||||
const aigateway = createAiGateway({
|
||||
accountId,
|
||||
gateway,
|
||||
apiKey: apiToken,
|
||||
...(Object.values(opts).some(v => v !== undefined) ? { options: opts } : {}),
|
||||
})
|
||||
const unified = createUnified()
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user