pub struct ChatGPT { /* private fields */ }Expand description
The client that operates the ChatGPT API
Implementations§
Source§impl ChatGPT
impl ChatGPT
Sourcepub fn new<S: Into<String>>(api_key: S) -> Result<Self>
pub fn new<S: Into<String>>(api_key: S) -> Result<Self>
Constructs a new ChatGPT API client with provided API Key
Sourcepub fn new_conversation(&self) -> Conversation
pub fn new_conversation(&self) -> Conversation
Starts a new conversation with a default starting message.
Conversations record message history.
Sourcepub fn new_conversation_directed<S: Into<String>>(
&self,
direction_message: S,
) -> Conversation
pub fn new_conversation_directed<S: Into<String>>( &self, direction_message: S, ) -> Conversation
Starts a new conversation with a specified starting message.
Conversations record message history.
Sourcepub fn send_history(&self, history: &Vec<ChatMessage>) -> String
pub fn send_history(&self, history: &Vec<ChatMessage>) -> String
Explicitly sends whole message history to the API.
In most cases, if you would like to store message history, you should be looking at the Conversation struct, and
Self::new_conversation() and Self::new_conversation_directed()
Sourcepub fn send_message<S: Into<String>>(
&self,
message: S,
) -> Result<CompletionResponse, Error>
pub fn send_message<S: Into<String>>( &self, message: S, ) -> Result<CompletionResponse, Error>
Sends a single message to the API without preserving message history.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatGPT
impl !RefUnwindSafe for ChatGPT
impl Send for ChatGPT
impl Sync for ChatGPT
impl Unpin for ChatGPT
impl !UnwindSafe for ChatGPT
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