mirror of
https://github.com/openai/codex.git
synced 2026-05-02 04:11:39 +03:00
image-gen-core (#13290)
Core tool-calling for image-gen, handles requesting and receiving logic for images using response API
This commit is contained in:
@@ -313,6 +313,23 @@ pub enum ResponseItem {
|
||||
#[ts(optional)]
|
||||
action: Option<WebSearchAction>,
|
||||
},
|
||||
// Emitted by the Responses API when the agent triggers image generation.
|
||||
// Example payload:
|
||||
// {
|
||||
// "id":"ig_123",
|
||||
// "type":"image_generation_call",
|
||||
// "status":"completed",
|
||||
// "revised_prompt":"A gray tabby cat hugging an otter...",
|
||||
// "result":"..."
|
||||
// }
|
||||
ImageGenerationCall {
|
||||
id: String,
|
||||
status: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
revised_prompt: Option<String>,
|
||||
result: String,
|
||||
},
|
||||
// Generated by the harness but considered exactly as a model response.
|
||||
GhostSnapshot {
|
||||
ghost_commit: GhostCommit,
|
||||
@@ -1286,6 +1303,49 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn response_item_parses_image_generation_call() {
|
||||
let item = serde_json::from_value::<ResponseItem>(serde_json::json!({
|
||||
"id": "ig_123",
|
||||
"type": "image_generation_call",
|
||||
"status": "completed",
|
||||
"revised_prompt": "A small blue square",
|
||||
"result": "Zm9v",
|
||||
}))
|
||||
.expect("image generation item should deserialize");
|
||||
|
||||
assert_eq!(
|
||||
item,
|
||||
ResponseItem::ImageGenerationCall {
|
||||
id: "ig_123".to_string(),
|
||||
status: "completed".to_string(),
|
||||
revised_prompt: Some("A small blue square".to_string()),
|
||||
result: "Zm9v".to_string(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn response_item_parses_image_generation_call_without_revised_prompt() {
|
||||
let item = serde_json::from_value::<ResponseItem>(serde_json::json!({
|
||||
"id": "ig_123",
|
||||
"type": "image_generation_call",
|
||||
"status": "completed",
|
||||
"result": "Zm9v",
|
||||
}))
|
||||
.expect("image generation item should deserialize");
|
||||
|
||||
assert_eq!(
|
||||
item,
|
||||
ResponseItem::ImageGenerationCall {
|
||||
id: "ig_123".to_string(),
|
||||
status: "completed".to_string(),
|
||||
revised_prompt: None,
|
||||
result: "Zm9v".to_string(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn convert_mcp_content_to_items_builds_data_urls_when_missing_prefix() {
|
||||
let contents = vec![serde_json::json!({
|
||||
|
||||
Reference in New Issue
Block a user