1 Commits

Author SHA1 Message Date
f7cc9977aa feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error (#19)
Some checks failed
Rust / build (pull_request) Failing after 3s
VertexApiError.details is now Option<Vec<serde_json::Value>> so that
unknown google.rpc.* detail types (e.g. RetryInfo, QuotaFailure) no
longer break deserialization and fall back to Error::HttpStatus. The
unused ErrorType, ErrorInfoMetadata, FieldViolation and Link types are
removed.

Add VertexApiError::retry_delay() which parses the protobuf duration in a
google.rpc.RetryInfo entry, and Error::retry_delay() which delegates to it.

Closes #19
2026-10-28 08:35:53 +00:00
5 changed files with 72 additions and 84 deletions

View File

@@ -10,19 +10,13 @@ env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
check: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# The Gitea runner image doesn't ship with Rust, unlike GitHub's. - name: Build
- uses: dtolnay/rust-toolchain@stable run: cargo build --verbose
with: - name: Run tests
components: clippy, rustfmt run: cargo test --verbose
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Test
run: cargo test

View File

@@ -1,5 +1,5 @@
use console::style; use console::style;
use dialoguer::{Input, theme::ColorfulTheme}; use dialoguer::{theme::ColorfulTheme, Input};
use gemini_rs::prelude::*; use gemini_rs::prelude::*;
use std::time::Duration; use std::time::Duration;

View File

@@ -19,12 +19,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.add_text_part("Answer as if you were Yoda") .add_text_part("Answer as if you were Yoda")
.build(); .build();
let user_prompt = vec![ let user_prompt = vec![Content::builder()
Content::builder() .role(Role::User)
.role(Role::User) .add_text_part("What is the airspeed of an unladen swallow?")
.add_text_part("What is the airspeed of an unladen swallow?") .build()];
.build(),
];
let request = GenerateContentRequest::builder() let request = GenerateContentRequest::builder()
.contents(user_prompt) .contents(user_prompt)

View File

@@ -15,12 +15,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
location_id, location_id,
); );
let prompt = vec![ let prompt = vec![Content::builder()
Content::builder() .role(Role::User)
.role(Role::User) .add_text_part("Tell me the story of the genesis of the universe as a bedtime story.")
.add_text_part("Tell me the story of the genesis of the universe as a bedtime story.") .build()];
.build(),
];
let request = GenerateContentRequest::builder().contents(prompt).build(); let request = GenerateContentRequest::builder().contents(prompt).build();

View File

@@ -14,12 +14,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
location_id, location_id,
); );
let prompt = vec![ let prompt = vec![Content::builder()
Content::builder() .role(Role::User)
.role(Role::User) .add_text_part("What is the airspeed of an unladen swallow?")
.add_text_part("What is the airspeed of an unladen swallow?") .build()];
.build(),
];
let request = GenerateContentRequest::builder().contents(prompt).build(); let request = GenerateContentRequest::builder().contents(prompt).build();
let response = gemini.generate_content(&request, "gemini-pro").await?; let response = gemini.generate_content(&request, "gemini-pro").await?;