From 8f9c29383d8b437740e04286f861fda5b93e2db3 Mon Sep 17 00:00:00 2001 From: Mick Clarke Date: Fri, 29 Dec 2023 18:09:14 +1300 Subject: [PATCH 1/2] fix: to marshal the post response to correct struct type --- src/v1/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/api.rs b/src/v1/api.rs index c24d192..346ed8f 100644 --- a/src/v1/api.rs +++ b/src/v1/api.rs @@ -158,7 +158,7 @@ impl Client { let mut streamed_reponse = StreamedResponse { streamed_candidates: vec![], }; - let mut response_stream = response.json_array_stream::(2048); + let mut response_stream = response.json_array_stream::(2048); //TODO what is a good length? while let Some(json_value) = response_stream .try_next() From 097184ca421bbbca9ebc47c9aead5778fe32cfe0 Mon Sep 17 00:00:00 2001 From: Mick Clarke Date: Sat, 30 Dec 2023 19:22:33 +1300 Subject: [PATCH 2/2] fix: belt and braces on the reqwest::Error url to remove any potential sensitive info --- Cargo.toml | 2 +- src/v1/api.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 40bda3d..6e73e1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "google-generative-ai-rs" -version = "0.1.2" +version = "0.1.3" edition = "2021" authors = ["Mick Clarke "] license = "MIT" diff --git a/src/v1/api.rs b/src/v1/api.rs index 346ed8f..a165610 100644 --- a/src/v1/api.rs +++ b/src/v1/api.rs @@ -257,7 +257,12 @@ impl Client { } } /// Creates a new error from a reqwest error. - fn new_error_from_reqwest_error(&self, e: reqwest::Error) -> GoogleAPIError { + fn new_error_from_reqwest_error(&self, mut e: reqwest::Error) -> GoogleAPIError { + if let Some(url) = e.url_mut() { + // Remove the API key from the URL, if any + url.query_pairs_mut().clear(); + } + GoogleAPIError { message: format!("{}", e), code: e.status(),