pub struct ChatSession {
pub messages: Option<Vec<BaseMessage>>,
pub functions: Option<Vec<Value>>,
}Expand description
Chat Session.
A Chat Session represents a single conversation, channel, or other group of messages.
§Example
ⓘ
use agent_chain_core::chat_sessions::ChatSession;
use agent_chain_core::messages::{BaseMessage, HumanMessage, AIMessage};
let session = ChatSession {
messages: Some(vec![
BaseMessage::Human(HumanMessage::new("Hello!")),
BaseMessage::AI(AIMessage::new("Hi there!")),
]),
functions: None,
};Fields§
§messages: Option<Vec<BaseMessage>>A sequence of the LangChain chat messages loaded from the source.
functions: Option<Vec<Value>>A sequence of the function calling specs for the messages.
Implementations§
Source§impl ChatSession
impl ChatSession
Sourcepub fn with_messages(messages: Vec<BaseMessage>) -> Self
pub fn with_messages(messages: Vec<BaseMessage>) -> Self
Create a chat session with the given messages.
Sourcepub fn with_messages_and_functions(
messages: Vec<BaseMessage>,
functions: Vec<Value>,
) -> Self
pub fn with_messages_and_functions( messages: Vec<BaseMessage>, functions: Vec<Value>, ) -> Self
Create a chat session with the given messages and functions.
Sourcepub fn messages(&self) -> &[BaseMessage]
pub fn messages(&self) -> &[BaseMessage]
Get the messages in this session, or an empty slice if none.
Sourcepub fn functions(&self) -> &[Value]
pub fn functions(&self) -> &[Value]
Get the functions in this session, or an empty slice if none.
Sourcepub fn has_messages(&self) -> bool
pub fn has_messages(&self) -> bool
Check if this session has any messages.
Sourcepub fn has_functions(&self) -> bool
pub fn has_functions(&self) -> bool
Check if this session has any functions.
Trait Implementations§
Source§impl Clone for ChatSession
impl Clone for ChatSession
Source§fn clone(&self) -> ChatSession
fn clone(&self) -> ChatSession
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 moreSource§impl Debug for ChatSession
impl Debug for ChatSession
Source§impl Default for ChatSession
impl Default for ChatSession
Source§fn default() -> ChatSession
fn default() -> ChatSession
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ChatSession
impl<'de> Deserialize<'de> for ChatSession
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ChatSession
impl PartialEq for ChatSession
Source§impl Serialize for ChatSession
impl Serialize for ChatSession
impl StructuralPartialEq for ChatSession
Auto Trait Implementations§
impl Freeze for ChatSession
impl RefUnwindSafe for ChatSession
impl Send for ChatSession
impl Sync for ChatSession
impl Unpin for ChatSession
impl UnwindSafe for ChatSession
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