gemini-ai 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +42 -4
- data/controllers/client.rb +14 -1
- data/gemini-ai.gemspec +1 -1
- data/static/gem.rb +1 -1
- data/template.md +40 -4
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36be77448ab7ba00008ac7548c25fdca45b92980762303631de5d6bdbcd2d01a
|
4
|
+
data.tar.gz: e0772790afa6019424282e8ac665fb0049da13a76ecc43909b147655f6f95a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d6c7391dff2ce75a46e3ceb5c7ef9c07c6cdcfc55477df68be1df2e06f77ff77d795ee6e70abc9ad73001e8dd583d39949a394140b129d08c2db94c2b8f7c4
|
7
|
+
data.tar.gz: 2acedebdfe562b7b68d19046a2f2b06bec6fbe75768cc7066b7c1e31cb72bc4caa551a8d656ffc6537c714f0d11965f3cc9f74542e7bc9315f0998f35390d5f4
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gemini-ai (3.
|
4
|
+
gemini-ai (3.1.0)
|
5
5
|
event_stream_parser (~> 1.0)
|
6
|
-
faraday (~> 2.
|
6
|
+
faraday (~> 2.8, >= 2.8.1)
|
7
7
|
googleauth (~> 1.9, >= 1.9.1)
|
8
8
|
|
9
9
|
GEM
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
byebug (11.1.3)
|
17
17
|
coderay (1.1.3)
|
18
18
|
event_stream_parser (1.0.0)
|
19
|
-
faraday (2.
|
19
|
+
faraday (2.8.1)
|
20
20
|
base64
|
21
21
|
faraday-net_http (>= 2.0, < 3.1)
|
22
22
|
ruby2_keywords (>= 0.0.4)
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ A Ruby Gem for interacting with [Gemini](https://deepmind.google/technologies/ge
|
|
9
9
|
## TL;DR and Quick Start
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'gemini-ai', '~> 3.
|
12
|
+
gem 'gemini-ai', '~> 3.1.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
```ruby
|
@@ -96,6 +96,8 @@ Result:
|
|
96
96
|
- [Back-and-Forth Conversations](#back-and-forth-conversations)
|
97
97
|
- [Tools (Functions) Calling](#tools-functions-calling)
|
98
98
|
- [New Functionalities and APIs](#new-functionalities-and-apis)
|
99
|
+
- [Request Options](#request-options)
|
100
|
+
- [Timeout](#timeout)
|
99
101
|
- [Error Handling](#error-handling)
|
100
102
|
- [Rescuing](#rescuing)
|
101
103
|
- [For Short](#for-short)
|
@@ -112,11 +114,11 @@ Result:
|
|
112
114
|
### Installing
|
113
115
|
|
114
116
|
```sh
|
115
|
-
gem install gemini-ai -v 3.
|
117
|
+
gem install gemini-ai -v 3.1.0
|
116
118
|
```
|
117
119
|
|
118
120
|
```sh
|
119
|
-
gem 'gemini-ai', '~> 3.
|
121
|
+
gem 'gemini-ai', '~> 3.1.0'
|
120
122
|
```
|
121
123
|
|
122
124
|
### Credentials
|
@@ -872,6 +874,42 @@ result = client.request(
|
|
872
874
|
)
|
873
875
|
```
|
874
876
|
|
877
|
+
### Request Options
|
878
|
+
|
879
|
+
#### Timeout
|
880
|
+
|
881
|
+
You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
|
882
|
+
|
883
|
+
```ruby
|
884
|
+
client = Gemini.new(
|
885
|
+
credentials: { service: 'vertex-ai-api', region: 'us-east4' },
|
886
|
+
options: {
|
887
|
+
model: 'gemini-pro',
|
888
|
+
connection: { request: { timeout: 5 } }
|
889
|
+
}
|
890
|
+
)
|
891
|
+
```
|
892
|
+
|
893
|
+
You can also have more fine-grained control over [Faraday's Request Options](https://lostisland.github.io/faraday/#/customization/request-options?id=request-options) if you prefer:
|
894
|
+
|
895
|
+
```ruby
|
896
|
+
client = Gemini.new(
|
897
|
+
credentials: { service: 'vertex-ai-api', region: 'us-east4' },
|
898
|
+
options: {
|
899
|
+
model: 'gemini-pro',
|
900
|
+
connection: {
|
901
|
+
request: {
|
902
|
+
timeout: 5,
|
903
|
+
open_timeout: 5,
|
904
|
+
read_timeout: 5,
|
905
|
+
write_timeout: 5
|
906
|
+
}
|
907
|
+
}
|
908
|
+
}
|
909
|
+
)
|
910
|
+
```
|
911
|
+
|
912
|
+
|
875
913
|
### Error Handling
|
876
914
|
|
877
915
|
#### Rescuing
|
@@ -942,7 +980,7 @@ gem build gemini-ai.gemspec
|
|
942
980
|
|
943
981
|
gem signin
|
944
982
|
|
945
|
-
gem push gemini-ai-3.
|
983
|
+
gem push gemini-ai-3.1.0.gem
|
946
984
|
```
|
947
985
|
|
948
986
|
### Updating the README
|
data/controllers/client.rb
CHANGED
@@ -10,6 +10,8 @@ require_relative '../ports/dsl/gemini-ai/errors'
|
|
10
10
|
module Gemini
|
11
11
|
module Controllers
|
12
12
|
class Client
|
13
|
+
ALLOWED_REQUEST_OPTIONS = %i[timeout open_timeout read_timeout write_timeout].freeze
|
14
|
+
|
13
15
|
def initialize(config)
|
14
16
|
if config[:credentials][:api_key]
|
15
17
|
@authentication = :api_key
|
@@ -43,6 +45,16 @@ module Gemini
|
|
43
45
|
end
|
44
46
|
|
45
47
|
@server_sent_events = config[:options][:server_sent_events]
|
48
|
+
|
49
|
+
@request_options = config.dig(:options, :connection, :request)
|
50
|
+
|
51
|
+
@request_options = if @request_options.is_a?(Hash)
|
52
|
+
@request_options.select do |key, _|
|
53
|
+
ALLOWED_REQUEST_OPTIONS.include?(key)
|
54
|
+
end
|
55
|
+
else
|
56
|
+
{}
|
57
|
+
end
|
46
58
|
end
|
47
59
|
|
48
60
|
def stream_generate_content(payload, server_sent_events: nil, &callback)
|
@@ -74,8 +86,9 @@ module Gemini
|
|
74
86
|
|
75
87
|
results = []
|
76
88
|
|
77
|
-
response = Faraday.new do |faraday|
|
89
|
+
response = Faraday.new(request: @request_options) do |faraday|
|
78
90
|
faraday.response :raise_error
|
91
|
+
faraday.options.timeout = @timeout if @timeout
|
79
92
|
end.post do |request|
|
80
93
|
request.url url
|
81
94
|
request.headers['Content-Type'] = 'application/json'
|
data/gemini-ai.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ['ports/dsl']
|
31
31
|
|
32
32
|
spec.add_dependency 'event_stream_parser', '~> 1.0'
|
33
|
-
spec.add_dependency 'faraday', '~> 2.
|
33
|
+
spec.add_dependency 'faraday', '~> 2.8', '>= 2.8.1'
|
34
34
|
spec.add_dependency 'googleauth', '~> 1.9', '>= 1.9.1'
|
35
35
|
|
36
36
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
data/static/gem.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Gemini
|
4
4
|
GEM = {
|
5
5
|
name: 'gemini-ai',
|
6
|
-
version: '3.
|
6
|
+
version: '3.1.0',
|
7
7
|
author: 'gbaptista',
|
8
8
|
summary: "Interact with Google's Gemini AI.",
|
9
9
|
description: "A Ruby Gem for interacting with Gemini through Vertex AI, Generative Language API, or AI Studio, Google's generative AI services.",
|
data/template.md
CHANGED
@@ -9,7 +9,7 @@ A Ruby Gem for interacting with [Gemini](https://deepmind.google/technologies/ge
|
|
9
9
|
## TL;DR and Quick Start
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'gemini-ai', '~> 3.
|
12
|
+
gem 'gemini-ai', '~> 3.1.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
```ruby
|
@@ -77,11 +77,11 @@ Result:
|
|
77
77
|
### Installing
|
78
78
|
|
79
79
|
```sh
|
80
|
-
gem install gemini-ai -v 3.
|
80
|
+
gem install gemini-ai -v 3.1.0
|
81
81
|
```
|
82
82
|
|
83
83
|
```sh
|
84
|
-
gem 'gemini-ai', '~> 3.
|
84
|
+
gem 'gemini-ai', '~> 3.1.0'
|
85
85
|
```
|
86
86
|
|
87
87
|
### Credentials
|
@@ -837,6 +837,42 @@ result = client.request(
|
|
837
837
|
)
|
838
838
|
```
|
839
839
|
|
840
|
+
### Request Options
|
841
|
+
|
842
|
+
#### Timeout
|
843
|
+
|
844
|
+
You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
|
845
|
+
|
846
|
+
```ruby
|
847
|
+
client = Gemini.new(
|
848
|
+
credentials: { service: 'vertex-ai-api', region: 'us-east4' },
|
849
|
+
options: {
|
850
|
+
model: 'gemini-pro',
|
851
|
+
connection: { request: { timeout: 5 } }
|
852
|
+
}
|
853
|
+
)
|
854
|
+
```
|
855
|
+
|
856
|
+
You can also have more fine-grained control over [Faraday's Request Options](https://lostisland.github.io/faraday/#/customization/request-options?id=request-options) if you prefer:
|
857
|
+
|
858
|
+
```ruby
|
859
|
+
client = Gemini.new(
|
860
|
+
credentials: { service: 'vertex-ai-api', region: 'us-east4' },
|
861
|
+
options: {
|
862
|
+
model: 'gemini-pro',
|
863
|
+
connection: {
|
864
|
+
request: {
|
865
|
+
timeout: 5,
|
866
|
+
open_timeout: 5,
|
867
|
+
read_timeout: 5,
|
868
|
+
write_timeout: 5
|
869
|
+
}
|
870
|
+
}
|
871
|
+
}
|
872
|
+
)
|
873
|
+
```
|
874
|
+
|
875
|
+
|
840
876
|
### Error Handling
|
841
877
|
|
842
878
|
#### Rescuing
|
@@ -907,7 +943,7 @@ gem build gemini-ai.gemspec
|
|
907
943
|
|
908
944
|
gem signin
|
909
945
|
|
910
|
-
gem push gemini-ai-3.
|
946
|
+
gem push gemini-ai-3.1.0.gem
|
911
947
|
```
|
912
948
|
|
913
949
|
### Updating the README
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemini-ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gbaptista
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.8'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.
|
36
|
+
version: 2.8.1
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '2.
|
43
|
+
version: '2.8'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
46
|
+
version: 2.8.1
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: googleauth
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.3.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Interact with Google's Gemini AI.
|