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

DOC: <Issue related to /docs/tutorials/classification/> #7764

Open
2 tasks done
IBJunior opened this issue Feb 26, 2025 · 1 comment
Open
2 tasks done

DOC: <Issue related to /docs/tutorials/classification/> #7764

IBJunior opened this issue Feb 26, 2025 · 1 comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder

Comments

@IBJunior
Copy link

Checklist

  • I added a very descriptive title to this issue.
  • I included a link to the documentation page I am referring to (if applicable).

Issue with current documentation:

Issue with Zod Schema for classificationSchema in OpenAI Model

While following this tutorial, I encountered an issue with the schema created using Zod for classificationSchema. I was using an OpenAI model, but it appears that their structured output does not yet support minimum and maximum constraints on the Integer type, as mentioned in the documentation: https://platform.openai.com/docs/guides/structured-outputs/some-type-specific-keywords-are-not-yet-supported.

Here is the schema creation in the tutorial :

const classificationSchema = z.object({
  sentiment: z.string().describe("The sentiment of the text"),
  aggressiveness: z
    .number()
    .int()
    .min(1)
    .max(10)
    .describe("How aggressive the text is on a scale from 1 to 10"),
  language: z.string().describe("The language the text is written in"),
});

Removing the min and max constraints and specifying them in the description resolved the issue.

Idea or request for content:

No response

Copy link

dosubot bot commented Feb 26, 2025

Hello, @IBJunior! I'm here to help you with any bugs, questions, or contributions you have. Let's take a look at the issue you've encountered.

The issue you're encountering with the classificationSchema in the LangChainJS tutorial is due to the OpenAI model's current limitations in supporting min and max constraints for integer types in structured outputs. As you've discovered, a workaround is to remove these constraints from the Zod schema and instead specify them in the description. This approach allows you to maintain the intended validation logic while adhering to the model's capabilities. If you have further questions or need additional assistance, feel free to ask!

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added the auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder
Projects
None yet
Development

No branches or pull requests

1 participant