mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## 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
69 lines
1.9 KiB
Rust
69 lines
1.9 KiB
Rust
use codex_protocol::models::ImageReference;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
|
pub struct ImageGenerationRequest {
|
|
pub prompt: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub background: Option<ImageBackground>,
|
|
pub model: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub n: Option<u64>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub quality: Option<ImageQuality>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub size: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, PartialEq)]
|
|
pub struct ImageEditRequest {
|
|
pub images: Vec<ImageReference>,
|
|
pub prompt: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub background: Option<ImageBackground>,
|
|
pub model: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub n: Option<u64>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub quality: Option<ImageQuality>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub size: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum ImageBackground {
|
|
Transparent,
|
|
Opaque,
|
|
Auto,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum ImageQuality {
|
|
Low,
|
|
Medium,
|
|
High,
|
|
Auto,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
|
|
pub struct ImageResponse {
|
|
pub created: u64,
|
|
pub data: Vec<ImageData>,
|
|
#[serde(default)]
|
|
pub background: Option<ImageBackground>,
|
|
#[serde(default)]
|
|
pub quality: Option<ImageQuality>,
|
|
#[serde(default)]
|
|
pub size: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
|
|
pub struct ImageData {
|
|
pub b64_json: String,
|
|
#[serde(default)]
|
|
pub generation_id: Option<String>,
|
|
}
|