pub struct Gemini { /* private fields */ }Implementations§
Source§impl Gemini
impl Gemini
Sourcepub fn new(
api_key: impl Into<String>,
model: impl Into<String>,
sys_prompt: Option<SystemInstruction>,
) -> Self
pub fn new( api_key: impl Into<String>, model: impl Into<String>, sys_prompt: Option<SystemInstruction>, ) -> Self
sys_prompt should follow gemini doc
Sourcepub fn set_generation_config(&mut self, generation_config: Value) -> &mut Self
pub fn set_generation_config(&mut self, generation_config: Value) -> &mut Self
The generation config Schema should follow Gemini docs
pub fn set_model(&mut self, model: impl Into<String>) -> &mut Self
pub fn set_api_key(&mut self, api_key: impl Into<String>) -> &mut Self
Sourcepub fn set_json_mode(&mut self, schema: Value) -> &mut Self
pub fn set_json_mode(&mut self, schema: Value) -> &mut Self
schema should follow Schema of gemini
pub fn unset_json_mode(&mut self) -> &mut Self
Sourcepub fn set_tools(&mut self, tools: Option<Vec<Tool>>) -> &mut Self
pub fn set_tools(&mut self, tools: Option<Vec<Tool>>) -> &mut Self
toolscan be None to unset tools from using.- Or Vec tools to be allowed
pub fn unset_code_execution_mode(&mut self) -> &mut Self
pub async fn ask<'b>( &self, session: &'b mut Session, ) -> Result<GeminiResponse, Box<dyn Error>>
Sourcepub async fn ask_as_stream<'b>(
&self,
session: &'b mut Session,
) -> Result<GeminiResponseStream<'b>, Box<dyn Error>>
pub async fn ask_as_stream<'b>( &self, session: &'b mut Session, ) -> Result<GeminiResponseStream<'b>, Box<dyn Error>>
§Warining
You must read the response stream to get reply stored context in sessions.
§Example
ⓘ
let mut response_stream = gemini.ask_as_stream(&mut session).await.unwrap();
while let Some(response) = response_stream.next().await {
if let Ok(response) = response {
println!("{}", response.get_text(""));
}
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gemini
impl !RefUnwindSafe for Gemini
impl !Send for Gemini
impl !Sync for Gemini
impl Unpin for Gemini
impl !UnwindSafe for Gemini
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