Skip to content

⚡️ Speed up method OpenAIJsonSchemaTransformer.transform by 18% #28

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

Open
wants to merge 1 commit into
base: try-refinement
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pydantic_ai_slim/pydantic_ai/profiles/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ def transform(self, schema: JsonSchema) -> JsonSchema: # noqa C901
schema['anyOf'] = [{'$ref': schema.pop('$ref')}]

# Track strict-incompatible keys
incompatible_values: dict[str, Any] = {}
for key in _STRICT_INCOMPATIBLE_KEYS:
value = schema.get(key, _sentinel)
if value is not _sentinel:
incompatible_values[key] = value
incompatible_values = {k: schema[k] for k in _STRICT_INCOMPATIBLE_KEYS if k in schema}
description = schema.get('description')
if incompatible_values:
if self.strict is True:
Expand Down
Loading