mirror of
https://github.com/openai/codex.git
synced 2026-09-17 12:23:33 +00:00
Preserve ImageUserInput in the Python SDK (#45796)
Keep the existing public class name for URL-based image input when regenerating the SDK. Map `UrlUserInput` to `ImageUserInput` during artifact generation and update the generated model and `UserInput` union accordingly. Extend the class-name stability test to assert that `ImageUserInput` remains importable under its expected name. GitOrigin-RevId: 6cbbd555e2e07904cc5fbc279e1e61ff089ac0a9
This commit is contained in:
committed by
copyberry
parent
7b8b17b97a
commit
63c09ed212
@@ -587,6 +587,7 @@ def _preserve_inline_image_class_names(out_path: Path) -> None:
|
||||
"""Keep the public class names used before ImageReference was introduced."""
|
||||
source = out_path.read_text()
|
||||
stable_names = {
|
||||
"UrlUserInput": "ImageUserInput",
|
||||
"ImageUrlContentItem": "InputImageContentItem",
|
||||
"ImageUrlFunctionCallOutputContentItem": "InputImageFunctionCallOutputContentItem",
|
||||
}
|
||||
|
||||
@@ -6240,7 +6240,7 @@ class TextUserInput(BaseModel):
|
||||
type: Annotated[Literal["text"], Field(title="TextUserInputType")]
|
||||
|
||||
|
||||
class UrlUserInput(BaseModel):
|
||||
class ImageUserInput(BaseModel):
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
)
|
||||
@@ -6304,7 +6304,7 @@ class MentionUserInput(BaseModel):
|
||||
class UserInput(
|
||||
RootModel[
|
||||
TextUserInput
|
||||
| UrlUserInput
|
||||
| ImageUserInput
|
||||
| FileIdUserInput
|
||||
| LocalImageUserInput
|
||||
| AudioUserInput
|
||||
@@ -6318,7 +6318,7 @@ class UserInput(
|
||||
)
|
||||
root: (
|
||||
TextUserInput
|
||||
| UrlUserInput
|
||||
| ImageUserInput
|
||||
| FileIdUserInput
|
||||
| LocalImageUserInput
|
||||
| AudioUserInput
|
||||
|
||||
@@ -539,10 +539,12 @@ def test_generated_chatgpt_account_email_is_required_nullable() -> None:
|
||||
def test_generated_inline_image_class_names_remain_stable() -> None:
|
||||
"""Keep the existing Python class names when image references expand."""
|
||||
from openai_codex.generated.v2_all import (
|
||||
ImageUserInput,
|
||||
InputImageContentItem,
|
||||
InputImageFunctionCallOutputContentItem,
|
||||
)
|
||||
|
||||
assert ImageUserInput.__name__ == "ImageUserInput"
|
||||
assert InputImageContentItem.__name__ == "InputImageContentItem"
|
||||
assert (
|
||||
InputImageFunctionCallOutputContentItem.__name__
|
||||
|
||||
Reference in New Issue
Block a user