mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
## What changed Parse optional `generation_id` values from image API responses and carry the selected image's ID through the image generation tool into analytics events. Keep the ID out of serialized extension items, JSON schemas, and TypeScript types. Responses without an ID remain supported. ## Testing Add coverage for distinct IDs in multi-image responses and responses without IDs. Extend analytics and app-server tests to verify that the selected image's ID reaches analytics, and item tests to verify that it is omitted from serialization and TypeScript types. GitOrigin-RevId: 70a600856990140b76fdbda51a0d73b3414338b1
73 lines
1.9 KiB
Rust
73 lines
1.9 KiB
Rust
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<ImageUrl>,
|
|
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, Deserialize, PartialEq, Eq)]
|
|
pub struct ImageUrl {
|
|
pub image_url: 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>,
|
|
}
|