mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
[sdk/python] Stop advertising HTTP image URLs (#29464)
## Summary - use generated image data URLs in the Python SDK examples and notebook - document HTTP and HTTPS image URLs as deprecated and recommend `LocalImageInput` - replace the remote-URL integration test with data-URL coverage `ImageInput` remains available for data URLs. The SDK does not duplicate app-server URL validation. ## Testing - `uv run --frozen --no-sync ruff check --output-format=full .` - `uv run --frozen --no-sync ruff format --check .` - full Python SDK test suite with an isolated writable `CODEX_SQLITE_HOME` (119 passed, 38 skipped)
This commit is contained in:
committed by
GitHub
Unverified
parent
5b95745eae
commit
20431d49a0
@@ -1,40 +1,45 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
|
||||
from app_server_harness import AppServerHarness
|
||||
from app_server_helpers import TINY_PNG_BYTES
|
||||
|
||||
from openai_codex import Codex, ImageInput, LocalImageInput, SkillInput, TextInput
|
||||
|
||||
|
||||
def test_remote_image_input_reaches_responses_api(
|
||||
def test_data_url_image_input_reaches_responses_api(
|
||||
tmp_path,
|
||||
) -> None:
|
||||
"""Remote image inputs should survive the SDK and app-server boundary."""
|
||||
remote_image_url = "https://example.com/codex.png"
|
||||
"""Data URL image inputs should survive the SDK and app-server boundary."""
|
||||
image_data_url = "data:image/png;base64," + base64.b64encode(TINY_PNG_BYTES).decode("ascii")
|
||||
|
||||
with AppServerHarness(tmp_path) as harness:
|
||||
harness.responses.enqueue_assistant_message(
|
||||
"remote image received",
|
||||
response_id="remote-image",
|
||||
"data URL image received",
|
||||
response_id="data-url-image",
|
||||
)
|
||||
|
||||
with Codex(config=harness.app_server_config()) as codex:
|
||||
result = codex.thread_start().run(
|
||||
[
|
||||
TextInput("Describe the remote image."),
|
||||
ImageInput(remote_image_url),
|
||||
TextInput("Describe the data URL image."),
|
||||
ImageInput(image_data_url),
|
||||
]
|
||||
)
|
||||
request = harness.responses.single_request()
|
||||
|
||||
assert {
|
||||
"final_response": result.final_response,
|
||||
"contains_user_prompt": "Describe the remote image." in request.message_input_texts("user"),
|
||||
"image_urls": request.message_image_urls("user"),
|
||||
"contains_user_prompt": "Describe the data URL image."
|
||||
in request.message_input_texts("user"),
|
||||
"image_url_is_png_data_url": request.message_image_urls("user")[-1].startswith(
|
||||
"data:image/png;base64,"
|
||||
),
|
||||
} == {
|
||||
"final_response": "remote image received",
|
||||
"final_response": "data URL image received",
|
||||
"contains_user_prompt": True,
|
||||
"image_urls": [remote_image_url],
|
||||
"image_url_is_png_data_url": True,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user