mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Support file references in image edit requests (#47956)
## Why Editing recent conversation images failed when the selected images included a file reference from a message or tool output. ## What changed Use `ImageReference` in `ImageEditRequest` to accept both `image_url` and `file_id` inputs. Pass file references from conversation history through to image edit requests while preserving image selection order. ## Testing Update tests to cover file references from messages and tool outputs, and serialization of mixed inline and file references in image edit requests. GitOrigin-RevId: 2764bf36a81a62ddd25cf9df27346a434a10c449
This commit is contained in:
committed by
copyberry
parent
40e13e6281
commit
51d66fdd3b
@@ -122,13 +122,13 @@ mod tests {
|
||||
use crate::images::ImageBackground;
|
||||
use crate::images::ImageData;
|
||||
use crate::images::ImageQuality;
|
||||
use crate::images::ImageUrl;
|
||||
use crate::provider::RetryConfig;
|
||||
use codex_client::Request;
|
||||
use codex_client::RequestBody;
|
||||
use codex_client::Response;
|
||||
use codex_client::StreamResponse;
|
||||
use codex_client::TransportError;
|
||||
use codex_protocol::models::ImageReference;
|
||||
use http::StatusCode;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
@@ -339,9 +339,14 @@ mod tests {
|
||||
let (response, imagegen_request_id) = client
|
||||
.edit(
|
||||
&ImageEditRequest {
|
||||
images: vec![ImageUrl {
|
||||
image_url: "data:image/png;base64,Zm9v".to_string(),
|
||||
}],
|
||||
images: vec![
|
||||
ImageReference::Inline {
|
||||
image_url: "data:image/png;base64,Zm9v".to_string(),
|
||||
},
|
||||
ImageReference::File {
|
||||
file_id: "file-image".to_string(),
|
||||
},
|
||||
],
|
||||
prompt: "add a red hat".to_string(),
|
||||
background: None,
|
||||
model: "gpt-image-1.5".to_string(),
|
||||
@@ -362,7 +367,10 @@ mod tests {
|
||||
assert_eq!(
|
||||
request.body.as_ref().and_then(RequestBody::json),
|
||||
Some(&json!({
|
||||
"images": [{"image_url": "data:image/png;base64,Zm9v"}],
|
||||
"images": [
|
||||
{"image_url": "data:image/png;base64,Zm9v"},
|
||||
{"file_id": "file-image"},
|
||||
],
|
||||
"prompt": "add a red hat",
|
||||
"model": "gpt-image-1.5",
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user