From fc20406845ccd8abec86f7551d4459b50f394847 Mon Sep 17 00:00:00 2001 From: Brandon Allen Date: Wed, 22 Apr 2026 15:54:50 -0400 Subject: [PATCH] fix(client): drop v1-incompat discriminator on InputItem (b48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- clients/python/llmengine/data_types/gen/openai.py | 2 +- clients/python/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/python/llmengine/data_types/gen/openai.py b/clients/python/llmengine/data_types/gen/openai.py index 841ee570..73ed01fd 100644 --- a/clients/python/llmengine/data_types/gen/openai.py +++ b/clients/python/llmengine/data_types/gen/openai.py @@ -11516,7 +11516,7 @@ class EvalRunList(BaseModel): class InputItem(BaseModel): __root__: Annotated[ - Union[EasyInputMessage, Item, ItemReferenceParam], Field(discriminator="type") + Union[EasyInputMessage, Item, ItemReferenceParam], Field() ] diff --git a/clients/python/pyproject.toml b/clients/python/pyproject.toml index af9ed901..eed80b28 100644 --- a/clients/python/pyproject.toml +++ b/clients/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "scale-llm-engine" -version = "0.0.0.beta47" +version = "0.0.0.beta48" description = "Scale LLM Engine Python client" license = "Apache-2.0" authors = ["Phil Chen "]