wip
parent
61ba844234
commit
bacf705ee5
|
|
@ -3,6 +3,7 @@ import { unique } from "remeda"
|
|||
import type { JSONSchema } from "zod/v4/core"
|
||||
import type { Provider } from "./provider"
|
||||
import type { ModelsDev } from "./models"
|
||||
import type { MessageV2 } from "@/session/message-v2"
|
||||
|
||||
type Modality = NonNullable<ModelsDev.Model["modalities"]>["input"][number]
|
||||
|
||||
|
|
@ -210,6 +211,38 @@ export namespace ProviderTransform {
|
|||
return undefined
|
||||
}
|
||||
|
||||
export function thinking(model: Provider.Model, thinking: MessageV2.Thinking) {
|
||||
if (!model.capabilities.reasoning) return undefined
|
||||
|
||||
switch (model.api.npm) {
|
||||
case "@openrouter/ai-sdk-provider":
|
||||
return {
|
||||
reasoning: { effort: thinking.effort },
|
||||
}
|
||||
case "@ai-sdk/openai-compatible":
|
||||
const result: Record<string, any> = {
|
||||
reasoningEffort: thinking.effort,
|
||||
}
|
||||
|
||||
if (model.providerID === "baseten") {
|
||||
result["chat_template_args"] = { enable_thinking: true }
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
case "@ai-sdk/openai":
|
||||
return {
|
||||
reasoningEffort: thinking.effort,
|
||||
reasoningSummary: "auto",
|
||||
include: ["reasoning.encrypted_content"],
|
||||
}
|
||||
|
||||
case "@ai-sdk/anthropic":
|
||||
// TODO: map to thinking budgets
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function options(
|
||||
model: Provider.Model,
|
||||
sessionID: string,
|
||||
|
|
|
|||
|
|
@ -286,6 +286,9 @@ export namespace MessageV2 {
|
|||
sessionID: z.string(),
|
||||
})
|
||||
|
||||
export const Thinking = z.object({ effort: z.enum(["low", "medium", "high"]) })
|
||||
export type Thinking = z.infer<typeof Thinking>
|
||||
|
||||
export const User = Base.extend({
|
||||
role: z.literal("user"),
|
||||
time: z.object({
|
||||
|
|
@ -305,6 +308,7 @@ export namespace MessageV2 {
|
|||
}),
|
||||
system: z.string().optional(),
|
||||
tools: z.record(z.string(), z.boolean()).optional(),
|
||||
thinking: Thinking.optional(),
|
||||
}).meta({
|
||||
ref: "UserMessage",
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue