friday_gemini_ai 0.1.1 → 0.1.3

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +58 -169
  3. metadata +13 -32
  4. data/gemini_ai.gemspec +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52341ffcd17c5b6273266d99825214442f6d59eb497a7eb3a47999d18a18e89f
4
- data.tar.gz: 79731db3a54d4840d0222fa6dada373ef9e7da855a28fb8dbe8338f009567b41
3
+ metadata.gz: 66b53a7e6a9cdf4e1321c477ab5b151159f7b176907b620264bfcb81b4dc0955
4
+ data.tar.gz: 42dea151c596e24f2c96f40710bc4a61bc1448516182791af4bd6ce855a2f4b2
5
5
  SHA512:
6
- metadata.gz: fd1316c73e47d2bf52ba576faf3802d2f836b0d8c0d3c09a75f1f01122349afeb396aeca23703fa75718051a69fe6ef6fc539f9fbe42e43e6ffbad8ee28cdf58
7
- data.tar.gz: f1f921e622d15a751f9af0d1dbfe5d657af88eb9e8e7986527995b43866b3b2e5f31e846c62589858b183c9c07d50e159ebc2aac7dc6013ce82ddad92b47e5d0
6
+ metadata.gz: dad93b02ef3f339ded728ce61d2ffd98af06f332347e5d57c707c94052f8799cb1776fd8ba4119ee1e52f46adca495303024c17b0ac134eedfd9a00373425415
7
+ data.tar.gz: dc31beb2d7af9c8aae31d81df9416ed67b1c7b243c8f258fedd36f523a6860160432e4ba6424f50098889eb29da4d4bf72891437d4de12c868fcf4969155c479
data/README.md CHANGED
@@ -1,215 +1,104 @@
1
1
  # Friday Gemini AI Ruby Gem
2
2
 
