gemini_craft 0.1.3 โ 0.2.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 +4 -4
- data/CHANGELOG.md +292 -4
- data/README.md +652 -38
- data/lib/gemini_craft/cache.rb +102 -18
- data/lib/gemini_craft/client.rb +280 -75
- data/lib/gemini_craft/configuration.rb +24 -1
- data/lib/gemini_craft/error.rb +27 -0
- data/lib/gemini_craft/version.rb +1 -1
- data/lib/gemini_craft.rb +36 -3
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8ec75d69654fc8719a1e983c791f104014072aaa4ea676e61a2862a7c6349f
|
4
|
+
data.tar.gz: f86507b4cc4eaa1f7cc1b6dac98be7192e01ca89a8c644364c256435e17e42fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 930f1b00b88ea179e9b97626917bbd20e001d8a62677c9ff9d1936f0918c670318028231152da5e9bc484c1fe660e92eb512be5a87b96ed8a1c6977285bc61df
|
7
|
+
data.tar.gz: bc1790b7775c45771524f4c74e0073f3bf0644c1b1bf23f1dddecc907bd472fcb6e6a8859cdb050945b97da34c1db5496bacc81d6d6b309ac1f1840a77786b4b
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,295 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.2.0] - 2025-05-26
|
4
4
|
|
5
|
-
|
5
|
+
### ๐ Added
|
6
|
+
- **Streaming Support**: Real-time content generation with `stream_content` method
|
7
|
+
- Added `stream: true` option to `generate_content` method
|
8
|
+
- Streaming responses return `Enumerator` for chunk-by-chunk processing
|
9
|
+
- Perfect for chatbots and live content generation
|
10
|
+
- **Function Calling**: Full support for Gemini's function calling capabilities
|
11
|
+
- New `generate_with_functions` method for AI-driven function execution
|
12
|
+
- Structured function parameter validation
|
13
|
+
- Support for multiple function calls in single request
|
14
|
+
- **Enhanced Error Handling**: Comprehensive error type system
|
15
|
+
- `AuthenticationError` for invalid API keys
|
16
|
+
- `AuthorizationError` for permission issues
|
17
|
+
- `RateLimitError` for quota exceeded scenarios
|
18
|
+
- `TimeoutError` for request timeouts
|
19
|
+
- `ConnectionError` for network failures
|
20
|
+
- `StreamingError` for streaming-specific issues
|
21
|
+
- `NotFoundError` for missing models/endpoints
|
22
|
+
- `ClientError` and `ServerError` for 4xx/5xx responses
|
23
|
+
- **Logging Support**: Integrated logging system
|
24
|
+
- Configurable log levels (`:debug`, `:info`, `:warn`, `:error`, `:fatal`)
|
25
|
+
- Automatic Rails logger integration
|
26
|
+
- Request/response logging with metadata
|
27
|
+
- Performance metrics logging
|
28
|
+
- **Connection Pooling**: HTTP connection optimization
|
29
|
+
- Configurable connection pool size
|
30
|
+
- Keep-alive timeout configuration
|
31
|
+
- Better resource management for high-throughput apps
|
32
|
+
- **Enhanced Caching System**: Intelligent cache management
|
33
|
+
- Thread-safe cache operations
|
34
|
+
- Automatic cleanup of expired entries
|
35
|
+
- LRU (Least Recently Used) eviction policy
|
36
|
+
- Cache statistics with `cache_stats` method
|
37
|
+
- Manual cache clearing with `clear_cache` method
|
38
|
+
- Background cleanup thread for maintenance
|
6
39
|
|
7
|
-
|
40
|
+
### ๐ง Changed
|
41
|
+
- **Configuration System**: Extended configuration options
|
42
|
+
- Added `logger` and `log_level` for logging control
|
43
|
+
- Added `streaming_enabled` for streaming feature toggle
|
44
|
+
- Added `connection_pool_size` and `keep_alive_timeout` for performance
|
45
|
+
- Enhanced validation with detailed error messages
|
46
|
+
- **Client Architecture**: Improved client implementation
|
47
|
+
- Better connection management with pooling
|
48
|
+
- Enhanced retry logic with specific retry conditions
|
49
|
+
- Improved error handling with contextual information
|
50
|
+
- Thread-safe operations throughout
|
51
|
+
- **Cache Implementation**: Complete cache system overhaul
|
52
|
+
- Moved from simple hash to sophisticated cache with cleanup
|
53
|
+
- Added timestamp and access time tracking
|
54
|
+
- Implemented automatic maintenance routines
|
55
|
+
- Added statistics and monitoring capabilities
|
56
|
+
- **API Integration**: Enhanced Gemini API interaction
|
57
|
+
- Better request/response handling
|
58
|
+
- Improved streaming protocol implementation
|
59
|
+
- Enhanced function calling protocol support
|
60
|
+
- More robust error parsing and handling
|
61
|
+
|
62
|
+
### ๐ Improved
|
63
|
+
- **Performance**: Significant performance improvements
|
64
|
+
- Connection pooling reduces latency for multiple requests
|
65
|
+
- Intelligent caching reduces redundant API calls
|
66
|
+
- Optimized retry logic prevents unnecessary delays
|
67
|
+
- Background cache cleanup prevents memory bloat
|
68
|
+
- **Reliability**: Enhanced reliability and stability
|
69
|
+
- Better error recovery mechanisms
|
70
|
+
- Improved timeout handling
|
71
|
+
- More robust streaming implementation
|
72
|
+
- Thread-safe operations prevent race conditions
|
73
|
+
- **Developer Experience**: Better development experience
|
74
|
+
- Comprehensive logging for debugging
|
75
|
+
- Detailed error messages with context
|
76
|
+
- Cache statistics for monitoring
|
77
|
+
- Rails integration helpers
|
78
|
+
- **Documentation**: Enhanced documentation and examples
|
79
|
+
- Updated README with comprehensive usage examples
|
80
|
+
- Added function calling examples
|
81
|
+
- Added streaming implementation guides
|
82
|
+
- Added Rails integration patterns
|
83
|
+
|
84
|
+
### ๐ Migration Notes
|
85
|
+
- All existing v0.1.x code continues to work without changes
|
86
|
+
- New features are opt-in and don't affect existing functionality
|
87
|
+
- Configuration remains backward compatible
|
88
|
+
- Error handling is enhanced but doesn't break existing rescue blocks
|
89
|
+
|
90
|
+
## [0.1.3] - 2025-03-25
|
91
|
+
|
92
|
+
### ๐ Fixed
|
93
|
+
- Fixed issue with response parsing when API returns empty candidates array
|
94
|
+
- Improved error messages for network connectivity issues
|
95
|
+
- Fixed cache key generation for requests with special characters
|
96
|
+
- Resolved thread safety issue in configuration management
|
97
|
+
|
98
|
+
### ๐ง Changed
|
99
|
+
- Updated Faraday dependency to allow versions 2.7.x
|
100
|
+
- Improved retry logic to handle more transient error types
|
101
|
+
- Enhanced timeout handling for slow network connections
|
102
|
+
- Better handling of malformed JSON responses
|
103
|
+
|
104
|
+
### ๐ Documentation
|
105
|
+
- Added more comprehensive error handling examples
|
106
|
+
- Updated API documentation with clearer parameter descriptions
|
107
|
+
- Added troubleshooting section for common issues
|
108
|
+
- Improved code examples formatting
|
109
|
+
|
110
|
+
## [0.1.2] - 2025-03-20
|
111
|
+
|
112
|
+
### ๐ Fixed
|
113
|
+
- Fixed gemspec file inclusion pattern
|
114
|
+
- Resolved issue with missing require statements in some environments
|
115
|
+
- Fixed default configuration values not being properly applied
|
116
|
+
- Corrected cache TTL calculation bug
|
117
|
+
|
118
|
+
### ๐ง Changed
|
119
|
+
- Improved error messages for configuration validation
|
120
|
+
- Enhanced request timeout handling
|
121
|
+
- Better handling of API response edge cases
|
122
|
+
- Optimized cache key generation algorithm
|
123
|
+
|
124
|
+
### ๐ฆ Dependencies
|
125
|
+
- Updated faraday-retry to version 2.2.x
|
126
|
+
- Added development dependency version constraints
|
127
|
+
- Improved bundler compatibility
|
128
|
+
|
129
|
+
## [0.1.1] - 2025-03-18
|
130
|
+
|
131
|
+
### ๐ Fixed
|
132
|
+
- Fixed require path issues in Ruby 3.1+
|
133
|
+
- Resolved compatibility issue with older Faraday versions
|
134
|
+
- Fixed cache invalidation timing bug
|
135
|
+
- Corrected API endpoint URL construction
|
136
|
+
|
137
|
+
### ๐ง Changed
|
138
|
+
- Improved gem loading performance
|
139
|
+
- Enhanced configuration validation messages
|
140
|
+
- Better default values for timeout settings
|
141
|
+
- Optimized memory usage for large responses
|
142
|
+
|
143
|
+
### ๐ Documentation
|
144
|
+
- Fixed typos in README examples
|
145
|
+
- Added missing code blocks in documentation
|
146
|
+
- Improved installation instructions
|
147
|
+
- Added FAQ section
|
148
|
+
|
149
|
+
## [0.1.0] - 2025-03-15
|
150
|
+
|
151
|
+
### ๐ Initial Release
|
152
|
+
|
153
|
+
### โจ Features
|
154
|
+
- **Core Content Generation**: Basic text generation using Gemini API
|
155
|
+
- Support for simple text prompts
|
156
|
+
- System instruction support for context setting
|
157
|
+
- Customizable generation parameters (temperature, topK, topP, maxTokens)
|
158
|
+
- **Configuration Management**: Flexible configuration system
|
159
|
+
- Environment variable support for API key (`GEMINI_API_KEY`)
|
160
|
+
- Configurable API endpoints and model selection
|
161
|
+
- Timeout and retry configuration
|
162
|
+
- **Caching System**: Simple in-memory caching
|
163
|
+
- Configurable cache TTL (time-to-live)
|
164
|
+
- Automatic cache key generation
|
165
|
+
- Optional caching with easy enable/disable
|
166
|
+
- **Error Handling**: Basic error handling
|
167
|
+
- API error detection and reporting
|
168
|
+
- Network timeout handling
|
169
|
+
- Configuration validation
|
170
|
+
- **HTTP Client**: Robust HTTP client implementation
|
171
|
+
- Built on Faraday with retry middleware
|
172
|
+
- Configurable timeouts and retry policies
|
173
|
+
- JSON request/response handling
|
174
|
+
- **Gem Infrastructure**: Professional gem setup
|
175
|
+
- RSpec test suite with comprehensive coverage
|
176
|
+
- RuboCop code style enforcement
|
177
|
+
- GitHub Actions CI/CD pipeline
|
178
|
+
- Semantic versioning
|
179
|
+
- MIT license
|
180
|
+
- Code of conduct and contributing guidelines
|
181
|
+
|
182
|
+
### ๐ง Configuration Options
|
183
|
+
- `api_key`: Gemini API key (required)
|
184
|
+
- `model`: Gemini model selection (default: "gemini-2.0-flash")
|
185
|
+
- `api_base_url`: API endpoint URL
|
186
|
+
- `timeout`: Request timeout in seconds (default: 30)
|
187
|
+
- `cache_enabled`: Enable/disable response caching (default: false)
|
188
|
+
- `cache_ttl`: Cache time-to-live in seconds (default: 3600)
|
189
|
+
- `max_retries`: Maximum retry attempts (default: 3)
|
190
|
+
|
191
|
+
### ๐ฆ Dependencies
|
192
|
+
- `faraday ~> 2.7`: HTTP client library
|
193
|
+
- `faraday-retry ~> 2.2`: Retry middleware for Faraday
|
194
|
+
|
195
|
+
### ๐งช Development Dependencies
|
196
|
+
- `rspec ~> 3.12`: Testing framework
|
197
|
+
- `rubocop ~> 1.50`: Code style enforcement
|
198
|
+
- `webmock ~> 3.18`: HTTP request mocking for tests
|
199
|
+
- `simplecov ~> 0.22`: Code coverage reporting
|
200
|
+
- `yard ~> 0.9`: Documentation generation
|
201
|
+
- `dotenv ~> 2.8`: Environment variable management
|
202
|
+
|
203
|
+
### ๐ Documentation
|
204
|
+
- Comprehensive README with usage examples
|
205
|
+
- API documentation with YARD
|
206
|
+
- Contributing guidelines
|
207
|
+
- Code of conduct
|
208
|
+
- MIT license
|
209
|
+
|
210
|
+
### ๐๏ธ Project Structure
|
211
|
+
```
|
212
|
+
gemini_craft/
|
213
|
+
โโโ lib/
|
214
|
+
โ โโโ gemini_craft.rb # Main module
|
215
|
+
โ โโโ gemini_craft/
|
216
|
+
โ โโโ version.rb # Version management
|
217
|
+
โ โโโ configuration.rb # Configuration class
|
218
|
+
โ โโโ client.rb # API client
|
219
|
+
โ โโโ cache.rb # Caching system
|
220
|
+
โ โโโ error.rb # Error classes
|
221
|
+
โโโ spec/ # Test suite
|
222
|
+
โโโ examples/ # Usage examples
|
223
|
+
โโโ README.md # Documentation
|
224
|
+
โโโ CHANGELOG.md # This file
|
225
|
+
โโโ LICENSE.txt # MIT license
|
226
|
+
โโโ gemini_craft.gemspec # Gem specification
|
227
|
+
```
|
228
|
+
|
229
|
+
---
|
230
|
+
|
231
|
+
## Version History Summary
|
232
|
+
|
233
|
+
| Version | Release Date | Key Features |
|
234
|
+
|---------|-------------|--------------|
|
235
|
+
| **0.2.0** | 2025-05-26 | ๐ Streaming, ๐ง Functions, ๐ Enhanced Errors, ๐ Logging |
|
236
|
+
| **0.1.3** | 2025-03-25 | ๐ Bug fixes, ๐ง Improvements |
|
237
|
+
| **0.1.2** | 2025-03-20 | ๐ Stability fixes, ๐ฆ Dependencies |
|
238
|
+
| **0.1.1** | 2025-03-18 | ๐ Compatibility fixes |
|
239
|
+
| **0.1.0** | 2025-03-15 | ๐ Initial release |
|
240
|
+
|
241
|
+
## Upgrade Guide
|
242
|
+
|
243
|
+
### From 0.1.x to 0.2.0
|
244
|
+
|
245
|
+
**Backward Compatibility**: All existing code continues to work without changes.
|
246
|
+
|
247
|
+
**New Features Available**:
|
248
|
+
```ruby
|
249
|
+
# Streaming (new in 0.2.0)
|
250
|
+
GeminiCraft.stream_content("Tell me a story").each { |chunk| print chunk }
|
251
|
+
|
252
|
+
# Function calling (new in 0.2.0)
|
253
|
+
result = GeminiCraft.generate_with_functions(prompt, functions)
|
254
|
+
|
255
|
+
# Enhanced error handling (new in 0.2.0)
|
256
|
+
rescue GeminiCraft::RateLimitError => e
|
257
|
+
# Handle rate limiting specifically
|
258
|
+
end
|
259
|
+
|
260
|
+
# Enhanced configuration (new in 0.2.0)
|
261
|
+
GeminiCraft.configure do |config|
|
262
|
+
config.logger = Rails.logger
|
263
|
+
config.streaming_enabled = true
|
264
|
+
config.connection_pool_size = 10
|
265
|
+
end
|
266
|
+
```
|
267
|
+
|
268
|
+
**Optional Migrations**:
|
269
|
+
1. **Enable Enhanced Caching**: Update configuration to use new cache features
|
270
|
+
2. **Add Logging**: Configure logger for better debugging
|
271
|
+
3. **Enable Streaming**: Set `streaming_enabled = true` for streaming features
|
272
|
+
4. **Optimize Performance**: Configure connection pooling for high-traffic apps
|
273
|
+
|
274
|
+
## Contributing
|
275
|
+
|
276
|
+
### Changelog Guidelines
|
277
|
+
|
278
|
+
When contributing, please update this changelog:
|
279
|
+
|
280
|
+
1. **Add entries under [Unreleased]** section
|
281
|
+
2. **Use semantic versioning** for releases
|
282
|
+
3. **Follow format**: `### Category` followed by bullet points
|
283
|
+
4. **Categories**: Added, Changed, Deprecated, Removed, Fixed, Security
|
284
|
+
5. **Be descriptive**: Include context and impact of changes
|
285
|
+
6. **Link issues/PRs**: Reference relevant GitHub issues
|
286
|
+
|
287
|
+
### Release Process
|
288
|
+
|
289
|
+
1. Move unreleased changes to new version section
|
290
|
+
2. Update version in `lib/gemini_craft/version.rb`
|
291
|
+
3. Commit changes with format: "Bump version to X.Y.Z"
|
292
|
+
4. Create git tag: `git tag vX.Y.Z`
|
293
|
+
5. Push tag: `git push origin vX.Y.Z`
|
294
|
+
6. Build and release gem: `gem build && gem push gemini_craft-X.Y.Z.gem`
|
295
|
+
7. Create GitHub release with changelog content
|