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

Transform response before parsing JSON #4710

Open
egoist opened this issue Feb 5, 2025 · 3 comments
Open

Transform response before parsing JSON #4710

egoist opened this issue Feb 5, 2025 · 3 comments
Labels
ai/core enhancement New feature or request

Comments

@egoist
Copy link
Contributor

egoist commented Feb 5, 2025

Feature Description

When generating structured output (like generateObject), some models like DeepSeek v3 failed to follow the instructions and generate json in a code block instead:

Image

which makes ai sdk throw the following error:

No object generated: could not parse the response.

It would be nice if we can modify the output the remove the code fence before ai sdk starts to parse it

Use Cases

make json response work in other models

Additional context

No response

@egoist egoist added the enhancement New feature or request label Feb 5, 2025
@lgrammel
Copy link
Collaborator

lgrammel commented Feb 5, 2025

You could try implementing a custom middleware as a short term solution.

@egoist
Copy link
Contributor Author

egoist commented Feb 5, 2025

thanks, that worked, closing this 😄

@egoist egoist closed this as completed Feb 5, 2025
@lgrammel
Copy link
Collaborator

lgrammel commented Feb 5, 2025

keeping open for now in case we add something dedicated to the sdk

@lgrammel lgrammel reopened this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants