fix: further adjust provider.ts, ensure that the typing for language is LanguageModelV3 instead of LanuageModel union (should fix compat in llm.ts)

This commit is contained in:
Aiden Cline
2026-03-20 16:02:25 -05:00
parent d70a6b37e5
commit dbd72df3a4
2 changed files with 6 additions and 6 deletions
+6 -3
View File
@@ -9,6 +9,7 @@ import { BunProc } from "../bun"
import { Hash } from "../util/hash"
import { Plugin } from "../plugin"
import { NamedError } from "@opencode-ai/util/error"
import { type LanguageModelV3 } from "@ai-sdk/provider"
import { ModelsDev } from "./models"
import { Auth } from "../auth"
import { Env } from "../env"
@@ -104,7 +105,9 @@ export namespace Provider {
})
}
type BundledSDK = Pick<SDK, "languageModel">
type BundledSDK = {
languageModel(modelId: string): LanguageModelV3
}
const BUNDLED_PROVIDERS: Record<string, (options: any) => BundledSDK> = {
"@ai-sdk/amazon-bedrock": createAmazonBedrock,
@@ -848,7 +851,7 @@ export namespace Provider {
}
const providers: Record<ProviderID, Info> = {} as Record<ProviderID, Info>
const languages = new Map<string, ReturnType<SDK["languageModel"]>>()
const languages = new Map<string, LanguageModelV3>()
const modelLoaders: {
[providerID: string]: CustomModelLoader
} = {}
@@ -1242,7 +1245,7 @@ export namespace Provider {
return info
}
export async function getLanguage(model: Model): Promise<ReturnType<SDK["languageModel"]>> {
export async function getLanguage(model: Model): Promise<LanguageModelV3> {
const s = await state()
const key = `${model.providerID}/${model.id}`
if (s.models.has(key)) return s.models.get(key)!
-3
View File
@@ -1,4 +1,3 @@
import { Installation } from "@/installation"
import { Provider } from "@/provider/provider"
import { Log } from "@/util/log"
import {
@@ -42,8 +41,6 @@ export namespace LLM {
toolChoice?: "auto" | "required" | "none"
}
export type StreamOutput = StreamTextResult<ToolSet, unknown>
export async function stream(input: StreamInput) {
const l = log
.clone()