Skip to content
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

fix(render): parse the args based on the zod schema #1119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IdoPesok
Copy link
Contributor

@IdoPesok IdoPesok commented Mar 6, 2024

#1065 Take 3

#1065 was reverted in #1080 due to a bug where the toolCallPayload.func.arguments were a string rather than a Record. In #1113 this behavior was fixed so now that bug should be gone since Zod will be parsing the object.

@lgrammel
Copy link
Collaborator

lgrammel commented May 8, 2024

We recommend using streamUI instead of render (which is now deprecated). Would this also apply to streamUI?

@unstubbable
Copy link
Contributor

unstubbable commented May 8, 2024

In streamUI, this is now handled via safeParseJSON, see:

const parseResult = safeParseJSON({
text: value.args,
schema: tool.parameters,
});
if (parseResult.success === false) {
throw new InvalidToolArgumentsError({
toolName,
toolArgs: value.args,
cause: parseResult.error,
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants