UNPKG

ai-gateway-provider

Version:

AI Gateway Provider for AI-SDK

1 lines 1.53 kB
{"version":3,"sources":["../../src/providers/google-vertex.ts","../../src/auth.ts"],"sourcesContent":["import { createVertex as createVertexOriginal } from '@ai-sdk/google-vertex';\nimport { CF_TEMP_TOKEN } from '../auth';\n\nexport const createVertex = (\n ...rest: Parameters<typeof createVertexOriginal>\n) => {\n if(!rest || !rest[0]) {\n return createVertexOriginal({ googleAuthOptions: { apiKey: CF_TEMP_TOKEN } });\n }\n\n if(rest[0].googleAuthOptions && rest[0].googleAuthOptions.apiKey === undefined && rest[0].googleAuthOptions.credentials === undefined) {\n rest[0].googleAuthOptions.apiKey = CF_TEMP_TOKEN;\n }\n\n return createVertexOriginal(...rest);\n}\n","export const CF_TEMP_TOKEN = 'CF_TEMP_TOKEN';\n\n\ntype HasApiKey = { apiKey: string };\n\nexport function authWrapper<\n Func extends (config?: HasApiKey) => any\n>(\n func: Func\n): (\n config: Parameters<Func>[0],\n) => ReturnType<Func> {\n return (config) => {\n if(!config) {\n return func({ apiKey: CF_TEMP_TOKEN });\n }\n if(config.apiKey === undefined) {\n config.apiKey = CF_TEMP_TOKEN;\n }\n return func(config);\n };\n}"],"mappings":";AAAA,SAAS,gBAAgB,4BAA4B;;;ACA9C,IAAM,gBAAgB;;;ADGtB,IAAM,eAAe,IACvB,SACA;AACH,MAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG;AACpB,WAAO,qBAAqB,EAAE,mBAAmB,EAAE,QAAQ,cAAc,EAAE,CAAC;AAAA,EAC9E;AAEA,MAAG,KAAK,CAAC,EAAE,qBAAqB,KAAK,CAAC,EAAE,kBAAkB,WAAW,UAAa,KAAK,CAAC,EAAE,kBAAkB,gBAAgB,QAAW;AACrI,SAAK,CAAC,EAAE,kBAAkB,SAAS;AAAA,EACrC;AAEA,SAAO,qBAAqB,GAAG,IAAI;AACrC;","names":[]}