mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 17:54:23 +01:00
fix: provider option transforms (#3331)
This commit is contained in:
@@ -105,6 +105,24 @@ export namespace ProviderTransform {
|
||||
return result
|
||||
}
|
||||
|
||||
export function providerOptions(npm: string | undefined, providerID: string, options: { [x: string]: any }) {
|
||||
switch (npm) {
|
||||
case "@ai-sdk/openai":
|
||||
case "@ai-sdk/azure":
|
||||
return {
|
||||
["openai" as string]: options,
|
||||
}
|
||||
case "@ai-sdk/anthropic":
|
||||
return {
|
||||
["anthropic" as string]: options,
|
||||
}
|
||||
default:
|
||||
return {
|
||||
[providerID]: options,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function maxOutputTokens(
|
||||
providerID: string,
|
||||
options: Record<string, any>,
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Token } from "../util/token"
|
||||
import { Log } from "../util/log"
|
||||
import { SessionLock } from "./lock"
|
||||
import { NamedError } from "../util/error"
|
||||
import { ProviderTransform } from "@/provider/transform"
|
||||
|
||||
export namespace SessionCompaction {
|
||||
const log = Log.create({ service: "session.compaction" })
|
||||
@@ -143,9 +144,7 @@ export namespace SessionCompaction {
|
||||
const stream = streamText({
|
||||
maxRetries: 10,
|
||||
model: model.language,
|
||||
providerOptions: {
|
||||
[model.npm === "@ai-sdk/openai" ? "openai" : model.providerID]: model.info.options,
|
||||
},
|
||||
providerOptions: ProviderTransform.providerOptions(model.npm, model.providerID, model.info.options),
|
||||
abortSignal: signal,
|
||||
onError(error) {
|
||||
log.error("stream error", {
|
||||
|
||||
@@ -282,10 +282,7 @@ export namespace SessionPrompt {
|
||||
OUTPUT_TOKEN_MAX,
|
||||
),
|
||||
abortSignal: abort.signal,
|
||||
providerOptions: {
|
||||
[model.npm === "@ai-sdk/openai" || model.npm === "@ai-sdk/azure" ? "openai" : model.providerID]:
|
||||
params.options,
|
||||
},
|
||||
providerOptions: ProviderTransform.providerOptions(model.npm, model.providerID, params.options),
|
||||
stopWhen: stepCountIs(1),
|
||||
temperature: params.temperature,
|
||||
topP: params.topP,
|
||||
@@ -1822,9 +1819,7 @@ export namespace SessionPrompt {
|
||||
}
|
||||
generateText({
|
||||
maxOutputTokens: small.info.reasoning ? 1500 : 20,
|
||||
providerOptions: {
|
||||
[small.providerID]: options,
|
||||
},
|
||||
providerOptions: ProviderTransform.providerOptions(small.npm, small.providerID, options),
|
||||
messages: [
|
||||
...SystemPrompt.title(small.providerID).map(
|
||||
(x): ModelMessage => ({
|
||||
|
||||
Reference in New Issue
Block a user