(
route: string,
toolChoice: NonNullable<LLMRequest["toolChoice"]>,
cases: {
readonly auto: () => Auto
readonly none: () => None
readonly required: () => Required
readonly tool: (name: string) => Tool
},
)
| 263 | }) |
| 264 | |
| 265 | export const matchToolChoice = <Auto, None, Required, Tool>( |
| 266 | route: string, |
| 267 | toolChoice: NonNullable<LLMRequest["toolChoice"]>, |
| 268 | cases: { |
| 269 | readonly auto: () => Auto |
| 270 | readonly none: () => None |
| 271 | readonly required: () => Required |
| 272 | readonly tool: (name: string) => Tool |
| 273 | }, |
| 274 | ) => |
| 275 | Effect.gen(function* () { |
| 276 | if (toolChoice.type === "auto") return cases.auto() |
| 277 | if (toolChoice.type === "none") return cases.none() |
| 278 | if (toolChoice.type === "required") return cases.required() |
| 279 | if (!toolChoice.name) return yield* invalidRequest(`${route} tool choice requires a tool name`) |
| 280 | return cases.tool(toolChoice.name) |
| 281 | }) |
| 282 | |
| 283 | type ContentType = ContentPart["type"] |
| 284 |
nothing calls this directly
no test coverage detected