-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Provide a safeparse / way to access the result in case of zod schema validation error #3451
Comments
Wanted to add some additional context here. In the example below, the LLM gets it super close, but it just added a bit of text that causes the enum parse to fail. This is fairly common and we can expect / fix this, but we just need a chance to do it before the entire thing throws an error. The big problem with this throwing an error is now we cannot access the full response from the LLM provider. We cannot track usage data on this request which was technically successful. We are able to grab the output value and handle this, but it's not very ergonomic since now this has to be handled/returned from a catch block. In the example below, LLM gives "Wisdom (Insight) Check" when it should have given "Wisdom Check" (we can fix this particular issue with some better instruction, but still think we need a way to access the original response from the LLM provider / have a safeParse option)
|
Feature Description
Provide a safeparse / way to access the result in case of zod schema validation error.
Use Case
Sometimes we get a response that fails zod validation but is perfectly usable. In these cases, we'd rather not throw a validation error and instead would prefer to continue.
Additional context
No response
The text was updated successfully, but these errors were encountered: