feat: enhance provider model mapping and reasoning capabilities

- Add npm package tracking to provider model mapping
- Implement special handling for opencode provider with reasoning
- Update provider options mapping to use npm package names
This commit is contained in:
Dax Raad
2025-09-16 03:10:17 -04:00
parent 8f58fef5ad
commit 2d5bd26a59
3 changed files with 9 additions and 2 deletions

View File

@@ -159,7 +159,7 @@ export namespace Provider {
} = {}
const models = new Map<
string,
{ providerID: string; modelID: string; info: ModelsDev.Model; language: LanguageModel }
{ providerID: string; modelID: string; info: ModelsDev.Model; language: LanguageModel; npm?: string }
>()
const sdk = new Map<number, SDK>()
@@ -378,12 +378,14 @@ export namespace Provider {
modelID,
info,
language,
npm: info.provider?.npm ?? provider.info.npm,
})
return {
modelID,
providerID,
info,
language,
npm: info.provider?.npm ?? provider.info.npm,
}
} catch (e) {
if (e instanceof NoSuchModelError)

View File

@@ -96,6 +96,11 @@ export namespace ProviderTransform {
if (providerID !== "azure") {
result["textVerbosity"] = "low"
}
if (providerID === "opencode") {
result["promptCacheKey"] = sessionID
result["include"] = ["reasoning.encrypted_content"]
result["reasoningSummary"] = "detailed"
}
}
return result
}

View File

@@ -268,7 +268,7 @@ export namespace SessionPrompt {
maxOutputTokens: ProviderTransform.maxOutputTokens(model.providerID, outputLimit, params.options),
abortSignal: abort.signal,
providerOptions: {
[model.providerID]: params.options,
[model.npm === "@ai-sdk/openai" ? "openai" : model.providerID]: params.options,
},
stopWhen: stepCountIs(1),
temperature: params.temperature,