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
data/lib/gemini_craft.rb
CHANGED
@@ -23,6 +23,8 @@ module GeminiCraft
|
|
23
23
|
# config.api_key = "your-api-key"
|
24
24
|
# config.model = "gemini-2.0-flash"
|
25
25
|
# config.cache_enabled = true
|
26
|
+
# config.streaming_enabled = true
|
27
|
+
# config.logger = Rails.logger
|
26
28
|
# end
|
27
29
|
# @yield [config] The configuration object
|
28
30
|
def configure
|
@@ -39,14 +41,45 @@ module GeminiCraft
|
|
39
41
|
# @param text [String] The text prompt to send to Gemini
|
40
42
|
# @param system_instruction [String, nil] Optional system instruction to guide the model
|
41
43
|
# @param options [Hash] Additional options for the request
|
42
|
-
# @
|
43
|
-
|
44
|
-
|
44
|
+
# @param stream [Boolean] Whether to stream the response
|
45
|
+
# @return [String, Enumerator] The generated content or stream enumerator
|
46
|
+
def generate_content(text, system_instruction = nil, options = {}, stream: false)
|
47
|
+
client.generate_content(text, system_instruction, options, stream: stream)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Generate content with function calling support
|
51
|
+
# @param text [String] The text prompt
|
52
|
+
# @param functions [Array<Hash>] Available functions for the model to call
|
53
|
+
# @param system_instruction [String, nil] Optional system instruction
|
54
|
+
# @param options [Hash] Additional options
|
55
|
+
# @return [Hash] Response including function calls if any
|
56
|
+
def generate_with_functions(text, functions, system_instruction = nil, options = {})
|
57
|
+
client.generate_with_functions(text, functions, system_instruction, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Generate streaming content
|
61
|
+
# @param text [String] The text prompt to send to Gemini
|
62
|
+
# @param system_instruction [String, nil] Optional system instruction
|
63
|
+
# @param options [Hash] Additional options
|
64
|
+
# @return [Enumerator] Stream enumerator
|
65
|
+
def stream_content(text, system_instruction = nil, options = {})
|
66
|
+
generate_content(text, system_instruction, options, stream: true)
|
45
67
|
end
|
46
68
|
|
47
69
|
# Reset the configuration to defaults
|
48
70
|
def reset_configuration
|
49
71
|
@configuration = Configuration.new
|
50
72
|
end
|
73
|
+
|
74
|
+
# Get cache statistics
|
75
|
+
# @return [Hash] Cache statistics
|
76
|
+
def cache_stats
|
77
|
+
client.cache.stats
|
78
|
+
end
|
79
|
+
|
80
|
+
# Clear the cache
|
81
|
+
def clear_cache
|
82
|
+
client.cache.clear
|
83
|
+
end
|
51
84
|
end
|
52
85
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemini_craft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shobhit Jain
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-05-26 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: faraday
|
@@ -150,7 +150,8 @@ dependencies:
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0.9'
|
152
152
|
description: GeminiCraft provides a simple and robust interface to generate content
|
153
|
-
using Google's Gemini AI models
|
153
|
+
using Google's Gemini AI models with support for streaming, function calling, and
|
154
|
+
advanced caching
|
154
155
|
email:
|
155
156
|
- shobjain09@gmail.com
|
156
157
|
executables: []
|
@@ -174,6 +175,8 @@ metadata:
|
|
174
175
|
homepage_uri: https://github.com/shobhits7/gemini_craft
|
175
176
|
source_code_uri: https://github.com/shobhits7/gemini_craft
|
176
177
|
changelog_uri: https://github.com/shobhits7/gemini_craft/blob/main/CHANGELOG.md
|
178
|
+
bug_tracker_uri: https://github.com/shobhits7/gemini_craft/issues
|
179
|
+
documentation_uri: https://rubydoc.info/gems/gemini_craft
|
177
180
|
rubygems_mfa_required: 'true'
|
178
181
|
rdoc_options: []
|
179
182
|
require_paths:
|