Commit 237b404
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11516 | 11516 | | |
11517 | 11517 | | |
11518 | 11518 | | |
11519 | | - | |
| 11519 | + | |
11520 | 11520 | | |
11521 | 11521 | | |
11522 | 11522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments