Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 135b13a

Browse files
committed
fix: reinstated rust-tls to reqwest. Updated current model options. Updated docs
1 parent 819cb1e commit 135b13a

File tree

7 files changed

+42
-17
lines changed

7 files changed

+42
-17
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ Cargo.lock
1515

1616
# Sensitive or local environment variables
1717
.env
18+
.envrc
1819

1920
# Local test files
2021
request.json
2122

22-
# Added by cargo
23-
/target

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "google-generative-ai-rs"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
edition = "2021"
55
authors = ["Mick Clarke <avastmick@outlook.com>"]
66
license = "MIT"
@@ -18,7 +18,7 @@ env_logger = { version = "0.11" }
1818
futures = { version = "0.3" }
1919
gcp_auth = { version = "0.12" }
2020
log = { version = "0.4.20" }
21-
reqwest = { version = "0.12", default-features = false, features = ["json"] }
21+
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
2222
reqwest-streams = { version = "0.8.2", default-features = false, features = ["json"] }
2323
serde = { version = "1.0", features = ["derive"] }
2424
serde_json = { version = "1.0" }

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ An unofficial rust-based client library to interact with the Google generative A
55

66
The goal is to emulate the [Google AI Python SDK](https://github.com/google/generative-ai-python) but in Rust.
77

8-
The initial focus will be on the [newer Gemini models](https://blog.google/technology/ai/google-gemini-ai/), but the more stable and mature models will hopefully also be supported soon.
98

109
## Usage
1110

@@ -25,20 +24,24 @@ Please see [contributing](CONTRIBUTING.md) for the rules; they are standard thou
2524

2625
## Work status
2726

28-
## Potentially Breaking Changes
29-
30-
Version `0.3.0` may lead to breaking changes. This version adds in some `beta` features and I have now added a feature flag to enable these.
31-
3227
```
33-
google-generative-ai-rs = { version = "0.3.0", features = ["beta"] }
28+
google-generative-ai-rs = { version = "0.3.4", features = ["beta"] }
3429
```
3530

3631
Using the `beta` feature will enable the following:
3732

3833
- `gemini-1.5-pro-latest`
34+
- `gemini-1.0-pro`
35+
- `gemini-1.5-pro-latest")`
36+
- `gemini-1.5-flash")`
37+
- `"gemini-1.5-flash-8b")`
38+
- `gemini-2.0-flash-exp")`
39+
- or custom `Model::Custom(name)`
3940
- system instructions
4041
- `json_mode`
4142

43+
Note: `gemini-1.0-pro` is deprecated and will be unavailable from 15th February 2025.
44+
4245
I do my best to release working code.
4346

4447
Status today is: *"Happy path for both public and Vertex AI endpoints work for Gemini."*

examples/text_request_json.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#[cfg(feature = "beta")]
22
use std::env;
33

4+
#[cfg(feature = "beta")]
45
use google_generative_ai_rs::v1::gemini::request::GenerationConfig;
56

67
#[cfg(feature = "beta")]

examples/text_request_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2525

2626
// Either run as a standard text request or a stream generate content request
2727
let client = Client::new_from_model_response_type(
28-
google_generative_ai_rs::v1::gemini::Model::GeminiPro,
28+
google_generative_ai_rs::v1::gemini::Model::Gemini1_0Pro,
2929
token.clone(),
3030
ResponseType::StreamGenerateContent,
3131
);

src/v1/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ impl Client {
405405
) -> Result<GeminiResponse, serde_json::error::Error> {
406406
serde_json::from_value(json_value.clone())
407407
}
408+
408409
fn get_reqwest_client(&self, timeout: u64) -> Result<reqwest::Client, GoogleAPIError> {
409410
let client: reqwest::Client = reqwest::Client::builder()
410411
.timeout(Duration::from_secs(timeout))

src/v1/gemini.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,47 @@ pub struct ModelInformationList {
7676
#[serde(rename_all = "kebab-case")]
7777
pub enum Model {
7878
#[default]
79-
GeminiPro,
79+
Gemini1_0Pro,
8080
#[cfg(feature = "beta")]
8181
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
8282
Gemini1_5Pro,
83-
GeminiProVision,
83+
#[cfg(feature = "beta")]
84+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
85+
Gemini1_5Flash,
86+
#[cfg(feature = "beta")]
87+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
88+
Gemini1_5Flash8B,
89+
#[cfg(feature = "beta")]
90+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
91+
Gemini2_0Flash,
92+
#[cfg(feature = "beta")]
93+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
8494
Custom(String),
85-
// TODO Embedding001
95+
// TODO: Embedding004
8696
}
8797
impl fmt::Display for Model {
8898
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
8999
match self {
90-
Model::GeminiPro => write!(f, "gemini-pro"),
100+
Model::Gemini1_0Pro => write!(f, "gemini-1.0-pro"),
91101

92102
#[cfg(feature = "beta")]
103+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
93104
Model::Gemini1_5Pro => write!(f, "gemini-1.5-pro-latest"),
105+
#[cfg(feature = "beta")]
106+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
107+
Model::Gemini1_5Flash => write!(f, "gemini-1.5-flash"),
108+
#[cfg(feature = "beta")]
109+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
110+
Model::Gemini1_5Flash8B => write!(f, "gemini-1.5-flash-8b"),
94111

95-
Model::GeminiProVision => write!(f, "gemini-pro-vision"),
112+
#[cfg(feature = "beta")]
113+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
114+
Model::Gemini2_0Flash => write!(f, "gemini-2.0-flash-exp"),
96115

116+
#[cfg(feature = "beta")]
117+
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
97118
Model::Custom(name) => write!(f, "{}", name),
98-
// TODO Model::Embedding001 => write!(f, "embedding-001"),
119+
// TODO: Model::Embedding004 => write!(f, "text-embedding-004"),
99120
}
100121
}
101122
}

0 commit comments

Comments
 (0)