pub struct ResponsesWebSocketSession { /* private fields */ }websocket only.Expand description
Sequential Responses session with automatic response-ID chaining.
Completed and incomplete responses update the chain unless a request supplies
its own previous_response_id. Call Self::close to perform a close handshake.
Implementations§
Source§impl ResponsesWebSocketSession
impl ResponsesWebSocketSession
Sourcepub fn from_connection(
wire: Responses,
connection: BoxedWebSocketConnection,
event_timeout: Option<Duration>,
) -> Self
pub fn from_connection( wire: Responses, connection: BoxedWebSocketConnection, event_timeout: Option<Duration>, ) -> Self
Build a session over an already-open, authenticated connection.
event_timeout: None waits indefinitely for each event.
Sourcepub fn previous_response_id(&self) -> Option<&str>
pub fn previous_response_id(&self) -> Option<&str>
Return the response ID retained for automatic chaining, if any.
Sourcepub fn clear_previous_response_id(&mut self)
pub fn clear_previous_response_id(&mut self)
Clears the cached previous_response_id so the next turn starts a fresh chain.
Sourcepub async fn send(
&mut self,
completion_request: CompletionRequest,
) -> Result<(), ProviderError>
pub async fn send( &mut self, completion_request: CompletionRequest, ) -> Result<(), ProviderError>
Sends a response.create event for a Rig completion request.
Sourcepub async fn send_with_options(
&mut self,
completion_request: CompletionRequest,
options: ResponsesWebSocketCreateOptions,
) -> Result<(), ProviderError>
pub async fn send_with_options( &mut self, completion_request: CompletionRequest, options: ResponsesWebSocketCreateOptions, ) -> Result<(), ProviderError>
Sends a response.create event with explicit websocket-mode options.
Sourcepub async fn next_event(
&mut self,
) -> Result<ResponsesWebSocketEvent, ProviderError>
pub async fn next_event( &mut self, ) -> Result<ResponsesWebSocketEvent, ProviderError>
Reads the next server event for the current in-flight turn.
Sourcepub async fn warmup(
&mut self,
completion_request: CompletionRequest,
) -> Result<String, ProviderError>
pub async fn warmup( &mut self, completion_request: CompletionRequest, ) -> Result<String, ProviderError>
Sends a warmup turn (generate: false) and returns the resulting response ID.
Sourcepub async fn completion(
&mut self,
completion_request: CompletionRequest,
) -> Result<CompletionResponse, ProviderError>
pub async fn completion( &mut self, completion_request: CompletionRequest, ) -> Result<CompletionResponse, ProviderError>
Sends a completion turn and collects the final OpenAI response,
normalized; its raw is the provider’s own terminal response object.
Sourcepub async fn close(&mut self) -> Result<(), ProviderError>
pub async fn close(&mut self) -> Result<(), ProviderError>
Closes the websocket connection.
Call this when you are finished with the session so the websocket can terminate with a clean close handshake.
Trait Implementations§
Source§impl Drop for ResponsesWebSocketSession
impl Drop for ResponsesWebSocketSession
Auto Trait Implementations§
impl !RefUnwindSafe for ResponsesWebSocketSession
impl !UnwindSafe for ResponsesWebSocketSession
impl Freeze for ResponsesWebSocketSession
impl Send for ResponsesWebSocketSession
impl Sync for ResponsesWebSocketSession
impl Unpin for ResponsesWebSocketSession
impl UnsafeUnpin for ResponsesWebSocketSession
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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