You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constclassificationSchema=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
The text was updated successfully, but these errors were encountered:
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!
Checklist
Issue with current documentation:
Issue with Zod Schema for
classificationSchema
in OpenAI ModelWhile 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 supportminimum
andmaximum
constraints on theInteger
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 :
Removing the
min
andmax
constraints and specifying them in the description resolved the issue.Idea or request for content:
No response
The text was updated successfully, but these errors were encountered: