Skip to content

Comments

Add schemas support to OpenAI models#16

Merged
tonybaloney merged 11 commits intotonybaloney:mainfrom
MattKotsenas:feature/schemas
May 26, 2025
Merged

Add schemas support to OpenAI models#16
tonybaloney merged 11 commits intotonybaloney:mainfrom
MattKotsenas:feature/schemas

Conversation

@MattKotsenas
Copy link
Contributor

Fixes #15

Add schemas support. Via a quick test, only the newer OpenAI models support JsonSchemaFormat currently.

@MattKotsenas
Copy link
Contributor Author

@tonybaloney, would you mind taking a look at this? If you have any questions, please let me know. Thanks!

@tonybaloney
Copy link
Owner

Yes, sorry I've been really busy the last week or so

@MattKotsenas
Copy link
Contributor Author

No worries!

@MattKotsenas
Copy link
Contributor Author

I see now that this should all be driven off the models.json file. I have a script incoming to automate downloading a new version, and then I'll update this to match.

@tonybaloney
Copy link
Owner

Can you update the script to populate this field, also I added an extra formatting step (ruff format) to your other PR with the tool metadata so that the quotes are consistent (") with the rest of the code.

@tonybaloney
Copy link
Owner

Updating the script and re-running it will make rebasing a lot easier

@MattKotsenas
Copy link
Contributor Author

Updated!

Copy link
Owner

@tonybaloney tonybaloney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Works really well on 4.1 series models

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for JSON schema-based responses in GitHub-hosted OpenAI models, enabling schema validation for newer models.

  • Introduces supports_schemas in the model‐parsing tool
  • Extends CHAT_MODELS tuples and GitHubModels to include a supports_schema flag
  • Updates execute to generate JsonSchemaFormat when prompt.schema is provided
  • Adds tests for supported and unsupported schema usage
  • Bumps llm dependency to >=0.23

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tools/parse_models_json.py Added supports_schemas helper
tests/test_llm_github_models.py Imported BaseModel, added schema tests
pyproject.toml Bumped llm dependency version
llm_github_models.py Expanded model tuple entries, added supports_schema handling in execute
Comments suppressed due to low confidence (5)

tools/parse_models_json.py:17

  • The function name supports_schemas doesn't match the flag supports_schema used elsewhere. Consider renaming it to supports_schema for consistency.
def supports_schemas(name):

llm_github_models.py:268

  • There's no test covering the branch where a raw dict schema is passed. Add a test to verify prompt.schema as a dict is correctly forwarded to JsonSchemaFormat.
schema=prompt.schema # type: ignore[variable]

llm_github_models.py:281

  • The chunks list is created but never used. Consider removing it or utilizing it to populate response.response_json instead of the TODO placeholder.
chunks = []

pyproject.toml:12

  • The code now imports and uses pydantic.BaseModel but pydantic isn't declared as a dependency. Please add pydantic>=1.x to dependencies.
"llm>=0.23",

llm_github_models.py:250

  • Changing the api_version globally may break compatibility for models that required a special preview version previously (e.g., o3-mini). Confirm that the new version works for all models or reintroduce model-specific overrides.
extra["api_version"] = "2025-03-01-preview" # Use latest version

@tonybaloney tonybaloney merged commit bbf4973 into tonybaloney:main May 26, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support schemas / structured output

2 participants