mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
Prompt realtime model to speak terminal output
This commit is contained in:
@@ -1351,13 +1351,13 @@ async fn webrtc_terminal_output_without_handoff_reaches_realtime() -> Result<()>
|
||||
],
|
||||
),
|
||||
] {
|
||||
let mut harness = RealtimeE2eHarness::new(
|
||||
version,
|
||||
main_loop_responses(vec![
|
||||
create_final_assistant_message_sse_response(output_texts[0])?,
|
||||
create_final_assistant_message_sse_response(output_texts[1])?,
|
||||
]),
|
||||
realtime_sideband(vec![realtime_sideband_connection(vec![
|
||||
let sideband_responses = match version {
|
||||
RealtimeTestVersion::V1 => vec![
|
||||
vec![session_updated("sess_terminal_output")],
|
||||
vec![],
|
||||
vec![],
|
||||
],
|
||||
RealtimeTestVersion::V2 => vec![
|
||||
vec![session_updated("sess_terminal_output")],
|
||||
vec![],
|
||||
vec![
|
||||
@@ -1372,7 +1372,15 @@ async fn webrtc_terminal_output_without_handoff_reaches_realtime() -> Result<()>
|
||||
],
|
||||
vec![],
|
||||
vec![],
|
||||
])]),
|
||||
],
|
||||
};
|
||||
let mut harness = RealtimeE2eHarness::new(
|
||||
version,
|
||||
main_loop_responses(vec![
|
||||
create_final_assistant_message_sse_response(output_texts[0])?,
|
||||
create_final_assistant_message_sse_response(output_texts[1])?,
|
||||
]),
|
||||
realtime_sideband(vec![realtime_sideband_connection(sideband_responses)]),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -1409,10 +1417,12 @@ async fn webrtc_terminal_output_without_handoff_reaches_realtime() -> Result<()>
|
||||
.read_notification::<TurnCompletedNotification>("turn/completed")
|
||||
.await?;
|
||||
|
||||
let request_index = match version {
|
||||
RealtimeTestVersion::V1 => 1 + turn_index,
|
||||
RealtimeTestVersion::V2 => 1 + turn_index * 2,
|
||||
};
|
||||
assert_eq!(
|
||||
harness
|
||||
.sideband_outbound_request(/*request_index*/ 1 + turn_index * 2)
|
||||
.await,
|
||||
harness.sideband_outbound_request(request_index).await,
|
||||
json!({
|
||||
"type": "conversation.item.create",
|
||||
"item": {
|
||||
@@ -1420,16 +1430,19 @@ async fn webrtc_terminal_output_without_handoff_reaches_realtime() -> Result<()>
|
||||
"role": "developer",
|
||||
"content": [{
|
||||
"type": "input_text",
|
||||
"text": output_text,
|
||||
"text": format!("Speak the following text:\n{output_text}"),
|
||||
}],
|
||||
},
|
||||
})
|
||||
);
|
||||
assert_v2_response_create(
|
||||
&harness
|
||||
.sideband_outbound_request(/*request_index*/ 2 + turn_index * 2)
|
||||
.await,
|
||||
);
|
||||
match version {
|
||||
RealtimeTestVersion::V1 => {}
|
||||
RealtimeTestVersion::V2 => {
|
||||
assert_v2_response_create(
|
||||
&harness.sideband_outbound_request(request_index + 1).await,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
harness.shutdown().await;
|
||||
|
||||
@@ -1142,12 +1142,20 @@ async fn handle_terminal_output(
|
||||
let terminal_output = terminal_output.context("terminal output channel closed")?;
|
||||
|
||||
let (result, request_response) = match terminal_output {
|
||||
RealtimeTerminalOutput::Direct { output_text } => (
|
||||
writer
|
||||
.send_conversation_developer_item_create(output_text)
|
||||
.await,
|
||||
true,
|
||||
),
|
||||
RealtimeTerminalOutput::Direct { output_text } => {
|
||||
let request_response = match event_parser {
|
||||
RealtimeEventParser::V1 => false,
|
||||
RealtimeEventParser::RealtimeV2 => true,
|
||||
};
|
||||
(
|
||||
writer
|
||||
.send_conversation_developer_item_create(format!(
|
||||
"Speak the following text:\n{output_text}"
|
||||
))
|
||||
.await,
|
||||
request_response,
|
||||
)
|
||||
}
|
||||
RealtimeTerminalOutput::Handoff {
|
||||
handoff_id,
|
||||
output_text,
|
||||
|
||||
Reference in New Issue
Block a user