3
- ## Overview
4
- A powerful Ruby gem for interacting with Google's Gemini AI models, providing easy text generation capabilities.
5
-
6
- ## Features
7
- - Support for multiple Gemini AI models
8
- - Flexible text generation
9
- - Comprehensive error handling
10
- - Configurable generation parameters
11
- - Advanced security and logging
12
-
13
- ## Security
14
-
15
- ### 🔒 API Key Protection
16
-
17
- #### Key Management
18
- 1. **Never Hardcode API Keys**
19
- - Do NOT include your API key directly in your code
20
- - Use environment variables or secure key management systems
21
-
22
- 2. **Environment Variable Setup**
23
- ```bash
24
- # Set in your shell profile (.bashrc, .zshrc, etc.)
25
- export GEMINI_API_KEY='your_actual_api_key'
26
- ```
27
-
28
- 3. **Secure Key Passing**
29
- ```ruby
30
- # Recommended: Use environment variable
31
- client = GeminiAI::Client.new
32
-
33
- # Alternative: Pass key securely
34
- client = GeminiAI::Client.new(ENV['GEMINI_API_KEY'])
35
- ```
36
-
37
- #### Advanced Security Features
38
- - API key format validation
39
- - Automatic key masking in logs
40
- - Strict input validation
41
- - Request timeout protection
42
-
43
- ### 🕵️ Logging and Monitoring
44
-
45
- #### Logging Configuration
46
- ```ruby
47
- # Configure logging level
48
- GeminiAI::Client.logger.level = Logger::WARN # Default
49
- GeminiAI::Client.logger.level = Logger::DEBUG # More verbose
50
- ```
51
-
52
- #### Log Masking
53
- - API keys are automatically masked in logs
54
- - Sensitive information is redacted
55
- - Prevents accidental key exposure
56
-
57
- ### 🛡️ Best Practices
58
- - Restrict API key permissions
59
- - Use the principle of least privilege
60
- - Keep your API key confidential
61
- - Monitor API usage and set up alerts
62
- - Implement rate limiting
63
- - Regularly rotate API keys
3
+ ## Table of Contents
4
+ 1. [Installation](#installation)
5
+ 2. [Configuration](#configuration)
6
+ 3. [Usage](#usage)
7
+ - [Text Generation](#text-generation)
8
+ - [Chat](#chat)
9
+ - [Error Handling](#error-handling)
10
+ 4. [Logging](#logging)
11
+ 5. [Security](#security)
12
+ 6. [Testing](#testing)
13
+ 7. [Contributing](#contributing)
64
14
 
65
15
  ## Installation
66
16
 
67
- ### Local Installation
68
- 1. Clone the repository
69
- ```bash
70
- git clone https://github.com/bniladridas/gemini_ai.git
71
- cd gemini_ai
72
- ```
73
-
74
- 2. Build the gem
75
- ```bash
76
- gem build gemini_ai.gemspec
77
- ```
78
-
79
- 3. Install the gem locally
80
- ```bash
81
- gem install gemini_ai-0.1.0.gem
82
- ```
83
-
84
- ### Using Bundler
85
- Add to your Gemfile:
86
- ```ruby
87
- gem 'gemini_ai', path: '/path/to/gemini_ai'
88
- ```
89
-
90
17
  ### From RubyGems
91
18
  ```bash
92
19
  gem install friday_gemini_ai
93
20
  ```
94
21
 
95
- Or add to your Gemfile:
22
+ ### Using Bundler
23
+ Add to your Gemfile:
96
24
  ```ruby
97
- gem 'friday_gemini_ai', '~> 0.1.0'
25
+ gem 'friday_gemini_ai'
98
26
  ```
99
27
 
100
- ## Quick Start
101
-
102
- 1. Get your API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
28
+ ## Configuration
103
29
 
104
- 2. Set your API key:
30
+ Set your API key:
105
31
  ```bash
106
32
  export GEMINI_API_KEY='your_api_key_here'
107
33
  ```
108
34
 
109
- 3. Start using the gem:
35
+ ## Usage
36
+
37
+ ### Text Generation
110
38
  ```ruby
111
39
  require 'gemini_ai'
112
40
 
113
- # Initialize client
114
41
  client = GeminiAI::Client.new
115
-
116
- # Generate text
117
42
  response = client.generate_text('Tell me a joke')
118
43
  puts response
119
-
120
- # Use different model
121
- client_lite = GeminiAI::Client.new(model: :flash_lite)
122
- response = client_lite.generate_text('What is AI?')
123
- puts response
124
-
125
- # Use custom parameters
126
- response = client.generate_text('Write a haiku',
127
- temperature: 0.3,
128
- max_tokens: 30,
129
- top_p: 0.8,
130
- top_k: 20
131
- )
132
- puts response
133
44
  ```
134
45
 
135
- ## Configuration
136
-
137
- ## Testing and Verification
138
-
139
- ### Running the Test Suite
140
- To run the comprehensive test suite:
141
- ```bash
142
- ruby comprehensive_test.rb
143
- ```
46
+ ### Chat
47
+ ```ruby
48
+ messages = [
49
+ { role: 'user', content: 'Hello' },
50
+ { role: 'model', content: 'Hi there!' },
51
+ { role: 'user', content: 'How are you?' }
52
+ ]
144
53
 
145
- ### Quick Verification
146
- First, ensure your API key is set:
147
- ```bash
148
- export GEMINI_API_KEY='your_api_key_here'
54
+ response = client.chat(messages)
55
+ puts response
149
56
  ```
150
57
 
151
- Then run the verification script:
152
- ```bash
153
- ruby verify_api.rb
58
+ ### Error Handling
59
+ ```ruby
60
+ begin
61
+ client.generate_text('')
62
+ rescue GeminiAI::Error => e
63
+ puts "Error: #{e.message}"
64
+ end
154
65
  ```
155
66
 
156
- This will run a series of quick tests:
157
- - Basic text generation with the default model
158
- - Text generation with the flash_lite model
159
- - Text generation with custom parameters
160
-
161
- ## Usage
67
+ ## Logging
162
68
 
163
- ### Basic Text Generation
69
+ ### Configuration
164
70
  ```ruby
165
- require 'gemini_ai'
166
-
167
- # Initialize client with default model
168
- client = GeminiAI::Client.new(ENV['GEMINI_API_KEY'])
71
+ # Set logging level
72
+ GeminiAI::Client.logger.level = Logger::INFO
169
73
 
170
- # Generate text
171
- response = client.generate_text('Tell me a joke about programming')
172
- puts response
74
+ # Log to file
75
+ GeminiAI::Client.logger = Logger.new('logfile.log')
173
76
  ```
174
77
 
175
- ### Specifying a Model
176
- ```ruby
177
- # Use Flash Lite model
178
- client_lite = GeminiAI::Client.new(ENV['GEMINI_API_KEY'], model: :flash_lite)
179
- response = client_lite.generate_text('Explain AI in simple terms')
180
- ```
78
+ ### Log Levels
79
+ - DEBUG: Detailed debug information
80
+ - INFO: General operational messages
81
+ - WARN: Warning conditions
82
+ - ERROR: Error conditions
181
83
 
182
- ### Custom Generation Options
183
- ```ruby
184
- options = {
185
- temperature: 0.7,
186
- max_tokens: 100,
187
- top_p: 0.9,
188
- top_k: 40
189
- }
190
-
191
- response = client.generate_text('Write a short story', options)
192
- ```
84
+ ## Security
193
85
 
194
- ## Error Handling
195
- The gem provides robust error handling:
196
- ```ruby
197
- begin
198
- client.generate_text('') # Raises an error
199
- rescue GeminiAI::Error => e
200
- puts "An error occurred: #{e.message}"
201
- end
86
+ ### API Key Protection
87
+ - Never hardcode API keys
88
+ - Use environment variables
89
+ - Automatic key masking in logs
90
+
91
+ ## Testing
92
+
93
+ Run the test suite:
94
+ ```bash
95
+ bundle exec ruby test/gemini_ai_test.rb
202
96
  ```
203
97
 
204
98
  ## Contributing
99
+
205
100
  1. Fork the repository
206
101
  2. Create your feature branch
207
102
  3. Commit your changes
208
103
  4. Push to the branch
209
104
  5. Create a new Pull Request
210
-
211
- ## License
212
- MIT License
213
-
214
- ## Support
215
- For issues, please file a GitHub issue in the repository.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friday_gemini_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bniladridas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-01 00:00:00.000000000 Z
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.21.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.6.3
34
- type: :runtime
33
+ version: '5.0'
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.6.3
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.25.4
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.25.4
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dotenv
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,22 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.8'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '13.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '13.0'
83
- description: A flexible Ruby gem for generating text using Google Gemini AI models
84
- with comprehensive error handling and multiple model support.
69
+ description: Provides easy text generation capabilities using Google's Gemini AI models
85
70
  email:
86
71
  - bniladridas@gmail.com
87
72
  executables: []
@@ -90,15 +75,11 @@ extra_rdoc_files: []
90
75
  files:
91
76
  - LICENSE
92
77
  - README.md
93
- - gemini_ai.gemspec
94
78
  - lib/gemini_ai.rb
95
79
  homepage: https://github.com/bniladridas/friday_gemini_ai
96
80
  licenses:
97
81
  - MIT
98
- metadata:
99
- source_code_uri: https://github.com/bniladridas/friday_gemini_ai
100
- documentation_uri: https://github.com/bniladridas/friday_gemini_ai/blob/main/README.md
101
- bug_tracker_uri: https://github.com/bniladridas/friday_gemini_ai/issues
82
+ metadata: {}
102
83
  post_install_message:
103
84
  rdoc_options: []
104
85
  require_paths:
@@ -107,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
88
  requirements:
108
89
  - - ">="
109
90
  - !ruby/object:Gem::Version
110
- version: 3.0.0
91
+ version: 3.1.0
111
92
  required_rubygems_version: !ruby/object:Gem::Requirement
112
93
  requirements:
113
94
  - - ">="
@@ -117,5 +98,5 @@ requirements: []
117
98
  rubygems_version: 3.4.10
118
99
  signing_key:
119
100
  specification_version: 4
120
- summary: Ruby interface for Google Gemini AI models
101
+ summary: A Ruby gem for interacting with Google's Gemini AI models
121
102
  test_files: []
data/gemini_ai.gemspec DELETED
@@ -1,37 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'friday_gemini_ai'
3
- spec.version = '0.1.1'
4
- spec.date = '2025-03-01'
5
- spec.summary = 'Ruby interface for Google Gemini AI models'
6
- spec.description = 'A flexible Ruby gem for generating text using Google Gemini AI models with comprehensive error handling and multiple model support.'
7
- spec.authors = ['bniladridas']
8
- spec.email = ['bniladridas@gmail.com']
9
- spec.homepage = 'https://github.com/bniladridas/friday_gemini_ai'
10
- spec.license = 'MIT'
11
-
12
- spec.files = [
13
- 'lib/gemini_ai.rb',
14
- 'README.md',
15
- 'LICENSE',
16
- 'gemini_ai.gemspec'
17
- ]
18
-
19
- spec.require_paths = ['lib']
20
-
21
- spec.required_ruby_version = '>= 3.0.0'
22
-
23
- # Runtime dependencies
24
- spec.add_runtime_dependency 'httparty', '~> 0.21.0'
25
- spec.add_runtime_dependency 'json', '~> 2.6.3'
26
-
27
- # Development dependencies
28
- spec.add_development_dependency 'minitest', '~> 5.25.4'
29
- spec.add_development_dependency 'dotenv', '~> 2.8'
30
- spec.add_development_dependency 'rake', '~> 13.0'
31
-
32
- spec.metadata = {
33
- 'source_code_uri' => 'https://github.com/bniladridas/friday_gemini_ai',
34
- 'documentation_uri' => 'https://github.com/bniladridas/friday_gemini_ai/blob/main/README.md',
35
- 'bug_tracker_uri' => 'https://github.com/bniladridas/friday_gemini_ai/issues'
36
- }
37
- end