-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
core: Add additional properties recursively for structured output(openai) when nested object is generated #25169
core: Add additional properties recursively for structured output(openai) when nested object is generated #25169
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
) -> None: | ||
"""Test to verify structured output with strict=True for nested object.""" | ||
|
||
from typing import TypedDict |
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.
now, pydantic outputs json schema includes 'allOf', but openai don't support.
pydantic PR → pydantic/pydantic#10029
BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for response_format 'JokeWithEvaluation': In context=('properties', 'self_evaluation'), 'allOf' is not permitted", 'type': 'invalid_request_error', 'param': 'response_format', 'code': None}}
full error: https://gist.github.com/fufufukakaka/0f638b40687a00fc712819f7b3dd0b5e
So, I'll only implement tests using TypedDict. 🙏
When is this expected to be merged? would be super useful |
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.
could we add unit tests for this functionality instead of integration tests?
thank you @fufufukakaka! will be out in langchain-core 0.2.35, which will be released later today |
thanks! |
Hello.
First of all, thank you for maintaining such a great project.
Description
In #25123, support for structured_output is added. However,
"additionalProperties": false
needs to be included at all levels when a nested object is generated.error from current code: https://gist.github.com/fufufukakaka/e9b475300e6934853d119428e390f204
Reference: Introducing Structured Outputs in the API
In the current code,
"additionalProperties": false
is only added at the last level.This PR introduces the
_add_additional_properties_key
function, which recursively adds"additionalProperties": false
to the entire JSON schema for the request.Twitter handle:
@fukkaa1225
Thank you!