This commit is contained in:
Shantur Rathore 2025-12-23 15:42:42 +08:00 committed by GitHub
commit f07f68edf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View file

@ -596,6 +596,12 @@ export namespace Config {
whitelist: z.array(z.string()).optional(),
blacklist: z.array(z.string()).optional(),
models: z.record(z.string(), ModelsDev.Model.partial()).optional(),
export_name: z
.string()
.optional()
.describe(
"Name of the export function to use from the npm package. If not specified, auto-detects the first 'create*' function.",
),
options: z
.object({
apiKey: z.string().optional(),

View file

@ -426,6 +426,7 @@ export namespace Provider {
source: z.enum(["env", "config", "custom", "api"]),
env: z.string().array(),
key: z.string().optional(),
export_name: z.string().optional(),
options: z.record(z.string(), z.any()),
models: z.record(z.string(), Model),
})
@ -457,13 +458,13 @@ export namespace Provider {
},
experimentalOver200K: model.cost?.context_over_200k
? {
cache: {
read: model.cost.context_over_200k.cache_read ?? 0,
write: model.cost.context_over_200k.cache_write ?? 0,
},
input: model.cost.context_over_200k.input,
output: model.cost.context_over_200k.output,
}
cache: {
read: model.cost.context_over_200k.cache_read ?? 0,
write: model.cost.context_over_200k.cache_write ?? 0,
},
input: model.cost.context_over_200k.input,
output: model.cost.context_over_200k.output,
}
: undefined,
},
limit: {
@ -566,6 +567,7 @@ export namespace Provider {
id: providerID,
name: provider.name ?? existing?.name ?? providerID,
env: provider.env ?? existing?.env ?? [],
export_name: provider.export_name,
options: mergeDeep(existing?.options ?? {}, provider.options ?? {}),
source: "config",
models: existing?.models ?? {},
@ -846,7 +848,8 @@ export namespace Provider {
const mod = await import(installedPath)
const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
const exportName = provider.export_name ?? Object.keys(mod).find((key) => key.startsWith("create"))!
const fn = mod[exportName]
const loaded = fn({
name: model.providerID,
...options,