feat(ai): support custom reasoning fields (#38227)

This commit is contained in:
Aiden Cline 2026-07-21 23:42:59 -05:00 committed by GitHub
commit 23483ea013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 306 additions and 67 deletions

View file

@ -209,14 +209,14 @@ export const fromCatalogModel = (
return Effect.succeed(
withDefaults(resolved, OpenAIResponses.route)
.with({ auth: key === undefined ? Auth.none : Auth.bearer(key) })
.model({ id: resolved.modelID ?? resolved.id }),
.model({ id: resolved.modelID ?? resolved.id, compatibility: resolved.compatibility }),
)
}
if (ProviderV2.isAISDK(resolved.package) && packageName === "@ai-sdk/anthropic") {
return Effect.succeed(
withDefaults(resolved, AnthropicMessages.route)
.with({ auth: key === undefined ? Auth.none : Auth.header("x-api-key", key) })
.model({ id: resolved.modelID ?? resolved.id }),
.model({ id: resolved.modelID ?? resolved.id, compatibility: resolved.compatibility }),
)
}
if (
@ -227,7 +227,7 @@ export const fromCatalogModel = (
return Effect.succeed(
withDefaults(resolved, OpenAICompatibleChat.route)
.with({ auth: key === undefined ? Auth.none : Auth.bearer(key) })
.model({ id: resolved.modelID ?? resolved.id }),
.model({ id: resolved.modelID ?? resolved.id, compatibility: resolved.compatibility }),
)
}
if (ProviderV2.isAISDK(resolved.package)) {
@ -257,8 +257,15 @@ export const fromCatalogModel = (
limits: { context: resolved.limit.context, output: resolved.limit.output },
}
return yield* Effect.try({
try: () =>
Model.update(module.model(resolved.modelID ?? resolved.id, settings), { provider: resolved.providerID }),
try: () => {
const runtime = module.model(resolved.modelID ?? resolved.id, settings)
return Model.update(runtime, {
provider: resolved.providerID,
compatibility: resolved.compatibility
? { ...runtime.compatibility, ...resolved.compatibility }
: runtime.compatibility,
})
},
catch: () => unsupported(resolved),
})
})
@ -302,7 +309,7 @@ const codexModel = (
account === undefined ? Auth.none : Auth.headers({ "chatgpt-account-id": account }),
),
})
.model({ id: model.modelID ?? model.id })
.model({ id: model.modelID ?? model.id, compatibility: model.compatibility })
}
const unsupported = (model: ModelV2.Info) =>