friday_gemini_ai 0.1.1 → 0.1.2
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 +58 -169
- metadata +13 -32
- data/gemini_ai.gemspec +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8659819b98d6beacde9d622a89c9e7f8b3bfba2d1a576a71a9b54cf380fc72b
|
|
4
|
+
data.tar.gz: 0464c9ab77ae9c8223561170a4e2767e337db955200f63b84efda0b2b5cc3a9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f0a92d36de757110b9cf38a9667d73c122d0c0eb1e4eae2911258b491626f8c062ae2e8327867bc99fb12f4099c1701a4f465a4717a0bf41bafe0c966c745fa
|
|
7
|
+
data.tar.gz: bd9bfaa6fe4bdeb27dcc1358c3de83bdefcbd534ed35a856799bd2a5e9bc5ed4b0baafb4791ed0586bcea594134e514325a87ad6b378772d9b7c63304c5db606
|
data/README.md
CHANGED
|
@@ -1,215 +1,104 @@
|
|
|
1
1
|
# Friday Gemini AI Ruby Gem
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
22
|
+
### Using Bundler
|
|
23
|
+
Add to your Gemfile:
|
|
96
24
|
```ruby
|
|
97
|
-
gem 'friday_gemini_ai'
|
|
25
|
+
gem 'friday_gemini_ai'
|
|
98
26
|
```
|
|
99
27
|
|
|
100
|
-
##
|
|
101
|
-
|
|
102
|
-
1. Get your API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
|
|
28
|
+
## Configuration
|
|
103
29
|
|
|
104
|
-
|
|
30
|
+
Set your API key:
|
|
105
31
|
```bash
|
|
106
32
|
export GEMINI_API_KEY='your_api_key_here'
|
|
107
33
|
```
|
|
108
34
|
|
|
109
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
export GEMINI_API_KEY='your_api_key_here'
|
|
54
|
+
response = client.chat(messages)
|
|
55
|
+
puts response
|
|
149
56
|
```
|
|
150
57
|
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
69
|
+
### Configuration
|
|
164
70
|
```ruby
|
|
165
|
-
|
|
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
|
-
#
|
|
171
|
-
|
|
172
|
-
puts response
|
|
74
|
+
# Log to file
|
|
75
|
+
GeminiAI::Client.logger = Logger.new('logfile.log')
|
|
173
76
|
```
|
|
174
77
|
|
|
175
|
-
###
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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.
|
|
4
|
+
version: 0.1.2
|
|
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-
|
|
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:
|
|
28
|
+
name: minitest
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
34
|
-
type: :
|
|
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:
|
|
40
|
+
version: '5.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
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:
|
|
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
|
-
|
|
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:
|
|
91
|
+
version: '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
|
|
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
|