ruby-gemini-api 0.1.3 → 0.1.4

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: 42b86546e154705767e40dad92410df0e1be21e335ae95630d8c2213f42a8a04
4
- data.tar.gz: ea10d1a8c13bf0c49ccd720c9e1c25494b9c9a4955879b15e20c2722d5f8f712
3
+ metadata.gz: c80fbf2cb7142ab3ff7d6a17d8b5f1e43960ec8ed398ee7f4c35286ed72ce962
4
+ data.tar.gz: 261f1a1e04757b93aac9c8a42263e355758bba4ec512f6c9dd408b63146e17fe
5
5
  SHA512:
6
- metadata.gz: 778b3de54c33818cb7d8fc6f2adc6e3876b5db4ef6dae3c9c1e1ad0db429c4b9c3225ae0518545feaba441cea212fbff0843ee72fe095c73f5fbc3b0c3a37862
7
- data.tar.gz: 07cfd038ac791757e11ea1784ba48760fd3b292b6cb5edf8434930dcd4815da89431259ca9359718dc665117630d82d70852f934ef1644130d92666d0c504e12
6
+ metadata.gz: 780a9684677d9bfdd8945727c9cd00e1e0ecc9e43a63a038da17a18aa8e524e43f601946bd1fbc00c9406e4a45b80d59fedfdfc85e190b973cedd9c2340a5be4
7
+ data.tar.gz: 399dff8bc6f6693b6267412b2fee067269125ea9b16ffd105d94b4ac9154ca1ade4246b6d3ca9aa9e7cb689e3f2d4a12ea771d4fc688de24e36688205675ab0f
data/CHANGELOG.md CHANGED
@@ -10,4 +10,7 @@
10
10
  - Add function calling
11
11
 
12
12
  ## [0.1.3] - 2025-10-09
13
- - Add support for multi-image input
13
+ - Add support for multi-image input
14
+
15
+ ## [0.1.4] - 2025-11-08
16
+ - Add support for grounding search
data/README.md CHANGED
@@ -272,6 +272,79 @@ client.files.delete(name: file_name)
272
272
 
273
273
  For more examples, check out the `demo/vision_demo.rb` and `demo/file_vision_demo.rb` files included with the gem.
274
274
 
275
+ ### Grounding with Google Search
276
+
277
+ You can use Gemini API's Google Search grounding feature to retrieve real-time information.
278
+
279
+ #### Basic Usage
280
+
281
+ ```ruby
282
+ require 'gemini'
283
+
284
+ client = Gemini::Client.new(ENV['GEMINI_API_KEY'])
285
+
286
+ # Use Google Search to get real-time information
287
+ response = client.generate_content(
288
+ "Who won the euro 2024?",
289
+ model: "gemini-2.0-flash-lite",
290
+ tools: [{ google_search: {} }]
291
+ )
292
+
293
+ if response.success?
294
+ puts response.text
295
+
296
+ # Check grounding information
297
+ if response.grounded?
298
+ puts "\nSource references:"
299
+ response.grounding_chunks.each do |chunk|
300
+ if chunk['web']
301
+ puts "- #{chunk['web']['title']}"
302
+ puts " #{chunk['web']['uri']}"
303
+ end
304
+ end
305
+ end
306
+ end
307
+ ```
308
+
309
+ #### Checking Grounding Metadata
310
+
311
+ ```ruby
312
+ # Check if response is grounded
313
+ if response.grounded?
314
+ # Get full grounding metadata
315
+ metadata = response.grounding_metadata
316
+
317
+ # Get source chunks (references)
318
+ chunks = response.grounding_chunks
319
+
320
+ # Get search entry point
321
+ entry_point = response.search_entry_point
322
+ end
323
+ ```
324
+
325
+ #### Example with Different Topics
326
+
327
+ ```ruby
328
+ response = client.generate_content(
329
+ "What are the latest AI developments in 2024?",
330
+ model: "gemini-2.0-flash-lite",
331
+ tools: [{ google_search: {} }]
332
+ )
333
+
334
+ if response.success? && response.grounded?
335
+ puts response.text
336
+ puts "\nSources: #{response.grounding_chunks.length} references"
337
+ end
338
+ ```
339
+
340
+ #### Demo Application
341
+
342
+ You can find a grounding search demo in:
343
+
344
+ ```bash
345
+ ruby demo/grounding_search_demo_ja.rb
346
+ ```
347
+
275
348
  ### Image Generation
276
349
 
277
350
  ```ruby
@@ -99,6 +99,27 @@ module Gemini
99
99
  def safety_blocked?
100
100
  finish_reason == "SAFETY"
101
101
  end
102
+
103
+ # Get grounding metadata (for Google Search grounding)
104
+ def grounding_metadata
105
+ first_candidate&.dig("groundingMetadata")
106
+ end
107
+
108
+ # Check if response has grounding metadata
109
+ def grounded?
110
+ !grounding_metadata.nil? && !grounding_metadata.empty?
111
+ end
112
+
113
+ # Get grounding chunks (source references)
114
+ def grounding_chunks
115
+ grounding_metadata&.dig("groundingChunks") || []
116
+ end
117
+
118
+ # Get search entry point URL (if available)
119
+ def search_entry_point
120
+ grounding_metadata&.dig("searchEntryPoint", "renderedContent")
121
+ end
122
+
102
123
 
103
124
  # Get token usage information
104
125
  def usage
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gemini
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gemini-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - rira100000000
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-09 00:00:00.000000000 Z
11
+ date: 2025-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday