fix(core): request default OpenAI reasoning summaries
This commit is contained in:
parent
828a4b3f15
commit
fda66bfd40
3 changed files with 20 additions and 6 deletions
|
|
@ -2,6 +2,7 @@ export * as SessionRunnerModel from "./model"
|
||||||
|
|
||||||
import { makeLocationNode } from "../../effect/app-node"
|
import { makeLocationNode } from "../../effect/app-node"
|
||||||
import { Model } from "@opencode-ai/llm"
|
import { Model } from "@opencode-ai/llm"
|
||||||
|
import { OpenAI } from "@opencode-ai/llm/providers"
|
||||||
// ast-grep-ignore: no-star-import
|
// ast-grep-ignore: no-star-import
|
||||||
import * as AnthropicMessages from "@opencode-ai/llm/protocols/anthropic-messages"
|
import * as AnthropicMessages from "@opencode-ai/llm/protocols/anthropic-messages"
|
||||||
// ast-grep-ignore: no-star-import
|
// ast-grep-ignore: no-star-import
|
||||||
|
|
@ -191,20 +192,18 @@ export const fromCatalogModel = (
|
||||||
const packageName = ProviderV2.packageName(resolved.package)
|
const packageName = ProviderV2.packageName(resolved.package)
|
||||||
const key = apiKey(resolved, credential)
|
const key = apiKey(resolved, credential)
|
||||||
|
|
||||||
if (
|
if (OpenAICodex.isChatGPT(credential) && !ProviderV2.isAISDK(resolved.package) && isNativeOpenAI(resolved.package)) {
|
||||||
OpenAICodex.isChatGPT(credential) &&
|
|
||||||
!ProviderV2.isAISDK(resolved.package) &&
|
|
||||||
isNativeOpenAI(resolved.package)
|
|
||||||
) {
|
|
||||||
return Effect.succeed(codexModel(resolved, credential, key))
|
return Effect.succeed(codexModel(resolved, credential, key))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProviderV2.isAISDK(resolved.package) && packageName === "@ai-sdk/openai") {
|
if (ProviderV2.isAISDK(resolved.package) && packageName === "@ai-sdk/openai") {
|
||||||
if (OpenAICodex.isChatGPT(credential)) return Effect.succeed(codexModel(resolved, credential, key))
|
if (OpenAICodex.isChatGPT(credential)) return Effect.succeed(codexModel(resolved, credential, key))
|
||||||
|
const id = resolved.modelID ?? resolved.id
|
||||||
return Effect.succeed(
|
return Effect.succeed(
|
||||||
withDefaults(resolved, OpenAIResponses.route)
|
withDefaults(resolved, OpenAIResponses.route)
|
||||||
|
.with(OpenAI.OpenAIProviderOptions.withOpenAIOptions(id, {}))
|
||||||
.with({ auth: key === undefined ? Auth.none : Auth.bearer(key) })
|
.with({ auth: key === undefined ? Auth.none : Auth.bearer(key) })
|
||||||
.model({ id: resolved.modelID ?? resolved.id }),
|
.model({ id }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (ProviderV2.isAISDK(resolved.package) && packageName === "@ai-sdk/anthropic") {
|
if (ProviderV2.isAISDK(resolved.package) && packageName === "@ai-sdk/anthropic") {
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,20 @@ describe("SessionRunnerModel", () => {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
it.effect("requests OpenAI reasoning summaries for default reasoning models", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const resolved = yield* SessionRunnerModel.fromCatalogModel(
|
||||||
|
model(ProviderV2.aisdk("@ai-sdk/openai"), {
|
||||||
|
modelID: "gpt-5.2",
|
||||||
|
settings: { baseURL: "https://openai.example/v1" },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
const prepared = yield* LLMClient.prepare(LLM.request({ model: resolved, prompt: "Hello" }))
|
||||||
|
|
||||||
|
expect(prepared.body).toMatchObject({ reasoning: { summary: "auto" } })
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
it.effect("keeps catalog apiKey credentials out of provider JSON", () =>
|
it.effect("keeps catalog apiKey credentials out of provider JSON", () =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const resolved = yield* SessionRunnerModel.fromCatalogModel(
|
const resolved = yield* SessionRunnerModel.fromCatalogModel(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import * as OpenAIResponses from "../protocols/openai-responses"
|
||||||
import { withOpenAIOptions, type OpenAIProviderOptionsInput } from "./openai-options"
|
import { withOpenAIOptions, type OpenAIProviderOptionsInput } from "./openai-options"
|
||||||
|
|
||||||
export type { OpenAIOptionsInput, OpenAIResponseIncludable } from "./openai-options"
|
export type { OpenAIOptionsInput, OpenAIResponseIncludable } from "./openai-options"
|
||||||
|
export * as OpenAIProviderOptions from "./openai-options"
|
||||||
|
|
||||||
export const id = ProviderID.make("openai")
|
export const id = ProviderID.make("openai")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue