pub struct Conversation {
pub history: Vec<ChatMessage>,
/* private fields */
}Expand description
Stores a single conversation session, and automatically saves message history
Fields§
§history: Vec<ChatMessage>All the messages sent and received, starting with the beginning system message
Implementations§
Source§impl Conversation
impl Conversation
Sourcepub fn new(client: ChatGPT, first_message: String) -> Self
pub fn new(client: ChatGPT, first_message: String) -> Self
Constructs a new conversation from an API client and the introductory message
Sourcepub fn new_with_history(client: ChatGPT, history: Vec<ChatMessage>) -> Self
pub fn new_with_history(client: ChatGPT, history: Vec<ChatMessage>) -> Self
Constructs a new conversation from a pre-initialized chat history
Sourcepub fn send_message<S: Into<String>>(&mut self, message: S) -> String
pub fn send_message<S: Into<String>>(&mut self, message: S) -> String
Sends the message to the ChatGPT API and returns the completion response.
Execution speed depends on API response times.
Auto Trait Implementations§
impl Freeze for Conversation
impl !RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl !UnwindSafe for Conversation
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