fix: make FunctionParameters and LogitBias OpenAI-compatible#1039
Conversation
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
|
@planetf1 don't want to assign you work but fyi this is an issue raised from your feedback |
272960a to
f0fc46b
Compare
|
The core fix looks solid — switching |
|
Minor / non-blocking: small gotcha with the alias — j = JsonSchemaFormat(name="test", schema={"type": "object"})
j.model_dump()
# → {"name": "test", "schema_": {"type": "object"}}For the current code path — where |
|
Minor / non-blocking: one gap worth noting in the test coverage — there's no HTTP-layer test that sends the old |
planetf1
left a comment
There was a problem hiding this comment.
One issue worth sorting before this lands — the silent {"RootModel": {...}} pass-through on FunctionParameters (see inline comment). For a breaking API change, clients that haven't updated yet deserving a clear error rather than a confusing inference failure downstream.
The other comments are minor and non-blocking.
planetf1
left a comment
There was a problem hiding this comment.
Both issues addressed — happy with the validator approach and the LogitBias cleanup. LGTM.
Use Pydantic's RootModel to accept bare JSON Schema dicts instead of
requiring a non-standard RootModel wrapper field. This makes m serve
compatible with standard OpenAI clients.
BREAKING CHANGE: FunctionParameters(RootModel={...}) is now FunctionParameters({...})
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Assisted-by: IBM Bob
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
The updated bare dict for OpenAI API compatibility would still
accept a key named RootModel, but the behavior would be wrong.
To assist in migration add validation and reject the legacy
wrapper.
BREAKING CHANGE: FunctionParameters validator now rejects {"RootModel": {...}}
envelope pattern. Send parameters as bare JSON Schema objects instead.
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Assisted-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Add serialize_by_alias=True to JsonSchemaFormat.model_config to ensure schema_ field serializes as "schema" not "schema_" for OpenAI compatibility. Add test coverage for serialization behavior. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> Assisted-by: IBM Bob
933b71a
…ive-computing#1039) * fix: make FunctionParameters and LogitBias OpenAI-compatible Use Pydantic's RootModel to accept bare JSON Schema dicts instead of requiring a non-standard RootModel wrapper field. This makes m serve compatible with standard OpenAI clients. BREAKING CHANGE: FunctionParameters(RootModel={...}) is now FunctionParameters({...}) Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> Assisted-by: IBM Bob * test(cli): update tests and example removing RootModel Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> * chore: remove unused LogitBias model Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> * feat!: reject legacy RootModel envelope in function parameters The updated bare dict for OpenAI API compatibility would still accept a key named RootModel, but the behavior would be wrong. To assist in migration add validation and reject the legacy wrapper. BREAKING CHANGE: FunctionParameters validator now rejects {"RootModel": {...}} envelope pattern. Send parameters as bare JSON Schema objects instead. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> Assisted-by: Mark Sturdevant <mark.sturdevant@ibm.com> * fix(serve): serialize JsonSchemaFormat with 'schema' alias Add serialize_by_alias=True to JsonSchemaFormat.model_config to ensure schema_ field serializes as "schema" not "schema_" for OpenAI compatibility. Add test coverage for serialization behavior. Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com> Assisted-by: IBM Bob --------- Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Misc PR
Type of PR
Description
"RootModel"key is non-standard and will cause any real OpenAI-compatible client to fail. #971fix: make FunctionParameters and LogitBias OpenAI-compatible
Testing
Attribution