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( &self, session: &mut Session, ) -> Result<GeminiResponse, GeminiResponseError>
Sourcepub async fn ask_as_stream<StreamType>(
&self,
session: Session,
data_extractor: StreamDataExtractor<StreamType>,
) -> Result<GeminiResponseStream<StreamType>, GeminiResponseError>
pub async fn ask_as_stream<StreamType>( &self, session: Session, data_extractor: StreamDataExtractor<StreamType>, ) -> Result<GeminiResponseStream<StreamType>, GeminiResponseError>
§Warning
You must read the response stream to get reply stored context in sessions.
data_extractor is used to extract data that you get as a stream of futures.
§Example
ⓘ
use futures::StreamExt
let mut response_stream = gemini.ask_as_stream(session,
|_session, gemini_response| gemini_response).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