pub struct RealtimeSession { /* private fields */ }Expand description
An active Realtime API session.
Provides methods for sending events and receiving responses.
Implementations§
Source§impl RealtimeSession
impl RealtimeSession
Sourcepub async fn send(&mut self, event: ClientEvent) -> Result<()>
pub async fn send(&mut self, event: ClientEvent) -> Result<()>
Send a client event to the server.
Sourcepub async fn recv(&mut self) -> Result<Option<ServerEvent>>
pub async fn recv(&mut self) -> Result<Option<ServerEvent>>
Receive the next server event.
Returns None if the connection is closed.
Sourcepub async fn update_session(&mut self, config: SessionConfig) -> Result<()>
pub async fn update_session(&mut self, config: SessionConfig) -> Result<()>
Update the session configuration.
Sourcepub async fn append_audio(&mut self, audio_base64: &str) -> Result<()>
pub async fn append_audio(&mut self, audio_base64: &str) -> Result<()>
Append base64-encoded audio to the input buffer.
Sourcepub async fn append_audio_bytes(&mut self, audio: &[u8]) -> Result<()>
pub async fn append_audio_bytes(&mut self, audio: &[u8]) -> Result<()>
Append raw audio bytes to the input buffer.
The bytes will be base64 encoded automatically.
Sourcepub async fn commit_audio(&mut self) -> Result<()>
pub async fn commit_audio(&mut self) -> Result<()>
Commit the input audio buffer.
Creates a user message item from the buffered audio.
Sourcepub async fn clear_audio(&mut self) -> Result<()>
pub async fn clear_audio(&mut self) -> Result<()>
Clear the input audio buffer.
Sourcepub async fn create_item(&mut self, item: ConversationItem) -> Result<()>
pub async fn create_item(&mut self, item: ConversationItem) -> Result<()>
Create a conversation item.
Sourcepub async fn create_response(
&mut self,
config: Option<ResponseCreateConfig>,
) -> Result<()>
pub async fn create_response( &mut self, config: Option<ResponseCreateConfig>, ) -> Result<()>
Create a response from the model.
Sourcepub async fn cancel_response(&mut self) -> Result<()>
pub async fn cancel_response(&mut self) -> Result<()>
Cancel the current response.
Sourcepub async fn submit_function_output(
&mut self,
call_id: &str,
output: &str,
) -> Result<()>
pub async fn submit_function_output( &mut self, call_id: &str, output: &str, ) -> Result<()>
Submit the output of a function call.
Sourcepub async fn delete_item(&mut self, item_id: &str) -> Result<()>
pub async fn delete_item(&mut self, item_id: &str) -> Result<()>
Delete a conversation item.
Auto Trait Implementations§
impl !Freeze for RealtimeSession
impl !RefUnwindSafe for RealtimeSession
impl Send for RealtimeSession
impl Sync for RealtimeSession
impl Unpin for RealtimeSession
impl !UnwindSafe for RealtimeSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more