-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add StructuredDict for structured outputs with custom JSON schema
#2157
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
Conversation
Implemented StructuredDict for getting structured python dictionary as output type.
PR Change SummaryImplemented StructuredDict for structured outputs, providing a JSON schema enforcement for structured data in agents.
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
…inferred correctly. Also add name and description arguments
|
@fswair I pushed a commit with some tweaks to make the type of I also added Finally, I think we should not claim this provides validation, as we depend on completely on the model's understanding of the JSON schema and don't do any Pydantic validation or something like that -- we just pass the What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better, yes, thank you!
|
i've updated docs with more correct description but its still --not enough-- description and removed prints that causes error. |
|
@DouweM can u review this doc before merge: https://github.com/fswair/pydantic-ai/blob/structured_dict/docs/output.md line 390 |
StructuredDict for structured outputs with custom JSON schema
# Conflicts: # tests/test_examples.py
|
yeah it looks nice |
Implemented StructuredDict for getting structured python dictionary as output type.
Structured Dict
A dictionary subclass that enforces a JSON schema for structured dict.
This class serves as both a container for structured data and the schema itself, making it suitable for use as an output type in agents that require validated dictionary responses.