swiftide_integrations/gemini/mod.rs
1//! This module provides integration with `Gemini`'s API, enabling the use of language models within
2//! the Swiftide project. It includes the `Gemini` struct for managing API clients and default
3//! options for prompt models. The module is conditionally compiled based on the "groq" feature
4//! flag.
5
6use crate::openai;
7
8use self::config::GeminiConfig;
9
10mod config;
11
12/// The `Gemini` struct encapsulates a `Gemini` client that implements
13/// [`swiftide_core::SimplePrompt`]
14///
15/// There is also a builder available.
16///
17/// By default it will look for a `GEMINI_API_KEY` environment variable. Note that a model
18/// always needs to be set, either with [`Gemini::with_default_prompt_model`] or via the builder.
19/// You can find available models in the Gemini documentation.
20///
21/// Under the hood it uses [`async_openai`], with the Gemini openai mapping. This means
22/// some features might not work as expected. See the Gemini documentation for details.
23pub type Gemini = openai::GenericOpenAI<GeminiConfig>;
24pub type GeminiBuilder = openai::GenericOpenAIBuilder<GeminiConfig>;
25pub type GeminiBuilderError = openai::GenericOpenAIBuilderError;
26pub use openai::{Options, OptionsBuilder, OptionsBuilderError};
27
28impl Gemini {
29 pub fn builder() -> GeminiBuilder {
30 GeminiBuilder::default()
31 }
32}
33
34impl Default for Gemini {
35 fn default() -> Self {
36 Self::builder().build().unwrap()
37 }
38}