pub struct Client {
pub model: GoogleModel,
/* private fields */
}Expand description
Wrapper struct which stores the HTTP Reqwest client and the request history. The send
methods are used to send text and images without having to manage the history manually.
Fields§
§model: GoogleModelImplementations§
Source§impl Client
impl Client
Sourcepub async fn new(model: &GoogleModel, key: &str) -> Result<Self, Error>
pub async fn new(model: &GoogleModel, key: &str) -> Result<Self, Error>
Creates a new instance of a Reqwest client. The client is setup to utilize the given Google Gemini model.
Sourcepub fn with_defaults(&mut self) -> Self
pub fn with_defaults(&mut self) -> Self
Mutates the client by setting sane default configurations based on the model.
pub async fn with_tools_client( &mut self, mcps: Vec<Arc<ClientRuntime>>, ) -> Result<Self, Error>
Sourcepub fn with_safety(&mut self, safety_settings: &[SafetySettings]) -> Self
pub fn with_safety(&mut self, safety_settings: &[SafetySettings]) -> Self
Mutate the client by setting the specified safety settings.
pub fn update_options(&mut self, updates: &[UpdateGenConfig]) -> Self
Sourcepub fn with_instructions(&mut self, system_instruction: &str) -> &mut Self
pub fn with_instructions(&mut self, system_instruction: &str) -> &mut Self
Mutate the client by setting the specified system instructions. Some models do not support system instructions, so in these cases we front-load the system instructions as user text content.
pub fn with_options(&mut self, options: &GenerationConfig) -> &mut Self
Sourcepub async fn send_text(&mut self, text: &str) -> Result<Responses, Error>
pub async fn send_text(&mut self, text: &str) -> Result<Responses, Error>
Send the given text to the model. Returns the responses or an error message if an error was returned.
pub async fn send_image(&mut self, blob: &Blob) -> Result<Responses, Error>
pub async fn send_file_data( &mut self, data: &FileData, ) -> Result<Responses, Error>
pub async fn send_image_file( &mut self, message: Option<String>, img: &Path, ) -> Result<Responses, Error>
pub async fn send_parts(&mut self, parts: &[Part]) -> Result<Responses, Error>
Sourcepub async fn send_image_bytes(
&mut self,
message: Option<String>,
mime_type: &str,
data: &str,
) -> Result<Responses, Error>
pub async fn send_image_bytes( &mut self, message: Option<String>, mime_type: &str, data: &str, ) -> Result<Responses, Error>
Send the given image to the model. This must be a UTF-8 Base64 encoded string which is required by the Google API. Optional text may be sent with the image to create a single consolidated message. Returns the responses or an error message if an error was returned.