Created
December 15, 2025 04:48
-
-
Save slashthinking/88bbcb4f9e6488b1f1a0cda275e1e879 to your computer and use it in GitHub Desktop.
使用ProviderToolSchema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // packages/anthropic/src/tool/code-execution_20250522.ts | |
| import { | |
| createProviderToolFactoryWithOutputSchema, | |
| lazySchema, | |
| zodSchema, | |
| } from '@ai-sdk/provider-utils'; | |
| import { z } from 'zod/v4'; | |
| export const codeExecution_20250522OutputSchema = lazySchema(() => | |
| zodSchema( | |
| z.object({ | |
| type: z.literal('code_execution_result'), | |
| stdout: z.string(), | |
| stderr: z.string(), | |
| return_code: z.number(), | |
| }), | |
| ), | |
| ); | |
| const codeExecution_20250522InputSchema = lazySchema(() => | |
| zodSchema( | |
| z.object({ | |
| code: z.string(), | |
| }), | |
| ), | |
| ); | |
| const factory = createProviderToolFactoryWithOutputSchema< | |
| { | |
| /** | |
| * The Python code to execute. | |
| */ | |
| code: string; | |
| }, | |
| { | |
| type: 'code_execution_result'; | |
| stdout: string; | |
| stderr: string; | |
| return_code: number; | |
| }, | |
| {} | |
| >({ | |
| id: 'anthropic.code_execution_20250522', | |
| inputSchema: codeExecution_20250522InputSchema, | |
| outputSchema: codeExecution_20250522OutputSchema, | |
| }); | |
| export const codeExecution_20250522 = ( | |
| args: Parameters<typeof factory>[0] = {}, | |
| ) => { | |
| return factory(args); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment