girb-gemini 0.1.1 → 0.2.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/CHANGELOG.md +8 -0
- data/README.md +47 -14
- data/README_ja.md +47 -14
- data/lib/girb/providers/gemini.rb +30 -10
- data/lib/girb-gemini/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9205e934ea2b8b69659abff8e6a22e66b8b4336f50c143cc2d4165646345fe41
|
|
4
|
+
data.tar.gz: cd7982ef917af81637ee997a984095bb2c068b1c6a2bf4daf99966e3dab8bb02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e82a2cdb733062c6a149249fb11faff79162267a042ec23c164a9712ed05626a775d61b9cbb1440279f082f7972cab32900c1009c1bad22f785b94e663cb866b
|
|
7
|
+
data.tar.gz: 7f4ad4291a2283270d0d6c610d0fc66f00c5d990ed0d5100c6179f1bbb24e82bd25b1715c32eec914a5434976807d5cdb2769305948c2df0d7fdaa6638454aea
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-02-07
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Fix Gemini 3 thought_signature error on function calls
|
|
8
|
+
- Preserve thought_signature from API response and include it when sending function call history back to the API
|
|
9
|
+
- Clear false-positive websocket-native LoadError from ExceptionCapture after loading ruby-gemini-api
|
|
10
|
+
|
|
3
11
|
## [0.1.1] - 2026-02-03
|
|
4
12
|
|
|
5
13
|
### Added
|
data/README.md
CHANGED
|
@@ -6,53 +6,86 @@ Google Gemini LLM provider for [girb](https://github.com/rira100000000/girb) (AI
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
### For Rails Projects
|
|
10
|
+
|
|
9
11
|
Add to your Gemfile:
|
|
10
12
|
|
|
11
13
|
```ruby
|
|
12
|
-
|
|
13
|
-
gem 'girb-gemini'
|
|
14
|
+
group :development do
|
|
15
|
+
gem 'girb-gemini'
|
|
16
|
+
end
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
Then run:
|
|
17
20
|
|
|
18
21
|
```bash
|
|
19
|
-
|
|
22
|
+
bundle install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Create a `.girbrc` file in your project root:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
# .girbrc
|
|
29
|
+
require 'girb-gemini'
|
|
30
|
+
|
|
31
|
+
Girb.configure do |c|
|
|
32
|
+
c.provider = Girb::Providers::Gemini.new(
|
|
33
|
+
api_key: ENV['GEMINI_API_KEY'],
|
|
34
|
+
model: 'gemini-2.5-flash'
|
|
35
|
+
)
|
|
36
|
+
end
|
|
20
37
|
```
|
|
21
38
|
|
|
22
|
-
|
|
39
|
+
Now `rails console` will automatically load girb!
|
|
23
40
|
|
|
24
|
-
###
|
|
41
|
+
### For Non-Rails Projects
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
Install globally:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gem install girb girb-gemini
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Create a `.girbrc` file in your project directory:
|
|
27
50
|
|
|
28
51
|
```ruby
|
|
52
|
+
# .girbrc
|
|
29
53
|
require 'girb-gemini'
|
|
30
54
|
|
|
31
55
|
Girb.configure do |c|
|
|
32
56
|
c.provider = Girb::Providers::Gemini.new(
|
|
33
|
-
api_key: '
|
|
57
|
+
api_key: ENV['GEMINI_API_KEY'],
|
|
34
58
|
model: 'gemini-2.5-flash'
|
|
35
59
|
)
|
|
36
60
|
end
|
|
37
61
|
```
|
|
38
62
|
|
|
39
|
-
Then use
|
|
63
|
+
Then use `girb` command instead of `irb`.
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
Set your API key as an environment variable:
|
|
42
68
|
|
|
43
69
|
```bash
|
|
44
|
-
export GIRB_PROVIDER=girb-gemini
|
|
45
|
-
export GIRB_MODEL=gemini-2.5-flash # optional, defaults to gemini-2.5-flash
|
|
46
70
|
export GEMINI_API_KEY=your-api-key
|
|
47
71
|
```
|
|
48
72
|
|
|
49
|
-
Then start with `girb` command.
|
|
50
|
-
|
|
51
73
|
## Available Models
|
|
52
74
|
|
|
53
75
|
- `gemini-2.5-flash` (default) - Fast and efficient
|
|
54
76
|
- `gemini-2.5-pro` - More capable, slower
|
|
55
77
|
|
|
78
|
+
## Alternative: Environment Variable Configuration
|
|
79
|
+
|
|
80
|
+
For the `girb` command, you can also configure via environment variables (used when no `.girbrc` is found):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
export GIRB_PROVIDER=girb-gemini
|
|
84
|
+
export GIRB_MODEL=gemini-2.5-flash # optional, defaults to gemini-2.5-flash
|
|
85
|
+
export GEMINI_API_KEY=your-api-key
|
|
86
|
+
girb
|
|
87
|
+
```
|
|
88
|
+
|
|
56
89
|
## License
|
|
57
90
|
|
|
58
91
|
MIT License
|
data/README_ja.md
CHANGED
|
@@ -4,53 +4,86 @@
|
|
|
4
4
|
|
|
5
5
|
## インストール
|
|
6
6
|
|
|
7
|
+
### Railsプロジェクトの場合
|
|
8
|
+
|
|
7
9
|
Gemfileに追加:
|
|
8
10
|
|
|
9
11
|
```ruby
|
|
10
|
-
|
|
11
|
-
gem 'girb-gemini'
|
|
12
|
+
group :development do
|
|
13
|
+
gem 'girb-gemini'
|
|
14
|
+
end
|
|
12
15
|
```
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
そして実行:
|
|
15
18
|
|
|
16
19
|
```bash
|
|
17
|
-
|
|
20
|
+
bundle install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
プロジェクトルートに `.girbrc` ファイルを作成:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
# .girbrc
|
|
27
|
+
require 'girb-gemini'
|
|
28
|
+
|
|
29
|
+
Girb.configure do |c|
|
|
30
|
+
c.provider = Girb::Providers::Gemini.new(
|
|
31
|
+
api_key: ENV['GEMINI_API_KEY'],
|
|
32
|
+
model: 'gemini-2.5-flash'
|
|
33
|
+
)
|
|
34
|
+
end
|
|
18
35
|
```
|
|
19
36
|
|
|
20
|
-
|
|
37
|
+
これで `rails console` が自動的にgirbを読み込みます!
|
|
21
38
|
|
|
22
|
-
###
|
|
39
|
+
### 非Railsプロジェクトの場合
|
|
23
40
|
|
|
24
|
-
|
|
41
|
+
グローバルにインストール:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
gem install girb girb-gemini
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
プロジェクトディレクトリに `.girbrc` ファイルを作成:
|
|
25
48
|
|
|
26
49
|
```ruby
|
|
50
|
+
# .girbrc
|
|
27
51
|
require 'girb-gemini'
|
|
28
52
|
|
|
29
53
|
Girb.configure do |c|
|
|
30
54
|
c.provider = Girb::Providers::Gemini.new(
|
|
31
|
-
api_key: '
|
|
55
|
+
api_key: ENV['GEMINI_API_KEY'],
|
|
32
56
|
model: 'gemini-2.5-flash'
|
|
33
57
|
)
|
|
34
58
|
end
|
|
35
59
|
```
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
`irb` の代わりに `girb` コマンドを使用します。
|
|
62
|
+
|
|
63
|
+
## 設定
|
|
38
64
|
|
|
39
|
-
|
|
65
|
+
APIキーを環境変数として設定:
|
|
40
66
|
|
|
41
67
|
```bash
|
|
42
|
-
export GIRB_PROVIDER=girb-gemini
|
|
43
|
-
export GIRB_MODEL=gemini-2.5-flash # オプション、デフォルトは gemini-2.5-flash
|
|
44
68
|
export GEMINI_API_KEY=your-api-key
|
|
45
69
|
```
|
|
46
70
|
|
|
47
|
-
`girb` コマンドで起動します。
|
|
48
|
-
|
|
49
71
|
## 利用可能なモデル
|
|
50
72
|
|
|
51
73
|
- `gemini-2.5-flash` (デフォルト) - 高速で効率的
|
|
52
74
|
- `gemini-2.5-pro` - より高性能、やや遅い
|
|
53
75
|
|
|
76
|
+
## 代替: 環境変数での設定
|
|
77
|
+
|
|
78
|
+
`girb` コマンドでは、`.girbrc` が見つからない場合に環境変数で設定することもできます:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
export GIRB_PROVIDER=girb-gemini
|
|
82
|
+
export GIRB_MODEL=gemini-2.5-flash # オプション、デフォルトは gemini-2.5-flash
|
|
83
|
+
export GEMINI_API_KEY=your-api-key
|
|
84
|
+
girb
|
|
85
|
+
```
|
|
86
|
+
|
|
54
87
|
## ライセンス
|
|
55
88
|
|
|
56
89
|
MIT License
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "gemini"
|
|
4
|
+
# ruby-gemini-apiがgemini/live→websocket→websocket-native(オプション)を
|
|
5
|
+
# requireする過程でLoadErrorが発生しrescueされるが、
|
|
6
|
+
# ExceptionCaptureのTracePointに捕捉される場合があるためクリアする
|
|
7
|
+
Girb::ExceptionCapture.clear if defined?(Girb::ExceptionCapture)
|
|
4
8
|
require "girb/providers/base"
|
|
5
9
|
|
|
6
10
|
module Girb
|
|
@@ -13,7 +17,7 @@ module Girb
|
|
|
13
17
|
@model = model
|
|
14
18
|
end
|
|
15
19
|
|
|
16
|
-
def chat(messages:, system_prompt:, tools:)
|
|
20
|
+
def chat(messages:, system_prompt:, tools:, binding: nil)
|
|
17
21
|
contents = convert_messages(messages)
|
|
18
22
|
tools_param = build_tools_param(tools)
|
|
19
23
|
|
|
@@ -41,15 +45,16 @@ module Girb
|
|
|
41
45
|
when :assistant
|
|
42
46
|
{ role: "model", parts: [{ text: msg[:content] }] }
|
|
43
47
|
when :tool_call
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
args: msg[:args]
|
|
50
|
-
}
|
|
51
|
-
}]
|
|
48
|
+
part = {
|
|
49
|
+
functionCall: {
|
|
50
|
+
name: msg[:name],
|
|
51
|
+
args: msg[:args]
|
|
52
|
+
}
|
|
52
53
|
}
|
|
54
|
+
if msg.dig(:metadata, :thought_signature)
|
|
55
|
+
part[:thoughtSignature] = msg[:metadata][:thought_signature]
|
|
56
|
+
end
|
|
57
|
+
{ role: "model", parts: [part] }
|
|
53
58
|
when :tool_result
|
|
54
59
|
{
|
|
55
60
|
role: "user",
|
|
@@ -109,13 +114,28 @@ module Girb
|
|
|
109
114
|
def parse_function_calls(response)
|
|
110
115
|
return [] unless response.function_calls&.any?
|
|
111
116
|
|
|
117
|
+
# Extract thought_signature from response parts
|
|
118
|
+
thought_signature = extract_thought_signature(response)
|
|
119
|
+
|
|
112
120
|
response.function_calls.map do |fc|
|
|
113
|
-
{
|
|
121
|
+
result = {
|
|
114
122
|
name: fc["name"],
|
|
115
123
|
args: fc["args"] || {}
|
|
116
124
|
}
|
|
125
|
+
if thought_signature
|
|
126
|
+
result[:metadata] = { thought_signature: thought_signature }
|
|
127
|
+
end
|
|
128
|
+
result
|
|
117
129
|
end
|
|
118
130
|
end
|
|
131
|
+
|
|
132
|
+
def extract_thought_signature(response)
|
|
133
|
+
return nil unless response.respond_to?(:first_thought_signature)
|
|
134
|
+
|
|
135
|
+
response.first_thought_signature
|
|
136
|
+
rescue
|
|
137
|
+
nil
|
|
138
|
+
end
|
|
119
139
|
end
|
|
120
140
|
end
|
|
121
141
|
end
|
data/lib/girb-gemini/version.rb
CHANGED