mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Merge 7d5d53694d into 83397ebde2
This commit is contained in:
commit
f07f68edf4
2 changed files with 17 additions and 8 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue