-
Notifications
You must be signed in to change notification settings - Fork 177
feat(openai): wire image_generation streaming events in Responses router (R6.2) #1356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,8 @@ use futures_util::StreamExt; | |
| use openai_protocol::{ | ||
| event_types::{ | ||
| is_function_call_type, is_response_event, CodeInterpreterCallEvent, FileSearchCallEvent, | ||
| FunctionCallEvent, ItemType, McpEvent, OutputItemEvent, ResponseEvent, WebSearchCallEvent, | ||
| FunctionCallEvent, ImageGenerationCallEvent, ItemType, McpEvent, OutputItemEvent, | ||
| ResponseEvent, WebSearchCallEvent, | ||
| }, | ||
| responses::{ResponseTool, ResponsesRequest}, | ||
| }; | ||
|
|
@@ -149,6 +150,9 @@ pub(super) fn apply_event_transformations_inplace( | |
| // Determine item type and ID prefix based on response_format | ||
| let (new_type, id_prefix) = match response_format { | ||
| ResponseFormat::WebSearchCall => (ItemType::WEB_SEARCH_CALL, "ws_"), | ||
| ResponseFormat::ImageGenerationCall => { | ||
| (ItemType::IMAGE_GENERATION_CALL, "ig_") | ||
| } | ||
|
Comment on lines
+153
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Rewriting Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the P1 flag. To unpack it: the The R6.2 task is scoped to wiring Happy to pick that up as a follow-up once the R6.x series lands; leaving this PR narrowly scoped to image_generation wiring.
Comment on lines
+153
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fresh evidence in this commit: Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a re-post of the same P1 from your previous review. See my reply on the original thread: #1356 (comment) — the |
||
| _ => (ItemType::MCP_CALL, "mcp_"), | ||
| }; | ||
|
|
||
|
|
@@ -412,7 +416,8 @@ pub(super) fn forward_streaming_event( | |
| } | ||
|
|
||
| /// Inject in_progress event after a tool call item is added. | ||
| /// Handles mcp_call, web_search_call, code_interpreter_call, and file_search_call items. | ||
| /// Handles mcp_call, web_search_call, code_interpreter_call, file_search_call, | ||
| /// and image_generation_call items. | ||
| /// Returns false if client disconnected. | ||
| fn maybe_inject_tool_in_progress( | ||
| parsed_data: &Value, | ||
|
|
@@ -431,6 +436,7 @@ fn maybe_inject_tool_in_progress( | |
| ItemType::WEB_SEARCH_CALL => WebSearchCallEvent::IN_PROGRESS, | ||
| ItemType::CODE_INTERPRETER_CALL => CodeInterpreterCallEvent::IN_PROGRESS, | ||
| ItemType::FILE_SEARCH_CALL => FileSearchCallEvent::IN_PROGRESS, | ||
| ItemType::IMAGE_GENERATION_CALL => ImageGenerationCallEvent::IN_PROGRESS, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Nit: The docstring for this function (line 419) enumerates the handled item types but doesn't include
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in c0dfc00 — updated the docstring to include |
||
| _ => return true, // Not a tool call item, nothing to inject | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
apply_event_transformations_inplacefunction is missing transformation logic for theCodeInterpreterCallandFileSearchCallresponse formats. WhileWebSearchCalland the newly addedImageGenerationCallare handled, these other built-in tool formats will currently fall through to the genericMCP_CALLtype with anmcp_ID prefix. To ensure consistency across all hosted tool formats as intended by this PR, they should be explicitly mapped to their respective item types and ID prefixes (ci_andfs_). This ensures that the transformation logic correctly identifies the item variants present in the final response output.References
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the gap — you're right that
CodeInterpreterCallandFileSearchCallcurrently fall through to(ItemType::MCP_CALL, "mcp_")in this match. That predates R6.2; the existingWebSearchCallarm is the only explicit hosted-tool branch today. R6.1 / R6.2 are scoped to adding theimage_generation_callpath to matchweb_search_call, not to retrofit the other two formats.Extending this match to also cover
CodeInterpreterCallandFileSearchCallis a straightforward cleanup but touches behavior for two unrelated tool types, so it belongs in a follow-up rather than in the R6.x series (which is staged around the image_generation tool specifically). I'd rather keep this PR's blast radius narrow and file a separate PR that handles all the remaining hosted-tool formats uniformly.