pub struct AsyncChatbot { /* private fields */ }Expand description
Async chatbot client for interacting with Google Gemini.
§Example
use gemini_chat_api::{AsyncChatbot, Model};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let chatbot = AsyncChatbot::new(
"your_psid",
"your_psidts",
Model::default(),
None,
30,
).await?;
let response = chatbot.ask("Hello!", None).await?;
println!("{}", response.content);
Ok(())
}Implementations§
Source§impl AsyncChatbot
impl AsyncChatbot
Sourcepub async fn new(
secure_1psid: &str,
secure_1psidts: &str,
model: Model,
proxy: Option<&str>,
timeout: u64,
) -> Result<Self>
pub async fn new( secure_1psid: &str, secure_1psidts: &str, model: Model, proxy: Option<&str>, timeout: u64, ) -> Result<Self>
Creates a new AsyncChatbot instance.
§Arguments
secure_1psid- The __Secure-1PSID cookie valuesecure_1psidts- The __Secure-1PSIDTS cookie valuemodel- The Gemini model to useproxy- Optional proxy URLtimeout- Request timeout in seconds
§Returns
A new initialized AsyncChatbot
§Errors
Returns an error if authentication fails or network is unavailable.
Sourcepub async fn save_conversation(
&self,
file_path: &str,
conversation_name: &str,
) -> Result<()>
pub async fn save_conversation( &self, file_path: &str, conversation_name: &str, ) -> Result<()>
Saves the current conversation to a file.
Sourcepub async fn load_conversations(
&self,
file_path: &str,
) -> Result<Vec<SavedConversation>>
pub async fn load_conversations( &self, file_path: &str, ) -> Result<Vec<SavedConversation>>
Loads all saved conversations from a file.
Sourcepub async fn load_conversation(
&mut self,
file_path: &str,
conversation_name: &str,
) -> Result<bool>
pub async fn load_conversation( &mut self, file_path: &str, conversation_name: &str, ) -> Result<bool>
Loads a specific conversation by name.
Sourcepub fn conversation_id(&self) -> &str
pub fn conversation_id(&self) -> &str
Gets the current conversation ID.
Auto Trait Implementations§
impl Freeze for AsyncChatbot
impl !RefUnwindSafe for AsyncChatbot
impl Send for AsyncChatbot
impl Sync for AsyncChatbot
impl Unpin for AsyncChatbot
impl !UnwindSafe for AsyncChatbot
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