mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Refactor image content to use a shared ImageReference type (#45543)
## What changed Represent images in `ContentItem` and `FunctionCallOutputContentItem` with `ImageReference::Inline`, flattened to preserve the existing `image_url` wire format. Update image producers and consumers and regenerate app-server schemas and SDK artifacts. Preserve the Python SDK's `InputImageContentItem` and `InputImageFunctionCallOutputContentItem` class names during generation. ## Testing Add a regression test for stable Python image class names and adapt existing image tests to the shared representation. GitOrigin-RevId: c38a780ac3314c2ac2deb3afc1b93b94b6f93fec
This commit is contained in:
1 parent
6ae5e71458
commit
5a66d460d3
79 files changed
+994
-312
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate::async_scorer::authorization::ScoreAuthorization;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -139,7 +140,7 @@ async fn assert_catalog_budget(evidence: BudgetEvidence) -> Result<()> {
|
||||
unreachable!("user instruction is a message");
|
||||
};
|
||||
content.push(ContentItem::InputImage {
|
||||
image_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGPgEpEDAABoAD1UCKP3AAAAAElFTkSuQmCC".to_owned(),
|
||||
image: ImageReference::Inline { image_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGPgEpEDAABoAD1UCKP3AAAAAElFTkSuQmCC".to_owned() },
|
||||
detail: None,
|
||||
});
|
||||
(None, vec!["optional old commentary ".repeat(/*n*/ 500)])
|
||||
|
||||
@@ -38,6 +38,7 @@ use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::ImageDetail;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use codex_protocol::models::InternalChatMessageMetadataPassthrough;
|
||||
use codex_protocol::models::LocalShellAction;
|
||||
use codex_protocol::models::LocalShellExecAction;
|
||||
@@ -1641,7 +1642,9 @@ async fn contributor_includes_transcript_images_by_default() -> Result<()> {
|
||||
text: "Review what is shown on screen.".to_owned(),
|
||||
},
|
||||
ContentItem::InputImage {
|
||||
image_url: user_image.to_owned(),
|
||||
image: ImageReference::Inline {
|
||||
image_url: user_image.to_owned(),
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
],
|
||||
@@ -1667,7 +1670,9 @@ async fn contributor_includes_transcript_images_by_default() -> Result<()> {
|
||||
text: "Screenshot captured.".to_owned(),
|
||||
},
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image_url: tool_image.to_owned(),
|
||||
image: ImageReference::Inline {
|
||||
image_url: tool_image.to_owned(),
|
||||
},
|
||||
detail: Some(ImageDetail::High),
|
||||
},
|
||||
]),
|
||||
|
||||
@@ -7,6 +7,7 @@ use codex_protocol::models::AgentMessageInputContent;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use codex_protocol::models::MessagePhase;
|
||||
use codex_protocol::models::ReasoningItemContent;
|
||||
use codex_protocol::models::ReasoningItemReasoningSummary;
|
||||
@@ -1077,7 +1078,9 @@ fn transcript_preserves_outputs_with_call_ids_or_explicit_names() {
|
||||
if let ResponseItem::FunctionCallOutput { output, .. } = &mut items[0] {
|
||||
*output = FunctionCallOutputPayload::from_content_items(vec![
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image_url: "data:image/png;base64,image".to_owned(),
|
||||
image: ImageReference::Inline {
|
||||
image_url: "data:image/png;base64,image".to_owned(),
|
||||
},
|
||||
detail: None,
|
||||
},
|
||||
]);
|
||||
@@ -1222,7 +1225,9 @@ fn transcript_omits_media_payloads_and_keeps_readable_content() {
|
||||
text: "Review this screenshot.".to_string(),
|
||||
},
|
||||
ContentItem::InputImage {
|
||||
image_url: format!("data:image/png;base64,{oversized_image}"),
|
||||
image: ImageReference::Inline {
|
||||
image_url: format!("data:image/png;base64,{oversized_image}"),
|
||||
},
|
||||
detail: None,
|
||||
},
|
||||
ContentItem::InputAudio {
|
||||
@@ -1242,7 +1247,9 @@ fn transcript_omits_media_payloads_and_keeps_readable_content() {
|
||||
text: "Screenshot captured.".to_string(),
|
||||
},
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image_url: "data:image/png;base64,tool-image".to_string(),
|
||||
image: ImageReference::Inline {
|
||||
image_url: "data:image/png;base64,tool-image".to_string(),
|
||||
},
|
||||
detail: None,
|
||||
},
|
||||
FunctionCallOutputContentItem::InputAudio {
|
||||
|
||||
Reference in new issue
Block a user