#[non_exhaustive]pub struct SessionContext {
pub id: String,
pub messages: Vec<MessageResponse>,
pub summary: Option<Summary>,
pub peer_representation: Option<String>,
pub peer_card: Option<Vec<String>>,
}Expand description
Context returned when requesting session state.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringSession identifier.
messages: Vec<MessageResponse>Messages in the session.
summary: Option<Summary>The summary if available.
peer_representation: Option<String>Curated subset of a peer representation, if requested from a specific perspective.
peer_card: Option<Vec<String>>The peer card, if requested from a specific perspective.
Implementations§
Source§impl SessionContext
impl SessionContext
Sourcepub fn to_openai(&self, assistant: impl IntoAssistantRef) -> Vec<Value>
pub fn to_openai(&self, assistant: impl IntoAssistantRef) -> Vec<Value>
Convert the context to OpenAI-compatible message format.
System messages (peer_representation, peer_card, summary) are prepended.
Assistant messages get role: "assistant", all others get role: "user".
Each message also includes a "name" field set to the peer ID.
assistant can be a &str, String, or &Peer.
use honcho_ai::types::session::SessionContext;
let ctx: SessionContext = serde_json::from_value(serde_json::json!({
"id": "s1",
"messages": [],
})).unwrap();
let messages = ctx.to_openai("assistant-1");
assert!(messages.is_empty());Sourcepub fn to_anthropic(&self, assistant: impl IntoAssistantRef) -> Vec<Value>
pub fn to_anthropic(&self, assistant: impl IntoAssistantRef) -> Vec<Value>
Convert the context to Anthropic-compatible message format.
System-like messages (peer_representation, peer_card, summary) use role: "user"
since Anthropic uses a separate system parameter.
Assistant messages get role: "assistant", others get role: "user" with
PEER_ID: CONTENT format.
assistant can be a &str, String, or &Peer.
Trait Implementations§
Source§impl Clone for SessionContext
impl Clone for SessionContext
Source§fn clone(&self) -> SessionContext
fn clone(&self) -> SessionContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more