pub struct GeminiProvider { /* private fields */ }Expand description
Client for the Google Gemini API
(POST {base_url}/models/{model}:generateContent, key in x-goog-api-key),
or for Gemini on Vertex AI via vertex.
Implementations§
Source§impl GeminiProvider
impl GeminiProvider
pub fn new(api_key: impl Into<String>) -> Self
Sourcepub fn vertex(
project: impl Into<String>,
region: impl Into<String>,
access_token: impl Into<String>,
) -> Self
pub fn vertex( project: impl Into<String>, region: impl Into<String>, access_token: impl Into<String>, ) -> Self
Gemini on Google Cloud Vertex AI. access_token is an OAuth token
(e.g. gcloud auth print-access-token); region is e.g. global or us-central1.
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Uses your own reqwest::Client, for example to share a connection pool or set a proxy.
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
How many times a failed request is retried (default DEFAULT_MAX_RETRIES; 0 disables).
Trait Implementations§
Source§impl Clone for GeminiProvider
impl Clone for GeminiProvider
Source§impl Debug for GeminiProvider
impl Debug for GeminiProvider
Source§impl EmbeddingProvider for GeminiProvider
impl EmbeddingProvider for GeminiProvider
fn embed<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
model: &'life1 str,
inputs: &'life2 [&'life3 str],
) -> Pin<Box<dyn Future<Output = Result<Embeddings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§impl LlmProvider for GeminiProvider
impl LlmProvider for GeminiProvider
Source§fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sends the request and waits for the whole answer.
Source§fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn chat_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Streams the answer as it is generated. The last event is
StreamEvent::Done
with the full response. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GeminiProvider
impl !UnwindSafe for GeminiProvider
impl Freeze for GeminiProvider
impl Send for GeminiProvider
impl Sync for GeminiProvider
impl Unpin for GeminiProvider
impl UnsafeUnpin for GeminiProvider
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