pub struct Conversation { /* private fields */ }Expand description
Represents a conversation with Gemini
§Example usage:
let mut convo = Conversation::new(
std::env::var("GEMINI_API_KEY").unwrap(), // Replace with however you want to get your API key
"gemini-1.5-flash".to_string() // Use a model from get_models()
);
let response = convo.prompt("Hello World!")await.unwrap();
println!("{0:?}", a.text);Implementations§
Source§impl<'a> Conversation
impl<'a> Conversation
Sourcepub fn update_safety_settings(&mut self, settings: Vec<SafetySetting>)
pub fn update_safety_settings(&mut self, settings: Vec<SafetySetting>)
Update the safety settings to different thresholds from safety::SafetySetting
§Example:
let mut convo = Conversation::new(
"ABC123".to_string,
"gemini-1.5-flash".to_string
).update_safety_settings(safety_settings::default());pub async fn prompt(&mut self, input: &'a str) -> String
Sourcepub async fn generate_content(
&mut self,
input: Vec<Part>,
) -> Result<GeminiResponse, GeminiError<'_>>
pub async fn generate_content( &mut self, input: Vec<Part>, ) -> Result<GeminiResponse, GeminiError<'_>>
Sends a prompt to the Gemini API and returns the response
Trait Implementations§
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