Download codex-rs/codex-api/src/endpoint/realtime_websocket/methods_v1.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 3.05 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-api/src/endpoint/realtime_websocket/methods_v1.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/codex-api/src/endpoint/realtime_websocket/methods_v1.rs
-
curl -L -o methods_v1.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-api/src/endpoint/realtime_websocket/methods_v1.rs
3.05 kB
| use crate::endpoint::realtime_websocket::methods_common::REALTIME_AUDIO_SAMPLE_RATE; | |
| use crate::endpoint::realtime_websocket::protocol::AudioFormatType; | |
| use crate::endpoint::realtime_websocket::protocol::ConversationContentType; | |
| use crate::endpoint::realtime_websocket::protocol::ConversationItemContent; | |
| use crate::endpoint::realtime_websocket::protocol::ConversationItemPayload; | |
| use crate::endpoint::realtime_websocket::protocol::ConversationItemType; | |
| use crate::endpoint::realtime_websocket::protocol::ConversationMessageItem; | |
| use crate::endpoint::realtime_websocket::protocol::RealtimeOutboundMessage; | |
| use crate::endpoint::realtime_websocket::protocol::RealtimeVoice; | |
| use crate::endpoint::realtime_websocket::protocol::SessionAudio; | |
| use crate::endpoint::realtime_websocket::protocol::SessionAudioFormat; | |
| use crate::endpoint::realtime_websocket::protocol::SessionAudioInput; | |
| use crate::endpoint::realtime_websocket::protocol::SessionAudioOutput; | |
| use crate::endpoint::realtime_websocket::protocol::SessionType; | |
| use crate::endpoint::realtime_websocket::protocol::SessionUpdateSession; | |
| use codex_protocol::protocol::ConversationTextRole; | |
| pub(super) fn conversation_item_create_message( | |
| text: String, | |
| role: ConversationTextRole, | |
| ) -> RealtimeOutboundMessage { | |
| let content_type = match role { | |
| ConversationTextRole::Assistant => ConversationContentType::OutputText, | |
| ConversationTextRole::User | ConversationTextRole::Developer => { | |
| ConversationContentType::InputText | |
| } | |
| }; | |
| RealtimeOutboundMessage::ConversationItemCreate { | |
| item: ConversationItemPayload::Message(ConversationMessageItem { | |
| r#type: ConversationItemType::Message, | |
| role, | |
| content: vec![ConversationItemContent { | |
| r#type: content_type, | |
| text, | |
| }], | |
| }), | |
| } | |
| } | |
| pub(super) fn conversation_handoff_append_message( | |
| handoff_id: String, | |
| output_text: String, | |
| ) -> RealtimeOutboundMessage { | |
| RealtimeOutboundMessage::ConversationHandoffAppend { | |
| handoff_id, | |
| output_text, | |
| } | |
| } | |
| pub(super) fn session_update_session( | |
| instructions: String, | |
| voice: RealtimeVoice, | |
| ) -> SessionUpdateSession { | |
| SessionUpdateSession { | |
| id: None, | |
| r#type: SessionType::Quicksilver, | |
| model: None, | |
| instructions: Some(instructions), | |
| output_modalities: None, | |
| audio: SessionAudio { | |
| input: SessionAudioInput { | |
| format: SessionAudioFormat { | |
| r#type: AudioFormatType::AudioPcm, | |
| rate: REALTIME_AUDIO_SAMPLE_RATE, | |
| }, | |
| noise_reduction: None, | |
| transcription: None, | |
| turn_detection: None, | |
| }, | |
| output: Some(SessionAudioOutput { | |
| format: None, | |
| voice, | |
| }), | |
| }, | |
| tools: None, | |
| tool_choice: None, | |
| } | |
| } | |
| pub(super) fn websocket_intent() -> Option<&'static str> { | |
| Some("quicksilver") | |
| } | |