-
Notifications
You must be signed in to change notification settings - Fork 976
fix: add type safety for tool output schemas in ToolCallback #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: add type safety for tool output schemas in ToolCallback #670
Conversation
3f68c37
to
08808a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sushichan044 many thanks for doing this! One minor suggestion inline for the server example.
@@ -43,7 +43,7 @@ server.registerTool( | |||
void country; | |||
// Simulate weather API call | |||
const temp_c = Math.round((Math.random() * 35 - 5) * 10) / 10; | |||
const conditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"][Math.floor(Math.random() * 5)]; | |||
const conditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"][Math.floor(Math.random() * 5)] as unknown as "sunny" | "cloudy" | "rainy" | "stormy" | "snowy"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const conditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"][Math.floor(Math.random() * 5)] as unknown as "sunny" | "cloudy" | "rainy" | "stormy" | "snowy"; | |
const weatherConditions = ["sunny", "cloudy", "rainy", "stormy", "snowy"] as const; | |
const conditions = weatherConditions[Math.floor(Math.random() * 5)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bhosmer-ant yes, that's more concise 🙏
fixed: fb303d7
Motivation and Context
Enhances
ToolCallback
to support type-safe structured outputsby introducing a second generic parameter for the output schema.
fixes: #669
How Has This Been Tested?
Passing all existing tests.
No need for adding new tests as no change for runtime behavior.
Breaking Changes
None.
Types of changes
Checklist
Additional context