(
toolUseBlock: Extract<BetaContentBlock, { type: 'tool_use' }>,
schema: T,
)
| 28 | * Returns null if parsing fails. |
| 29 | */ |
| 30 | export function parseClassifierResponse<T extends z.ZodTypeAny>( |
| 31 | toolUseBlock: Extract<BetaContentBlock, { type: 'tool_use' }>, |
| 32 | schema: T, |
| 33 | ): z.infer<T> | null { |
| 34 | const parseResult = schema.safeParse(toolUseBlock.input) |
| 35 | if (!parseResult.success) { |
| 36 | return null |
| 37 | } |
| 38 | return parseResult.data |
| 39 | } |
no outgoing calls
no test coverage detected