pub struct SessionsClient { /* private fields */ }Expand description
Client for session operations.
Sessions enable multi-turn conversations with persistent history stored on the server.
Implementations§
Source§impl SessionsClient
impl SessionsClient
Sourcepub async fn create(
&self,
req: SessionCreateRequest,
) -> Result<SessionResponse, Error>
pub async fn create( &self, req: SessionCreateRequest, ) -> Result<SessionResponse, Error>
Create a new session.
Sessions are project-scoped and can optionally be associated with a customer.
§Example
ⓘ
let session = client.sessions().create(SessionCreateRequest {
customer_id: Some(uuid::Uuid::parse_str("...")?),
metadata: Some(serde_json::json!({"project": "my-app"})),
}).await?;
println!("Created session: {}", session.id);Sourcepub async fn list(
&self,
opts: ListSessionsOptions,
) -> Result<SessionListResponse, Error>
pub async fn list( &self, opts: ListSessionsOptions, ) -> Result<SessionListResponse, Error>
List sessions with pagination.
§Example
ⓘ
let resp = client.sessions().list(ListSessionsOptions {
limit: Some(10),
..Default::default()
}).await?;
for session in resp.sessions {
println!("Session {}: {} messages", session.id, session.message_count);
}
// Fetch next page using cursor
if let Some(cursor) = resp.next_cursor {
let next_page = client.sessions().list(ListSessionsOptions {
cursor: Some(cursor),
..Default::default()
}).await?;
}Sourcepub async fn add_message(
&self,
session_id: &str,
req: SessionMessageCreateRequest,
) -> Result<SessionMessageResponse, Error>
pub async fn add_message( &self, session_id: &str, req: SessionMessageCreateRequest, ) -> Result<SessionMessageResponse, Error>
Add a message to a session.
Messages can be user, assistant, or tool messages. Assistant messages can optionally include a run_id to link them to a workflow run.
§Example
ⓘ
let msg = client.sessions().add_message("session-uuid", SessionMessageCreateRequest {
role: "user".into(),
content: vec![serde_json::json!({"type": "text", "text": "Hello!"})],
run_id: None,
}).await?;
println!("Added message: {}", msg.id);Trait Implementations§
Source§impl Clone for SessionsClient
impl Clone for SessionsClient
Source§fn clone(&self) -> SessionsClient
fn clone(&self) -> SessionsClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SessionsClient
impl !RefUnwindSafe for SessionsClient
impl Send for SessionsClient
impl Sync for SessionsClient
impl Unpin for SessionsClient
impl !UnwindSafe for SessionsClient
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