google-genai 0.1.0 → 0.1.1
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/README.md +37 -1
- data/lib/google/genai/client.rb +1 -0
- data/lib/google/genai/version.rb +1 -1
- 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: 1f244207b40e13c6ff1702ddd721bdd75583ffd11eae0c76ffa900e1a02e37e7
|
|
4
|
+
data.tar.gz: 912a9bc9e1411edc29856be4e497983fdeed31cebc0deadc5275cb88c4daf9ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a28c3e8b7b3d0b63037cb27b434e03ec47fb5c31ba65bf4002c71635347a427b2e6d8746ebdbeb2d691bd028b22ad1389a6e190e91b8fb9aa225cd241a97bc1
|
|
7
|
+
data.tar.gz: cdc7b1bc60e17b8ce6a75060b60d7808d1856bfcc6829632d84e9077ba42ed0fd566031975f09b832161155a34266be7024a33c05ec5bb932d6f29ef96b9e3b1
|
data/README.md
CHANGED
|
@@ -22,7 +22,43 @@ Or install it yourself as:
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Here's a quick example of how to upload an audio file and generate a summary.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
require 'google/genai'
|
|
29
|
+
|
|
30
|
+
# The client will automatically use the GOOGLE_API_KEY or GEMINI_API_KEY environment variable.
|
|
31
|
+
client = Google::Genai::Client.new
|
|
32
|
+
|
|
33
|
+
# Path to your local audio file.
|
|
34
|
+
audio_file_path = 'path/to/your/audio.mp4' # <--- CHANGE THIS
|
|
35
|
+
|
|
36
|
+
begin
|
|
37
|
+
# Upload the file to the Gemini API.
|
|
38
|
+
# If the automatically detected MIME type is incorrect (e.g., for an MP4 audio file),
|
|
39
|
+
# you can override it like this:
|
|
40
|
+
puts "Uploading file: #{audio_file_path}..."
|
|
41
|
+
audio_file = client.files.upload(file: audio_file_path, config: { mime_type: 'audio/m4a' })
|
|
42
|
+
puts "File uploaded successfully. URI: #{audio_file.uri}"
|
|
43
|
+
|
|
44
|
+
# Ask the model to summarize the audio file.
|
|
45
|
+
puts "Generating summary..."
|
|
46
|
+
prompt = "Please provide a concise summary of this audio file."
|
|
47
|
+
|
|
48
|
+
response = client.models.generate_content(
|
|
49
|
+
model: 'gemini-2.5-flash',
|
|
50
|
+
contents: [prompt, audio_file]
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Print the summary
|
|
54
|
+
puts "\n--- Summary ---"
|
|
55
|
+
puts response.text
|
|
56
|
+
puts "---------------"
|
|
57
|
+
|
|
58
|
+
rescue Google::Genai::APIError => e
|
|
59
|
+
puts "An API error occurred: #{e.message}"
|
|
60
|
+
end
|
|
61
|
+
```
|
|
26
62
|
|
|
27
63
|
## Development
|
|
28
64
|
|
data/lib/google/genai/client.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Google
|
|
|
6
6
|
module Genai
|
|
7
7
|
class Client
|
|
8
8
|
def initialize(api_key: nil, vertexai: nil, credentials: nil, project: nil, location: nil, http_options: nil)
|
|
9
|
+
api_key ||= ENV['GOOGLE_API_KEY'] || ENV['GEMINI_API_KEY']
|
|
9
10
|
@api_client = ApiClient.new(
|
|
10
11
|
api_key: api_key,
|
|
11
12
|
vertexai: vertexai,
|
data/lib/google/genai/version.rb
CHANGED