-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add output_json_schema method to Agent class #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. |
| if isinstance(output, ObjectOutputProcessor): | ||
| processor = output | ||
| else: | ||
| processor = ObjectOutputProcessor(output=output, strict=strict) |
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.
Why did we need to change this?
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 modify UnionOutputProcessor so that toolset output processors can be unioned with additional output types (like str, BinaryImage, DeferredToolRequests). Maybe I shouldn't be using toolset.processors?
|
@DouweM thanks for the reviews so far. The PR has an issue where it always adds
allows_text to True. This doesn't seem right but I'll wait for confirmation.
|
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'} {'type': 'object', 'properties': {'result': {'anyOf': [{'type': 'object', 'properties': {'kind': {'type': 'string', 'const': 'final_result'}, 'data': {'properties': {'response': {'type': 'boolean'}}, 'required': ['response'], 'type': 'object'}}, 'required': ['kind', 'data'], 'additionalProperties': False, 'title': 'final_result'}]}}, 'required': ['result'], 'additionalProperties': False}Closes #3225