mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
fix: custom model (#3156)
This commit is contained in:
@@ -210,6 +210,8 @@ export namespace Provider {
|
||||
{ providerID: string; modelID: string; info: ModelsDev.Model; language: LanguageModel; npm?: string }
|
||||
>()
|
||||
const sdk = new Map<number, SDK>()
|
||||
// Maps `${provider}/${key}` to the provider’s actual model ID for custom aliases.
|
||||
const realIdByKey = new Map<string, string>()
|
||||
|
||||
log.info("init")
|
||||
|
||||
@@ -253,7 +255,7 @@ export namespace Provider {
|
||||
for (const [modelID, model] of Object.entries(provider.models ?? {})) {
|
||||
const existing = parsed.models[modelID]
|
||||
const parsedModel: ModelsDev.Model = {
|
||||
id: model.id ?? modelID,
|
||||
id: modelID,
|
||||
name: model.name ?? existing?.name ?? modelID,
|
||||
release_date: model.release_date ?? existing?.release_date,
|
||||
attachment: model.attachment ?? existing?.attachment ?? false,
|
||||
@@ -290,6 +292,9 @@ export namespace Provider {
|
||||
},
|
||||
provider: model.provider ?? existing?.provider,
|
||||
}
|
||||
if (model.id && model.id !== modelID) {
|
||||
realIdByKey.set(`${providerID}/${modelID}`, model.id)
|
||||
}
|
||||
parsed.models[modelID] = parsedModel
|
||||
}
|
||||
database[providerID] = parsed
|
||||
@@ -366,6 +371,7 @@ export namespace Provider {
|
||||
models,
|
||||
providers,
|
||||
sdk,
|
||||
realIdByKey,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -436,9 +442,11 @@ export namespace Provider {
|
||||
const sdk = await getSDK(provider.info, info)
|
||||
|
||||
try {
|
||||
const keyReal = `${providerID}/${modelID}`
|
||||
const realID = s.realIdByKey.get(keyReal) ?? info.id
|
||||
const language = provider.getModel
|
||||
? await provider.getModel(sdk, modelID, provider.options)
|
||||
: sdk.languageModel(modelID)
|
||||
? await provider.getModel(sdk, realID, provider.options)
|
||||
: sdk.languageModel(realID)
|
||||
log.info("found", { providerID, modelID })
|
||||
s.models.set(key, {
|
||||
providerID,
|
||||
|
||||
@@ -1305,7 +1305,7 @@ export namespace SessionPrompt {
|
||||
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
|
||||
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
|
||||
${input.command}
|
||||
`
|
||||
`,
|
||||
],
|
||||
},
|
||||
bash: {
|
||||
@@ -1320,15 +1320,11 @@ export namespace SessionPrompt {
|
||||
},
|
||||
// Fallback: any shell that doesn't match those above
|
||||
"": {
|
||||
args: [
|
||||
"-c",
|
||||
"-l",
|
||||
`${input.command}`,
|
||||
],
|
||||
args: ["-c", "-l", `${input.command}`],
|
||||
},
|
||||
}
|
||||
|
||||
const matchingInvocation = invocations[shellName] ?? invocations[""];
|
||||
const matchingInvocation = invocations[shellName] ?? invocations[""]
|
||||
const args = matchingInvocation?.args
|
||||
|
||||
const proc = spawn(shell, args, {
|
||||
|
||||
Reference in New Issue
Block a user