pub struct Session { /* private fields */ }Expand description
Unique opaque provider-native interactive session supplied for OpenAI models.
This example requires valid credentials and a live model with native session support. Sessions are unique, mutable, and non-Clone. Consuming close settles the session transport; the Provider retains separate shared shutdown authority. Ordinary multi-turn generation instead uses messages and continuation.
§Examples
use providers_kit::{Provider, ProviderBackend, ProviderConfig, config::{ApiKey, OpenAiConfig, ProviderKind, TransportConfig}};
let provider = Provider::from_config(ProviderConfig::new(ProviderKind::OpenAi(OpenAiConfig::new(ApiKey::new("replace-with-your-key")?)), TransportConfig::default()))?;
use providers_kit::{ModelBackend, ModelId, SessionBackend, session::{SessionConfig, SessionInput}};
let model = provider.model(ModelId::new("your-exact-session-model-id")?)?;
let observed = async {
let mut session = model.open_session(SessionConfig::default()).await?;
assert!(!session.id().is_empty());
assert_eq!(session.model_id(), model.model_id());
let closed = session.close().await;
closed
}.await;
let cleanup = provider.shutdown().await;
observed?;
cleanup?;
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl !UnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
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