girb-gemini 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9205e934ea2b8b69659abff8e6a22e66b8b4336f50c143cc2d4165646345fe41
4
- data.tar.gz: cd7982ef917af81637ee997a984095bb2c068b1c6a2bf4daf99966e3dab8bb02
3
+ metadata.gz: f31f46cab9413d0ab42e04ab660d422d2c2eab6aa3c24c73bd0cb92302ddee7b
4
+ data.tar.gz: 96d2cf77aec44f0d0e3e7ed58974be763f5f0fd84b5ffeeadf02b1fe501825ae
5
5
  SHA512:
6
- metadata.gz: e82a2cdb733062c6a149249fb11faff79162267a042ec23c164a9712ed05626a775d61b9cbb1440279f082f7972cab32900c1009c1bad22f785b94e663cb866b
7
- data.tar.gz: 7f4ad4291a2283270d0d6c610d0fc66f00c5d990ed0d5100c6179f1bbb24e82bd25b1715c32eec914a5434976807d5cdb2769305948c2df0d7fdaa6638454aea
6
+ metadata.gz: e732d81d5c50e8e9d816c4980c0dd6ae88e050f08903bbae28a05b55a86a31c2a829893adfa8c2ddbb9a54be75b561aade611bf8ec81365de0b7483583055385
7
+ data.tar.gz: f9e9a2ce202940ed7085e4c3e3ee82cf73345233e29afb45006b4adcf2e1520d9b2c09a67fae97776c5fbd87316b5963da5b96da3e3820a5acc7e16fdbcabf82
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] - 2026-02-12
4
+
5
+ ### Added
6
+
7
+ - Web search tool powered by Google Search grounding
8
+ - Support for gemini-3-flash-preview and gemini-3-pro-preview models
9
+
3
10
  ## [0.2.0] - 2026-02-07
4
11
 
5
12
  ### Fixed
data/README.md CHANGED
@@ -74,6 +74,24 @@ export GEMINI_API_KEY=your-api-key
74
74
 
75
75
  - `gemini-2.5-flash` (default) - Fast and efficient
76
76
  - `gemini-2.5-pro` - More capable, slower
77
+ - `gemini-3-flash-preview` - Next generation, fast
78
+ - `gemini-3-pro-preview` - Next generation, more capable
79
+
80
+ ## Web Search
81
+
82
+ girb-gemini includes a built-in web search tool powered by Google Search. This allows the AI to retrieve up-to-date information during your IRB session.
83
+
84
+ Web search is **enabled by default**. To disable it:
85
+
86
+ ```ruby
87
+ Girb.configure do |c|
88
+ c.provider = Girb::Providers::Gemini.new(
89
+ api_key: ENV['GEMINI_API_KEY'],
90
+ model: 'gemini-2.5-flash',
91
+ google_search: false
92
+ )
93
+ end
94
+ ```
77
95
 
78
96
  ## Alternative: Environment Variable Configuration
79
97
 
data/README_ja.md CHANGED
@@ -72,6 +72,24 @@ export GEMINI_API_KEY=your-api-key
72
72
 
73
73
  - `gemini-2.5-flash` (デフォルト) - 高速で効率的
74
74
  - `gemini-2.5-pro` - より高性能、やや遅い
75
+ - `gemini-3-flash-preview` - 次世代モデル、高速
76
+ - `gemini-3-pro-preview` - 次世代モデル、より高性能
77
+
78
+ ## Web検索
79
+
80
+ girb-geminiにはGoogle Searchを利用したWeb検索ツールが組み込まれています。IRBセッション中にAIが最新の情報を取得できます。
81
+
82
+ Web検索は**デフォルトで有効**です。無効にするには:
83
+
84
+ ```ruby
85
+ Girb.configure do |c|
86
+ c.provider = Girb::Providers::Gemini.new(
87
+ api_key: ENV['GEMINI_API_KEY'],
88
+ model: 'gemini-2.5-flash',
89
+ google_search: false
90
+ )
91
+ end
92
+ ```
75
93
 
76
94
  ## 代替: 環境変数での設定
77
95
 
@@ -12,9 +12,16 @@ module Girb
12
12
  class Gemini < Base
13
13
  DEFAULT_MODEL = "gemini-2.5-flash"
14
14
 
15
- def initialize(api_key:, model: DEFAULT_MODEL)
15
+ def initialize(api_key:, model: DEFAULT_MODEL, google_search: true)
16
16
  @client = ::Gemini::Client.new(api_key)
17
17
  @model = model
18
+ @google_search = google_search
19
+
20
+ if @google_search
21
+ setup_web_search_tool
22
+ else
23
+ disable_web_search_tool
24
+ end
18
25
  end
19
26
 
20
27
  def chat(messages:, system_prompt:, tools:, binding: nil)
@@ -136,6 +143,19 @@ module Girb
136
143
  rescue
137
144
  nil
138
145
  end
146
+
147
+ def setup_web_search_tool
148
+ require_relative "web_search_tool"
149
+ WebSearchTool.client = @client
150
+ WebSearchTool.model = @model
151
+ Girb::Tools.register(WebSearchTool)
152
+ end
153
+
154
+ def disable_web_search_tool
155
+ return unless defined?(WebSearchTool)
156
+
157
+ WebSearchTool.client = nil
158
+ end
139
159
  end
140
160
  end
141
161
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Girb
4
+ module Providers
5
+ class WebSearchTool < Girb::Tools::Base
6
+ @client = nil
7
+ @model = nil
8
+
9
+ class << self
10
+ attr_accessor :client, :model
11
+
12
+ def tool_name
13
+ "web_search"
14
+ end
15
+
16
+ def description
17
+ "Search the web for current information. Use this when you need up-to-date information " \
18
+ "that may not be in your training data, such as latest API documentation, recent changes " \
19
+ "to libraries/frameworks, current error messages, or any real-time information."
20
+ end
21
+
22
+ def parameters
23
+ {
24
+ type: "object",
25
+ properties: {
26
+ query: {
27
+ type: "string",
28
+ description: "The search query. Be specific and include version numbers or dates when relevant."
29
+ }
30
+ },
31
+ required: ["query"]
32
+ }
33
+ end
34
+
35
+ def available?
36
+ !@client.nil?
37
+ end
38
+ end
39
+
40
+ def execute(binding, query:)
41
+ client = self.class.client
42
+ model = self.class.model
43
+ return { error: "Web search not configured" } unless client
44
+
45
+ response = client.generate_content(
46
+ query,
47
+ model: model,
48
+ google_search: true
49
+ )
50
+
51
+ text = response.text || ""
52
+ sources = format_sources(response)
53
+
54
+ {
55
+ result: text,
56
+ sources: sources
57
+ }
58
+ rescue StandardError => e
59
+ { error: "Web search failed: #{e.message}" }
60
+ end
61
+
62
+ private
63
+
64
+ def format_sources(response)
65
+ return [] unless response.respond_to?(:grounded?) && response.grounded?
66
+
67
+ response.grounding_sources.map do |s|
68
+ "#{s[:title]}: #{s[:url]}"
69
+ end
70
+ rescue
71
+ []
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GirbGemini
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: girb-gemini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rira100000000
@@ -54,6 +54,7 @@ files:
54
54
  - lib/girb-gemini.rb
55
55
  - lib/girb-gemini/version.rb
56
56
  - lib/girb/providers/gemini.rb
57
+ - lib/girb/providers/web_search_tool.rb
57
58
  homepage: https://github.com/rira100000000/girb-gemini
58
59
  licenses:
59
60
  - MIT