Commit Graph

88 Commits

Author SHA1 Message Date
440b3c7a87 fix: keep Retry-After for JSON error bodies and tighten parsing (#21)
All checks were successful
Rust / check (pull_request) Successful in 3m9s
- VertexApiError gains a serde-skipped retry_after field, filled from the
  Retry-After header. VertexApiError::retry_delay() prefers RetryInfo and
  falls back to it, so a JSON 429 without RetryInfo still exposes the
  header delay.
- parse_retry_after rejects anything but ASCII digits; u64::from_str
  alone accepted a leading '+'.
- Client tests share mock_client/http_response helpers instead of
  repeating the mock server setup in every test.
2026-10-28 19:49:45 +00:00
2e0016eb25 feat: capture HTTP Retry-After header in Error::retry_delay() (#21)
All checks were successful
Rust / check (pull_request) Successful in 2m41s
Error::HttpStatus gains a retry_after field, filled from the response's
Retry-After header (delay-seconds form) before the body is consumed.
Error::retry_delay() now returns it for HttpStatus errors, so a 429 or
503 with a non-Vertex body still exposes the server's retry hint.

Closes #21
2026-10-28 08:54:52 +00:00
faa72a6d7a Merge pull request 'feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error (#19)' (#20) from feat/retry-delay into main
All checks were successful
Rust / check (push) Successful in 2m44s
Reviewed-on: #20
2026-10-28 08:48:51 +00:00
a49d37f03d refactor: address review feedback on retry_delay (#19)
All checks were successful
Rust / check (pull_request) Successful in 2m42s
- Drop the unreachable checked_mul in parse_duration; a fraction of at
  most 9 digits scaled to nanoseconds always fits in a u32.
- Share a vertex_error test helper in error.rs instead of building
  VertexApiError inline.
- Bump version to 0.2.0 for the breaking VertexApiError.details change.
2026-10-28 08:44:53 +00:00
cecc14d31e feat: expose Gemini RetryInfo retry_delay() on VertexApiError and Error (#19)
All checks were successful
Rust / check (pull_request) Successful in 2m40s
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:38:02 +00:00
4791125943 Merge pull request 'ci: run fmt, clippy and tests on the Gitea runner' (#18) from ci/gitea-actions into main
All checks were successful
Rust / check (push) Successful in 2m39s
Reviewed-on: #18
2026-10-26 20:42:05 +00:00
6d49f9939c ci: install Rust on the Gitea runner and check fmt and clippy
All checks were successful
Rust / check (pull_request) Successful in 5m14s
The Gitea runner image doesn't include Rust, so every job failed at
'cargo: command not found'. Install the stable toolchain, cache the
build, and run cargo fmt --check and clippy alongside the tests.
2026-10-26 20:34:40 +00:00
c911fc382e style: run cargo fmt on examples 2026-10-26 20:34:40 +00:00
a8961b12e3 Merge pull request 'feat: allow missing name/args in FunctionCallData and add streamed argument fields (#12)' (#17) from feat/function-call-optional-fields into main
Some checks failed
Rust / build (push) Failing after 3s
Reviewed-on: #17
2026-10-26 19:59:46 +00:00
2f15b5298d feat: allow missing name/args in FunctionCallData and add streamed argument fields (#12)
Some checks failed
Rust / build (pull_request) Failing after 4s
2026-10-26 19:57:09 +00:00
01a4300bb3 Merge pull request 'feat: omit None fields on Content, add optional id to function call/response, and add Part helpers (#11)' (#16) from feat/content-none-and-part-helpers into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #16
2026-10-26 19:45:55 +00:00
a2cff20aff feat: omit None fields on Content, add optional id to function call/response, and add Part helpers (#11)
Some checks failed
Rust / build (pull_request) Failing after 4s
2026-10-26 19:39:36 +00:00
7d5c6e3e28 Merge pull request 'feat: check response status in all GeminiClient methods and add Error::is_retryable() (#10)' (#15) from feat/error-status-and-retryable into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #15
2026-10-26 19:26:46 +00:00
8d1c9c3bb6 feat: check response status in all GeminiClient methods and add Error::is_retryable() (#10)
Some checks failed
Rust / build (pull_request) Failing after 3s
2026-10-26 19:24:49 +00:00
7264276232 Merge pull request 'feat: add thoughts, cached content, and tool use token counts to UsageMetadata (#9)' (#14) from feat/usage-metadata-token-counts into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #14
2026-10-26 19:07:08 +00:00
763a1a5da6 feat: add thoughts, cached content, and tool use token counts to UsageMetadata (#9)
Some checks failed
Rust / build (pull_request) Failing after 3s
2026-10-26 18:52:18 +00:00
f9e74ee171 Merge pull request 'fix: propagate LinesCodecError in parse_sse_event (#8)' (#13) from fix/propagate-sse-lines-codec-error into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #13
2026-10-26 18:44:14 +00:00
20f7a4a34c fix: propagate LinesCodecError in parse_sse_event (#8)
Some checks failed
Rust / build (pull_request) Failing after 8m5s
2026-10-26 18:37:10 +00:00
e64a748d5c Merge pull request 'fix: decode every complete SSE event already in the buffer' (#7) from fix/sse-decode-loop into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #7
2026-10-25 17:04:22 +00:00
166bdefa89 fix: decode every complete SSE event already in the buffer
Some checks failed
Rust / build (pull_request) Failing after 8m5s
decode returned None after each non-empty line, which makes FramedRead wait for more bytes before decoding again, so each event was held until the next network read. Loop until an event is complete or the buffer has no full line left.
2026-10-25 16:56:54 +00:00
ebb49eb929 Merge pull request 'fix: return error on non-2xx response in stream_generate_content (#3)' (#4) from fix/stream-non-2xx-handling into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #4
2026-10-18 22:54:23 +01:00
9bade7a1e6 test: move client unit tests to sibling client_tests.rs per rust-testing conventions
Some checks failed
Rust / build (pull_request) Has been cancelled
2026-10-18 22:52:40 +01:00
ba9870277c fix: return error on non-2xx response in stream_generate_content (#3)
Some checks failed
Rust / build (pull_request) Has been cancelled
Check response.status() before building the SSE event stream. On non-success
status, parse the response body as GenerateContentResponseError when
possible (returning Error::VertexError), and fall back to Error::HttpStatus
with the status code and raw text. Adds tests for HTTP 400 Vertex error,
non-JSON HTTP 500 error, and successful 200 SSE streaming.
2026-10-18 22:47:23 +01:00
196d5a9f55 Merge pull request 'feat: support parametersJsonSchema on function declarations' (#2) from feat/parameters-json-schema into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #2
2026-10-18 08:54:33 +01:00
43cf7933fc feat: support parametersJsonSchema on function declarations
Some checks failed
Rust / build (pull_request) Has been cancelled
FunctionDeclaration.parameters becomes Option<Value>, and the new
parameters_json_schema field sends the schema as JSON Schema. Vertex
rejects many JSON Schema keywords in parameters ($schema, $ref/$defs,
const, type arrays) but accepts them in parametersJsonSchema. Both
fields are skipped when None, since Vertex rejects a declaration that
sets both.
2026-10-18 08:34:56 +01:00
69532ad110 Merge pull request 'feat/function-response-parts' (#1) from feat/function-response-parts into main
Some checks failed
Rust / build (push) Has been cancelled
Reviewed-on: #1
2026-10-17 15:05:38 +01:00
e120780006 docs: add multimodal function response example
Some checks failed
Rust / build (pull_request) Has been cancelled
Calls a function, returns a solid-color PNG as functionResponse.parts
inlineData, and checks that the model names the color. COLOR picks the
color; otherwise it is picked by time.
2026-10-17 15:02:29 +01:00
f4f275f2f9 feat: support multimodal function response parts
Adds an optional parts field to FunctionResponseData, serialized as
functionResponse.parts with inlineData, so function responses can carry
images. It is omitted when empty, so existing requests are unchanged.
2026-10-17 14:49:53 +01:00
494aab6d14 feat: add SSE streaming, thinking models, and modernized Part struct
Some checks failed
Rust / build (push) Has been cancelled
2026-09-20 16:42:55 +01:00
ad82fc712b fix: support response parts with extra fields like thoughtSignature
Some checks failed
Rust / build (push) Has been cancelled
Implement custom Deserialize for Part to tolerate additional response fields (such as thoughtSignature or thought) returned by thinking models.
2026-09-06 13:13:49 +01:00
f9c50a3f45 Expand README with features, quick start, examples, and API reference
Some checks failed
Rust / build (push) Has been cancelled
2026-04-06 21:13:49 +01:00
1d467138ed Move predict image safety settings to enum
Some checks failed
Rust / build (push) Has been cancelled
2025-06-08 09:24:34 +01:00
9a8732f609 Move PersonGeneration parameter to enum 2025-06-08 09:11:01 +01:00
6e64b8fd72 Add missing parameters to imagegen 2025-06-08 08:58:48 +01:00
d1678bdc37 Define specific error for event stream ended 2025-04-06 08:12:58 +01:00
8ff379d040 Fixes lifetime for TokenProvider 2025-04-05 19:51:07 +01:00
51d6a27017 Adds streaming generation that returns a streaming
- Introducues generate_content_stream that returns a Tokio Steam instead
of a Queue. This allows using the standard stream APIs from
tokio-streams.
- Replace future-utils with tokio-streams, mainly due to better
ergonomics for using the filter_map stream combinator.
2025-04-05 19:18:33 +01:00
de9b14b984 Add support for the Google Search tool
- Gemini 2.0 and above use a google_search tool instead of a
google_search_retrieval tool. This commit adds support for the new tool.
2025-03-26 20:47:48 +00:00
83663680c9 Increase embedding precision to f64 2024-12-31 08:39:46 +00:00
fd1223da59 More builder refactoring 2024-11-27 16:20:53 +00:00
56d6b95c53 Add shortcuts for commonly used functions 2024-11-27 15:57:18 +00:00
db5a01afef Adds more builders 2024-11-27 15:11:01 +00:00
326b3919d1 Add builders for GenerateContent and CountToken 2024-11-26 20:27:36 +00:00
e6de1d1ce7 Adds error logging when failing o parse response 2024-10-06 08:18:05 +01:00
eb36c49493 Merge branch 'main' of https://github.com/andreban/gemini-rs 2024-10-05 17:07:24 +01:00
bbe5433d83 Adds code for image generation 2024-10-05 17:07:18 +01:00
dc1b5cabdf Adds support for the response schema field
- Support is added by allowing a serde_json `Value`.
- In the future, this could be improved by using a proper `Schema`
definition.
2024-09-20 15:47:21 +01:00
cb954ea5db Adds safety setting 2024-08-15 14:45:27 +01:00
60c20958a4 Update README.md 2024-07-30 21:06:52 +01:00
d0d2dd6bab Make safety rating scores optional
- The API doesn't always return `probabilityScore` and
`severityScore` for a safety rating, causing the parsing to fail
- This commit makes those fields optional to fix that.
2024-07-30 15:04:16 +01:00