gemini_craft 0.1.2 → 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.
data/lib/gemini_craft.rb CHANGED
@@ -1,16 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "gemini_craft/version"
4
-
5
- module GeminiCraft
6
- class Error < StandardError; end
7
- # Your code goes here...
8
- end
9
- # frozen_string_literal: true
10
-
4
+ require_relative "gemini_craft/error"
11
5
  require_relative "gemini_craft/configuration"
12
6
  require_relative "gemini_craft/client"
13
- require_relative "gemini_craft/error"
14
7
  require_relative "gemini_craft/cache"
15
8
 
16
9
  # GeminiCraft is a Ruby gem for generating content using Google's Gemini AI
@@ -30,6 +23,8 @@ module GeminiCraft
30
23
  # config.api_key = "your-api-key"
31
24
  # config.model = "gemini-2.0-flash"
32
25
  # config.cache_enabled = true
26
+ # config.streaming_enabled = true
27
+ # config.logger = Rails.logger
33
28
  # end
34
29
  # @yield [config] The configuration object
35
30
  def configure
@@ -46,14 +41,45 @@ module GeminiCraft
46
41
  # @param text [String] The text prompt to send to Gemini
47
42
  # @param system_instruction [String, nil] Optional system instruction to guide the model
48
43
  # @param options [Hash] Additional options for the request
49
- # @return [String] The generated content
50
- def generate_content(text, system_instruction = nil, options = {})
51
- client.generate_content(text, system_instruction, options)
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)
52
67
  end
53
68
 
54
69
  # Reset the configuration to defaults
55
70
  def reset_configuration
56
71
  @configuration = Configuration.new
57
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
58
84
  end
59
85
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemini_craft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shobhit Jain
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-03-23 00:00:00.000000000 Z
10
+ date: 2025-05-26 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -151,7 +150,8 @@ dependencies:
151
150
  - !ruby/object:Gem::Version
152
151
  version: '0.9'
153
152
  description: GeminiCraft provides a simple and robust interface to generate content
154
- using Google's Gemini AI models
153
+ using Google's Gemini AI models with support for streaming, function calling, and
154
+ advanced caching
155
155
  email:
156
156
  - shobjain09@gmail.com
157
157
  executables: []
@@ -175,8 +175,9 @@ metadata:
175
175
  homepage_uri: https://github.com/shobhits7/gemini_craft
176
176
  source_code_uri: https://github.com/shobhits7/gemini_craft
177
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
178
180
  rubygems_mfa_required: 'true'
179
- post_install_message:
180
181
  rdoc_options: []
181
182
  require_paths:
182
183
  - lib
@@ -184,15 +185,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
185
  requirements:
185
186
  - - ">="
186
187
  - !ruby/object:Gem::Version
187
- version: 2.6.0
188
+ version: 3.1.0
188
189
  required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  requirements:
190
191
  - - ">="
191
192
  - !ruby/object:Gem::Version
192
193
  version: '0'
193
194
  requirements: []
194
- rubygems_version: 3.3.7
195
- signing_key:
195
+ rubygems_version: 3.6.6
196
196
  specification_version: 4
197
197
  summary: A Ruby gem for generating content using Google's Gemini AI
198
198
  test_files: []