Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Session
Defined in the session module.
Rust AI Agent SDK
Session manager - main API for session persistence
Fields
| Name | Type | Description |
|---|
session_id | String | - |
data | SessionData | - |
store | Arc<dyn SessionStore> | - |
Methods
new
fn new(session_id: impl Into<String>) -> Self
Create a new session with default file store
Parameters:
| Name | Type |
|---|
session_id | impl Into<String> |
with_store
fn with_store(session_id: impl Into<String>, store: Arc<dyn SessionStore>) -> Self
Create with custom store
Parameters:
| Name | Type |
|---|
session_id | impl Into<String> |
store | Arc<dyn SessionStore> |
load
fn load(session_id: impl Into<String>) -> Result<Self>
Load an existing session
Parameters:
| Name | Type |
|---|
session_id | impl Into<String> |
Get session ID
add_user_message
fn add_user_message(&mut self, content: impl Into<String>) -> Result<()>
Add a user message
Parameters:
| Name | Type |
|---|
content | impl Into<String> |
add_assistant_message
fn add_assistant_message(&mut self, content: impl Into<String>) -> Result<()>
Add an assistant message
Parameters:
| Name | Type |
|---|
content | impl Into<String> |
add_message
fn add_message(&mut self, role: &str, content: impl Into<String>) -> Result<()>
Add a message with role
Parameters:
| Name | Type |
|---|
role | &str |
content | impl Into<String> |
get_history
fn get_history(&self, max_messages: Option<usize>) -> Vec<Message>
Get chat history as LLM messages
Parameters:
| Name | Type |
|---|
max_messages | Option<usize> |
messages
fn messages(&self) -> &[SessionMessage]
Get all messages
message_count
fn message_count(&self) -> usize
Get message count
set_agent_name
fn set_agent_name(&mut self, name: impl Into<String>) -> Result<()>
Set agent name
Parameters:
| Name | Type |
|---|
name | impl Into<String> |
set_user_id
fn set_user_id(&mut self, user_id: impl Into<String>) -> Result<()>
Set user ID
Parameters:
| Name | Type |
|---|
user_id | impl Into<String> |
clear
fn clear(&mut self) -> Result<()>
Clear all messages
delete
fn delete(self) -> Result<()>
Delete the session
exists
Check if session exists on disk
save
fn save(&self) -> Result<()>
Save current state
Source
View on GitHub
praisonai/src/session/mod.rs at line 440