v5 typesafe tool call issue #7004
Replies: 3 comments 3 replies
-
|
@thdxr can you provide a code example that breaks for you? ideally you would leave it untyped in that case but we need to explore where exactly this breaks down and if it possible to fix. |
Beta Was this translation helpful? Give feedback.
-
|
Is the issue only the typing on the frontend? because then you can do something like this in the react code: if (part.type.startsWith('tool-')) {
const toolPart: ToolUIPart<UITools> = part as ToolUIPart<UITools>;
switch (toolPart.state) {
case 'input-available':
const input = toolPart.input as any;
return (
<div key={index} className="text-gray-500">
{input.message}
</div>
);
case 'output-available':
const output = toolPart.output as any;
return (
<div key={index} className="text-gray-500">
Location access allowed: {output}
</div>
);
}For zod, is it possible to use Noted on the overall issue thought. Not sure if a good solution for OpenAPI exists since it does not support prefixes. |
Beta Was this translation helpful? Give feedback.
-
|
This discussion was automatically locked because it has not been updated in over 30 days. If you still have questions about this topic, please ask us at community.vercel.com/ai-sdk |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
in v5 with the change in how tool call parts look: https://ai-sdk.dev/docs/announcing-ai-sdk-5-beta#type-safe-tool-calls
this has made it massively more complex for us because we use this format in an openapi spec. this list of tools are configured by the end user so we can't really know them ahead of time
this means it's difficult to represent this as zod, as an openapi spec, codegen for a golang client - these are all places where we use the format
to put it another way - making a string template literal part of the top level union means languages that don't have that concept cannot deal with it. it's fine when nested because it can be ignored
i'm assuming it's too late now to change anything (although things were fine in the alpha) but wanted to ask anyway
Beta Was this translation helpful? Give feedback.
All reactions