pub struct GeminiLlm { /* private fields */ }Expand description
Concrete Gemini LLM implementation using gemini-live Client.
The gemini-live Client is created once at construction time and reused for
all generate() calls, matching the JS GenAI SDK pattern where a single
GoogleGenAI instance is shared across requests.
Implementations§
Source§impl GeminiLlm
impl GeminiLlm
Sourcepub fn new(params: GeminiLlmParams) -> Self
pub fn new(params: GeminiLlmParams) -> Self
Create a new GeminiLlm from parameters.
Resolves defaults for model, variant, API key, project, and location
from parameters first, then falls back to environment variables.
The gemini-live Client is created once here and reused for all calls.
Sourcepub fn from_env() -> Result<Self, LlmError>
pub fn from_env() -> Result<Self, LlmError>
A GeminiLlm configured from the environment, checked before any
request is made.
Reads the same variables as new —
GEMINI_API_KEY (or GOOGLE_GENAI_API_KEY, GOOGLE_API_KEY) for Google
AI; GOOGLE_GENAI_USE_VERTEXAI=true with GOOGLE_CLOUD_PROJECT and
optionally GOOGLE_CLOUD_LOCATION for Vertex AI; GEMINI_TEXT_MODEL or
GEMINI_MODEL for the model — and fails with a message naming the
variable to set when one is missing, or when the model is a Live model
the text API does not serve. new accepts the same
configuration and fails on the first request instead.
use gemini_adk_rs::llm::GeminiLlm;
let llm = GeminiLlm::from_env()?;Sourcepub fn try_new(params: GeminiLlmParams) -> Result<Self, LlmError>
pub fn try_new(params: GeminiLlmParams) -> Result<Self, LlmError>
Sourcepub fn is_supported(model: &str) -> bool
pub fn is_supported(model: &str) -> bool
Check if a model name is supported by GeminiLlm.
Sourcepub fn variant(&self) -> GoogleLlmVariant
pub fn variant(&self) -> GoogleLlmVariant
Get the variant (VertexAI vs GeminiApi).
Trait Implementations§
Source§impl BaseLlm for GeminiLlm
impl BaseLlm for GeminiLlm
Source§fn warm_up<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn warm_up<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pre-warm the HTTP connection pool by making a lightweight request.
Establishes the TCP+TLS connection so the first real generate()
call doesn’t pay the ~100-300ms handshake penalty. reqwest’s
connection pool keeps it alive for subsequent calls.
Source§fn generate<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn generate_stream<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmStream, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_stream<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmStream, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
LlmResponse::append folds them into the whole reply;
usage, when a chunk carries it, is cumulative. Read moreSource§fn capabilities(&self) -> ModelCapabilities
fn capabilities(&self) -> ModelCapabilities
model_id; back-ends
with authoritative knowledge should override.Auto Trait Implementations§
impl Freeze for GeminiLlm
impl !RefUnwindSafe for GeminiLlm
impl Send for GeminiLlm
impl Sync for GeminiLlm
impl Unpin for GeminiLlm
impl !UnwindSafe for GeminiLlm
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].