-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Agent.output_json_schema() method
#3454
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
base: main
Are you sure you want to change the base?
Conversation
|
@DouweM is there a source of truth I can reference for what the schema output should be for tests? I think I will get stuck figuring this out so any guidance will be appreciated. Edit: I added snapshots of expected output to the tests. Please review them carefully as I'm guessing what they are supposed to be. |
|
@DouweM thanks for the reviews so far. Fixed:
allows_text to True. This doesn't seem right but I'll wait for confirmation.
|
|
@DouweM how should duplicate tool output types be handled? For example: Can it be: Or should duplicates be removed? |
|
@DouweM ready for review. The test failure doesn't appear to be from this PR. I have one question about whether we should remove duplicate output types: #3454 (comment) |
|
@g-eoj Yeah that's fine to be deduplicated. The code using I'll do another review later or early next week, I have some some more PRs to get through :) |
tests/test_agent_output_schemas.py
Outdated
| 'enum': ['audio/wav', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/aiff', 'audio/aac'], | ||
| 'type': 'string', | ||
| }, | ||
| {'enum': ['image/jpeg', 'image/png', 'image/gif', 'image/webp'], 'type': 'string'}, |
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.
Hmm, we really should only have this type in this case, as BinaryImage is essentially a BinaryContent with is_image guaranteed to be true. Fixing this may require tweaking of BinaryImage though.
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.
Should try to tweak BinaryImage in this PR? Or make a separate issue?
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.
@g-eoj I'd like to do it in this PR if it's not too complicated
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.
I'll give it a try
Agent.output_json_schema() method
|
@DouweM can you look at the approach I'm taking now? I'm not getting any info from |
| self._system_prompt_functions.append(_system_prompt.SystemPromptRunner[AgentDepsT](func, dynamic=dynamic)) | ||
| return func | ||
|
|
||
| def output_json_schema(self, output_type: OutputSpec[OutputDataT | RunOutputDataT] | None = None) -> JsonSchema: |
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.
@g-eoj This is so much cleaner that I'm a little embarrassed I didn't come up with it before.
This PR adds a method to get the json schema for agent output.
It aims to support all output types, including special ones:
BinaryImageDeferredToolRequestsSimple example:
{'type': 'string'}Override agent output types:
{'type': 'bool'}Closes #3225