Skip to content

Commit 237b404

Browse files
scale-ballenclaude
andauthored
fix(client): drop v1-incompat discriminator on InputItem (b48) (#814)
InputItem's __root__ union uses Field(discriminator="type"), but one of its submodels (Item) is itself a RootModel union whose nested submodels don't satisfy pydantic v1 compat's strict discriminator requirements. Under pydantic v2 with v1 compat, class definition fails at import: pydantic.v1.errors.ConfigError: Field 'type' is not the same for all submodels of 'Item' This is the same fix Brandon applied in 1d50898 (feat: support openai 2 in python client), which was wiped out by a subsequent codegen regen. Dropping the discriminator on InputItem makes it a regular Union (try- each validation). Valid data still deserializes into the correct submodel because each has a Literal[...] type field — only the matching submodel validates. JSON input/output is byte-identical. Minimal patch. Other 9 discriminator="type" sites in gen/openai.py are left intact; they don't recursively reference RootModel unions so they don't hit the v1-compat failure. Local verification: - Before: `from llmengine import Completion, Model` raises ConfigError - After: imports cleanly; ChatCompletionV2Request/Response work; all 9 Item submodels import; InputItem/Item/ItemResource/OutputItem1 import; InputMessage instantiation + validation roundtrips Follow-ups: - Fix OpenAPI schema or datamodel-code-generator config so next regen doesn't re-introduce the bug - Add import smoke test to llm-engine CI under pydantic 2 + v1 compat Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 45e1e50 commit 237b404

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

clients/python/llmengine/data_types/gen/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11516,7 +11516,7 @@ class EvalRunList(BaseModel):
1151611516

1151711517
class InputItem(BaseModel):
1151811518
__root__: Annotated[
11519-
Union[EasyInputMessage, Item, ItemReferenceParam], Field(discriminator="type")
11519+
Union[EasyInputMessage, Item, ItemReferenceParam], Field()
1152011520
]
1152111521

1152211522

clients/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scale-llm-engine"
3-
version = "0.0.0.beta47"
3+
version = "0.0.0.beta48"
44
description = "Scale LLM Engine Python client"
55
license = "Apache-2.0"
66
authors = ["Phil Chen <phil.chen@scale.com>"]

0 commit comments

Comments
 (0)