geminize 1.1.0 → 1.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/.memory_bank/activeContext.md +25 -1
- data/.memory_bank/progress.md +26 -13
- data/.memory_bank/projectbrief.md +16 -0
- data/.memory_bank/tasks.md +57 -13
- data/CHANGELOG.md +22 -0
- data/README.md +181 -0
- data/examples/function_calling.rb +218 -0
- data/examples/safety_settings.rb +82 -0
- data/lib/geminize/models/content_request_extensions.rb +219 -0
- data/lib/geminize/models/content_request_safety.rb +123 -0
- data/lib/geminize/models/content_response_extensions.rb +120 -0
- data/lib/geminize/models/function_declaration.rb +112 -0
- data/lib/geminize/models/function_response.rb +70 -0
- data/lib/geminize/models/safety_setting.rb +102 -0
- data/lib/geminize/models/tool.rb +47 -0
- data/lib/geminize/models/tool_config.rb +52 -0
- data/lib/geminize/module_extensions.rb +228 -0
- data/lib/geminize/module_safety.rb +135 -0
- data/lib/geminize/version.rb +1 -1
- data/lib/geminize.rb +12 -0
- metadata +13 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900c19e9cf075e32779e3ee2f4f4530fdced2c027e8bc393d05250c1b20e5dac
|
4
|
+
data.tar.gz: 7d1a9a2f365eff24d2625492916d578f661fd881263c1cd4101352d7b16780ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1e3a5235a330b9bba4690a2452992f331bf4b76294109e2d4a8beb3fbc357c3f06be8b9728d607aff8653367458827bf17b166a1c89c6d243062272e747b154
|
7
|
+
data.tar.gz: a9c73fc3264fccaa26ba6b525d89807a9a99052232c12387281844d1cca821609c795fe199ed222c601962e8f144fc73854b73eccc75994fc3ab6ac70e4f7b2d
|
@@ -9,6 +9,9 @@
|
|
9
9
|
- Multimodal content handling (text + images)
|
10
10
|
- Embeddings generation
|
11
11
|
- Streaming responses
|
12
|
+
- Function calling capabilities
|
13
|
+
- JSON mode for structured responses
|
14
|
+
- Safety settings for content moderation
|
12
15
|
|
13
16
|
### Key Implementation Details
|
14
17
|
|
@@ -18,6 +21,23 @@
|
|
18
21
|
- System instructions for guiding model behavior
|
19
22
|
- Generation parameters (temperature, top_k, top_p)
|
20
23
|
- Support for stop sequences
|
24
|
+
- Safety settings for content moderation
|
25
|
+
|
26
|
+
#### Function Calling
|
27
|
+
|
28
|
+
- Tool integration with Gemini API
|
29
|
+
- Function declaration and response models
|
30
|
+
- Support for multiple function definitions
|
31
|
+
- Tool execution modes (AUTO, MANUAL, NONE)
|
32
|
+
- Function result processing
|
33
|
+
- String-based function call detection
|
34
|
+
|
35
|
+
#### JSON Mode
|
36
|
+
|
37
|
+
- Structured data response handling
|
38
|
+
- Automatic JSON parsing
|
39
|
+
- JSON schema integration
|
40
|
+
- Response validation
|
21
41
|
|
22
42
|
#### Multimodal Support
|
23
43
|
|
@@ -69,10 +89,14 @@
|
|
69
89
|
- Streaming response optimizations
|
70
90
|
- Comprehensive documentation
|
71
91
|
- Error handling refinements
|
92
|
+
- Models API integration
|
93
|
+
- Function calling support
|
72
94
|
|
73
95
|
### Upcoming Features
|
74
96
|
|
75
|
-
-
|
97
|
+
- Code execution support
|
98
|
+
- Additional content types (audio, PDF)
|
99
|
+
- Caching support
|
76
100
|
- Advanced parameter tuning
|
77
101
|
- Additional vector operations
|
78
102
|
- Improved conversation persistence
|
data/.memory_bank/progress.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Current Status
|
4
4
|
|
5
|
-
Geminize is a functional Ruby gem providing a complete interface to the Google Gemini API. The current implementation includes all core features with a focus on stability, documentation, and ease of use.
|
5
|
+
Geminize is a functional Ruby gem providing a complete interface to the Google Gemini API. The current implementation includes all core features with a focus on stability, documentation, and ease of use. The gem now also includes function calling, JSON mode, and safety settings features.
|
6
6
|
|
7
7
|
## Development Progress
|
8
8
|
|
@@ -15,6 +15,10 @@ Geminize is a functional Ruby gem providing a complete interface to the Google G
|
|
15
15
|
- **Streaming Responses**: ✅ Complete
|
16
16
|
- **Error Handling**: ✅ Complete
|
17
17
|
- **Configuration System**: ✅ Complete
|
18
|
+
- **Models API**: ✅ Complete
|
19
|
+
- **Function Calling**: ✅ Complete
|
20
|
+
- **JSON Mode**: ✅ Complete
|
21
|
+
- **Safety Settings**: ✅ Complete
|
18
22
|
|
19
23
|
### Documentation
|
20
24
|
|
@@ -26,7 +30,7 @@ Geminize is a functional Ruby gem providing a complete interface to the Google G
|
|
26
30
|
### Testing
|
27
31
|
|
28
32
|
- **Unit Tests**: ✅ Complete
|
29
|
-
- **Integration Tests**: 🟡 Partially Complete (
|
33
|
+
- **Integration Tests**: 🟡 Partially Complete (85%)
|
30
34
|
- **Performance Tests**: ❌ Not Started
|
31
35
|
|
32
36
|
### Deployment
|
@@ -50,27 +54,35 @@ Geminize is a functional Ruby gem providing a complete interface to the Google G
|
|
50
54
|
- Additional embedding task types
|
51
55
|
- Improved documentation
|
52
56
|
|
53
|
-
### v1.0.0 (
|
57
|
+
### v1.0.0 (2025-05-02)
|
54
58
|
|
55
59
|
- Removed Rails-specific integration
|
56
60
|
- Simplified usage
|
57
61
|
- API stabilization
|
58
62
|
|
59
|
-
|
63
|
+
### v1.1.0 (2025-05-02)
|
64
|
+
|
65
|
+
- Support for Gemini Models API
|
66
|
+
- Model discovery and filtering functionality
|
67
|
+
- Pagination support
|
68
|
+
- Improved documentation
|
60
69
|
|
61
|
-
### v1.
|
70
|
+
### v1.2.0 (2025-05-02)
|
62
71
|
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
72
|
+
- Added function calling capabilities
|
73
|
+
- Added JSON mode for structured responses
|
74
|
+
- Added safety settings for content moderation
|
75
|
+
- Comprehensive test suite for new features
|
76
|
+
- Updated documentation
|
77
|
+
|
78
|
+
## Upcoming Milestones
|
67
79
|
|
68
|
-
### v1.
|
80
|
+
### v1.3.0 (Planned)
|
69
81
|
|
70
|
-
-
|
82
|
+
- Code execution support
|
83
|
+
- Additional content types (audio, PDF)
|
84
|
+
- Caching mechanisms
|
71
85
|
- Improved conversation persistence
|
72
|
-
- Additional configuration options
|
73
|
-
- Memory optimizations
|
74
86
|
|
75
87
|
### v2.0.0 (Planned)
|
76
88
|
|
@@ -78,3 +90,4 @@ Geminize is a functional Ruby gem providing a complete interface to the Google G
|
|
78
90
|
- Advanced function calling support
|
79
91
|
- Performance improvements
|
80
92
|
- Additional middleware options
|
93
|
+
- Async API support
|
@@ -11,6 +11,10 @@ Geminize is a Ruby gem providing a convenient and robust interface to Google's G
|
|
11
11
|
- **Conversation Management**: Maintain conversation context for chat applications
|
12
12
|
- **Embeddings Generation**: Generate and manipulate vector representations for text
|
13
13
|
- **Streaming Responses**: Support for efficient streaming output
|
14
|
+
- **Models API**: Discover and filter available Gemini models
|
15
|
+
- **Function Calling**: Enable AI models to call functions defined by developers
|
16
|
+
- **JSON Mode**: Generate structured JSON responses for data-oriented applications
|
17
|
+
- **Safety Settings**: Control content generation with configurable safety thresholds
|
14
18
|
- **Error Handling**: Comprehensive error handling and validation
|
15
19
|
|
16
20
|
## Technical Foundation
|
@@ -19,6 +23,8 @@ Geminize is a Ruby gem providing a convenient and robust interface to Google's G
|
|
19
23
|
- Faraday for HTTP client functionality
|
20
24
|
- Support for environment-based or programmatic configuration
|
21
25
|
- Comprehensive API for both simple and advanced use cases
|
26
|
+
- VCR-based testing for API interactions
|
27
|
+
- Modular design with extensible components
|
22
28
|
|
23
29
|
## Project Goals
|
24
30
|
|
@@ -27,3 +33,13 @@ Geminize is a Ruby gem providing a convenient and robust interface to Google's G
|
|
27
33
|
- Maintain clean, well-documented, and idiomatic Ruby code
|
28
34
|
- Support both simple use cases and advanced configurations
|
29
35
|
- Enable seamless integration with various Ruby applications
|
36
|
+
- Stay current with the latest Gemini API features and models
|
37
|
+
|
38
|
+
## Current Version
|
39
|
+
|
40
|
+
Version 1.2.0 implements all core features including the latest additions:
|
41
|
+
|
42
|
+
- Function calling capabilities
|
43
|
+
- JSON mode for structured responses
|
44
|
+
- Safety settings for content moderation
|
45
|
+
- Comprehensive Models API
|
data/.memory_bank/tasks.md
CHANGED
@@ -6,32 +6,53 @@
|
|
6
6
|
|
7
7
|
- [ ] Review and improve YARD documentation
|
8
8
|
- [ ] Add more code examples
|
9
|
-
- [
|
9
|
+
- [x] Update README with latest features
|
10
10
|
- [ ] Create diagrams for architecture overview
|
11
11
|
|
12
12
|
### Feature Development
|
13
13
|
|
14
14
|
- [ ] Support for new Gemini models as they become available
|
15
|
-
- [ ]
|
15
|
+
- [ ] Implement Gemini API missing features:
|
16
|
+
- [x] **Function Calling Support**
|
17
|
+
- [x] Create model classes for function calling structures
|
18
|
+
- [x] Update ContentRequest to support tools and functions
|
19
|
+
- [x] Update request builder and response handling
|
20
|
+
- [x] Add module-level convenience methods
|
21
|
+
- [x] Add comprehensive VCR tests for function calling
|
22
|
+
- [x] **JSON Mode Support**
|
23
|
+
- [x] Add MIME type support for JSON responses
|
24
|
+
- [x] Implement helper methods for JSON generation
|
25
|
+
- [x] Add validation for JSON response structures
|
26
|
+
- [x] Add tests for JSON mode functionality
|
27
|
+
- [x] **Safety Settings**
|
28
|
+
- [x] Create SafetySetting model
|
29
|
+
- [x] Add safety configuration to requests
|
30
|
+
- [x] Implement module-level safety methods
|
31
|
+
- [x] Add tests for safety settings
|
32
|
+
- [ ] **Code Execution Support**
|
33
|
+
- [ ] Create code execution model classes
|
34
|
+
- [ ] Implement code execution tools in requests
|
35
|
+
- [ ] Update response handling for code execution
|
36
|
+
- [ ] **Additional Content Types**
|
37
|
+
- [ ] Audio content support
|
38
|
+
- [ ] Document/PDF content support
|
39
|
+
- [ ] Video content support
|
40
|
+
- [ ] **Caching Support**
|
41
|
+
- [ ] Add caching to content requests
|
42
|
+
- [ ] Implement cached content handling
|
43
|
+
- [ ] Add module-level caching methods
|
44
|
+
- [x] Add support for function calling capabilities
|
16
45
|
- [ ] Implement batch embedding generation
|
17
46
|
- [ ] Improve conversation persistence with adapter pattern for multiple storage options
|
18
|
-
- [ ] **Models API Integration**:
|
19
|
-
- [x] Enhance `model_info.rb` to support full model metadata
|
20
|
-
- [x] Update/create `Models::Model` class to match API response structure
|
21
|
-
- [x] Implement `Models::ModelList` class for handling paginated results
|
22
|
-
- [x] Add methods to `RequestBuilder` for models endpoints
|
23
|
-
- [x] Add client methods for models endpoints
|
24
|
-
- [x] Add convenience methods to main Geminize module
|
25
|
-
- [x] Implement helper methods for model capability filtering
|
26
|
-
- [x] Add comprehensive tests for models functionality
|
27
|
-
- [x] Update documentation with models API examples
|
28
47
|
|
29
48
|
### Testing
|
30
49
|
|
31
50
|
- [ ] Expand test coverage
|
32
51
|
- [ ] Add integration tests for streaming
|
33
|
-
- [
|
52
|
+
- [x] Update VCR cassettes with latest API responses
|
34
53
|
- [ ] Add benchmarks for performance testing
|
54
|
+
- [x] Create test fixtures for new Gemini API features
|
55
|
+
- [x] Add VCR cassettes for function calling responses
|
35
56
|
|
36
57
|
### Improvements
|
37
58
|
|
@@ -57,18 +78,41 @@
|
|
57
78
|
- [x] Embeddings generation
|
58
79
|
- [x] Streaming response handling
|
59
80
|
- [x] Models API Integration
|
81
|
+
- [x] Enhance `model_info.rb` to support full model metadata
|
82
|
+
- [x] Update/create `Models::Model` class to match API response structure
|
83
|
+
- [x] Implement `Models::ModelList` class for handling paginated results
|
84
|
+
- [x] Add methods to `RequestBuilder` for models endpoints
|
85
|
+
- [x] Add client methods for models endpoints
|
86
|
+
- [x] Add convenience methods to main Geminize module
|
87
|
+
- [x] Implement helper methods for model capability filtering
|
88
|
+
- [x] Add comprehensive tests for models functionality
|
89
|
+
- [x] Update documentation with models API examples
|
90
|
+
- [x] Function Calling Support
|
91
|
+
- [x] Create function declaration, tool, and response models
|
92
|
+
- [x] Implement request and response extensions
|
93
|
+
- [x] Add module-level methods for function calling
|
94
|
+
- [x] Add VCR tests for real API interactions
|
95
|
+
- [x] JSON Mode Support
|
96
|
+
- [x] Add MIME type support and JSON response parsing
|
97
|
+
- [x] Add structured data generation features
|
98
|
+
- [x] Safety Settings Support
|
99
|
+
- [x] Implement safety categories and thresholds
|
100
|
+
- [x] Add safety-focused generation methods
|
60
101
|
|
61
102
|
### Documentation
|
62
103
|
|
63
104
|
- [x] Initial README with examples
|
64
105
|
- [x] YARD documentation for public methods
|
65
106
|
- [x] Example scripts
|
107
|
+
- [x] Update README with function calling, JSON mode, and safety settings
|
66
108
|
|
67
109
|
### Testing
|
68
110
|
|
69
111
|
- [x] Basic test suite with RSpec
|
70
112
|
- [x] VCR setup for API mocking
|
71
113
|
- [x] Unit tests for core functionality
|
114
|
+
- [x] Integration tests for function calling
|
115
|
+
- [x] Tests for JSON mode and safety settings
|
72
116
|
|
73
117
|
### Error Handling
|
74
118
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## [1.2.0] - 2025-05-02
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
- Function calling capabilities for working with the Gemini API's tool features
|
6
|
+
- Added `generate_with_functions` method to create content with function definitions
|
7
|
+
- Added `process_function_call` method to handle function responses
|
8
|
+
- Added support for multiple function declarations in a single request
|
9
|
+
- Added configurable tool execution modes (AUTO, MANUAL, NONE)
|
10
|
+
- Implemented comprehensive test suite for function calling features
|
11
|
+
- Added tool-related model classes (Tool, ToolConfig, FunctionDeclaration, FunctionResponse)
|
12
|
+
- JSON mode for structured data responses
|
13
|
+
- Added `generate_json` method for receiving JSON-formatted responses
|
14
|
+
- Implemented automatic parsing of JSON responses
|
15
|
+
- Added type-checking and validation for JSON mode configuration
|
16
|
+
- Safety settings for controlled content generation
|
17
|
+
- Added `generate_with_safety_settings` method for customizing safety settings
|
18
|
+
- Added `generate_text_safe` for maximum content safety
|
19
|
+
- Added `generate_text_permissive` for minimum content filtering
|
20
|
+
- Added comprehensive safety categories and threshold levels
|
21
|
+
- Implemented validation for safety setting configurations
|
22
|
+
|
1
23
|
## [1.1.0] - 2025-05-02
|
2
24
|
|
3
25
|
### Added
|
data/README.md
CHANGED
@@ -10,6 +10,9 @@ A convenient and robust Ruby interface for the Google Gemini API, enabling easy
|
|
10
10
|
- Multimodal inputs (text + images)
|
11
11
|
- Embeddings generation
|
12
12
|
- Support for streaming responses
|
13
|
+
- Function calling capabilities for tool integration
|
14
|
+
- JSON mode for structured data responses
|
15
|
+
- Safety settings for content moderation
|
13
16
|
- Comprehensive error handling
|
14
17
|
- Complete Models API for discovering and filtering available models
|
15
18
|
|
@@ -273,6 +276,184 @@ end
|
|
273
276
|
|
274
277
|
See the `examples/embeddings.rb` file for more comprehensive examples of working with embeddings.
|
275
278
|
|
279
|
+
## Function Calling
|
280
|
+
|
281
|
+
Geminize provides support for Gemini's function calling capabilities, allowing the AI model to call functions defined by you:
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
require 'geminize'
|
285
|
+
# Assumes API key is configured via .env
|
286
|
+
|
287
|
+
# Define functions that the model can call
|
288
|
+
weather_functions = [
|
289
|
+
{
|
290
|
+
name: "get_weather",
|
291
|
+
description: "Get the current weather for a location",
|
292
|
+
parameters: {
|
293
|
+
type: "object",
|
294
|
+
properties: {
|
295
|
+
location: {
|
296
|
+
type: "string",
|
297
|
+
description: "The city and state, e.g. New York, NY"
|
298
|
+
},
|
299
|
+
unit: {
|
300
|
+
type: "string",
|
301
|
+
enum: ["celsius", "fahrenheit"],
|
302
|
+
description: "The unit of temperature"
|
303
|
+
}
|
304
|
+
},
|
305
|
+
required: ["location"]
|
306
|
+
}
|
307
|
+
}
|
308
|
+
]
|
309
|
+
|
310
|
+
# Generate a response that may include a function call
|
311
|
+
response = Geminize.generate_with_functions(
|
312
|
+
"What's the weather in San Francisco?",
|
313
|
+
weather_functions,
|
314
|
+
"gemini-1.5-pro", # Make sure you use a model that supports function calling
|
315
|
+
{
|
316
|
+
temperature: 0.2,
|
317
|
+
system_instruction: "Use the provided function to get weather information."
|
318
|
+
}
|
319
|
+
)
|
320
|
+
|
321
|
+
# Check if the response contains a function call
|
322
|
+
if response.has_function_call?
|
323
|
+
function_call = response.function_call
|
324
|
+
puts "Function called: #{function_call.name}"
|
325
|
+
puts "Arguments: #{function_call.response.inspect}"
|
326
|
+
|
327
|
+
# Process the function call with your implementation
|
328
|
+
final_response = Geminize.process_function_call(response) do |name, args|
|
329
|
+
if name == "get_weather"
|
330
|
+
location = args["location"]
|
331
|
+
# Call your actual weather API here
|
332
|
+
# For this example, we'll just return mock data
|
333
|
+
{
|
334
|
+
temperature: 72,
|
335
|
+
conditions: "partly cloudy",
|
336
|
+
humidity: 65,
|
337
|
+
location: location
|
338
|
+
}
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
# Display the final response
|
343
|
+
puts "Final response: #{final_response.text}"
|
344
|
+
else
|
345
|
+
puts "No function call in response: #{response.text}"
|
346
|
+
end
|
347
|
+
```
|
348
|
+
|
349
|
+
### Function Call Options
|
350
|
+
|
351
|
+
You can customize function calling behavior:
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
# Set the tool execution mode:
|
355
|
+
# - "AUTO": Model decides when to call functions
|
356
|
+
# - "MANUAL": Functions are only used when explicitly requested
|
357
|
+
# - "NONE": Functions are ignored
|
358
|
+
response = Geminize.generate_with_functions(
|
359
|
+
prompt,
|
360
|
+
functions,
|
361
|
+
model_name,
|
362
|
+
{ tool_execution_mode: "MANUAL" }
|
363
|
+
)
|
364
|
+
|
365
|
+
# Control retry behavior
|
366
|
+
response = Geminize.generate_with_functions(
|
367
|
+
prompt,
|
368
|
+
functions,
|
369
|
+
model_name,
|
370
|
+
with_retries: false # Disable automatic retries on failure
|
371
|
+
)
|
372
|
+
```
|
373
|
+
|
374
|
+
## JSON Mode
|
375
|
+
|
376
|
+
Generate structured JSON responses from the model:
|
377
|
+
|
378
|
+
```ruby
|
379
|
+
require 'geminize'
|
380
|
+
# Assumes API key is configured via .env
|
381
|
+
|
382
|
+
# Request JSON-formatted data
|
383
|
+
response = Geminize.generate_json(
|
384
|
+
"List the three largest planets in our solar system with their diameters in km",
|
385
|
+
"gemini-1.5-pro", # Use a model that supports JSON mode
|
386
|
+
{ temperature: 0.2 }
|
387
|
+
)
|
388
|
+
|
389
|
+
# Access the parsed JSON data
|
390
|
+
if response.has_json_response?
|
391
|
+
planets = response.json_response
|
392
|
+
puts "Received structured data:"
|
393
|
+
planets.each do |planet|
|
394
|
+
puts "#{planet['name']}: #{planet['diameter']} km"
|
395
|
+
end
|
396
|
+
else
|
397
|
+
puts "No valid JSON in response: #{response.text}"
|
398
|
+
end
|
399
|
+
```
|
400
|
+
|
401
|
+
The JSON mode is ideal for getting structured data that you can programmatically process in your application.
|
402
|
+
|
403
|
+
## Safety Settings
|
404
|
+
|
405
|
+
Control content generation with safety settings:
|
406
|
+
|
407
|
+
```ruby
|
408
|
+
require 'geminize'
|
409
|
+
# Assumes API key is configured via .env
|
410
|
+
|
411
|
+
# Generate content with custom safety settings
|
412
|
+
safety_settings = [
|
413
|
+
{ category: "HARM_CATEGORY_DANGEROUS_CONTENT", threshold: "BLOCK_MEDIUM_AND_ABOVE" },
|
414
|
+
{ category: "HARM_CATEGORY_HATE_SPEECH", threshold: "BLOCK_LOW_AND_ABOVE" }
|
415
|
+
]
|
416
|
+
|
417
|
+
response = Geminize.generate_with_safety_settings(
|
418
|
+
"Explain the concept of nuclear fission",
|
419
|
+
safety_settings,
|
420
|
+
"gemini-1.5-pro",
|
421
|
+
{ temperature: 0.7 }
|
422
|
+
)
|
423
|
+
|
424
|
+
puts response.text
|
425
|
+
|
426
|
+
# For maximum safety (blocks most potentially harmful content)
|
427
|
+
safe_response = Geminize.generate_text_safe(
|
428
|
+
"Tell me about controversial political topics",
|
429
|
+
"gemini-1.5-pro"
|
430
|
+
)
|
431
|
+
|
432
|
+
puts "Safe response: #{safe_response.text}"
|
433
|
+
|
434
|
+
# For minimum filtering (blocks only the most harmful content)
|
435
|
+
permissive_response = Geminize.generate_text_permissive(
|
436
|
+
"Describe a controversial historical event",
|
437
|
+
"gemini-1.5-pro"
|
438
|
+
)
|
439
|
+
|
440
|
+
puts "Permissive response: #{permissive_response.text}"
|
441
|
+
```
|
442
|
+
|
443
|
+
Available safety categories:
|
444
|
+
|
445
|
+
- `HARM_CATEGORY_HATE_SPEECH`
|
446
|
+
- `HARM_CATEGORY_DANGEROUS_CONTENT`
|
447
|
+
- `HARM_CATEGORY_HARASSMENT`
|
448
|
+
- `HARM_CATEGORY_SEXUALLY_EXPLICIT`
|
449
|
+
|
450
|
+
Available threshold levels (from most to least restrictive):
|
451
|
+
|
452
|
+
- `BLOCK_LOW_AND_ABOVE`
|
453
|
+
- `BLOCK_MEDIUM_AND_ABOVE`
|
454
|
+
- `BLOCK_ONLY_HIGH`
|
455
|
+
- `BLOCK_NONE`
|
456
|
+
|
276
457
|
## Streaming Responses
|
277
458
|
|
278
459
|
Get real-time, token-by-token responses:
|