ruby_llm-sequel 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0cdecd16447df344e6e618c6e0883890348068cfa185085304e6bd26bffbb9a
4
- data.tar.gz: 2984799b793177bf89fef310270444aa3728c7ad4f9fee0558df599065cebc4a
3
+ metadata.gz: 3422a45af2abd1286b9762fcbf6efd245af84375e6dde6ab067adb433a80c3e7
4
+ data.tar.gz: 54ec6f2324de674e4fe112280843115f0b866b5a8edc93776768d57b3b5b2f76
5
5
  SHA512:
6
- metadata.gz: 91a0ad1ef357c27909b064abcbbd6b5cc83b256d1de8b280f8b0d60e6d7fa71c9b9bda191a8d80ded993eb100cb3ad9b68f2483fd9fe9dd15ace65e7d17bc834
7
- data.tar.gz: 85d122fcad93f5c14af4e5897c9173a69b0c1725a231f60bd8d0b606da31f696cf8f837d9653e2973540230ae8273079fbdde15fe92f132a759aa90c509b8976
6
+ metadata.gz: 4fac8795a86055f72e7197042006de0f14cd6c2d7e9951ffe470721c0a9c8032d062a32b2b98be2ba7ff3ca3c9d98c35e779bc93dccbda057c8b43f3ec06f7e1
7
+ data.tar.gz: 7a662f9adb13c9570b564fb7268c8230c19e9b1c1bbbebef392a2d0a38f587b5499bc5b6cb04d4e399a870293c2e9c7c1fecd5bcb010878ee0fb3c02434fecf6
data/README.md CHANGED
@@ -137,8 +137,14 @@ end
137
137
  # Configure RubyLLM
138
138
  RubyLLM.configure do |config|
139
139
  config.openai_api_key = ENV['OPENAI_API_KEY']
140
+
141
+ # For custom Model class names (defaults to 'Model')
142
+ # config.model_registry_class = 'AIModel'
140
143
  end
141
144
 
145
+ # Opt-in behaviour to use models registry from database
146
+ RubyLLM.Sequel.use_model_registry!
147
+
142
148
  # Create a chat
143
149
  chat = Chat.create
144
150
 
@@ -246,7 +252,7 @@ ruby -Ilib:spec spec/ruby_llm/sequel/chat_methods_spec.rb
246
252
  The tests use:
247
253
  - **Minitest** for the test framework
248
254
  - **SQLite** in-memory database for fast test execution
249
- - **VCR + WebMock** for HTTP interaction recording (when testing with real API calls)
255
+ - **SimpleCov** for code coverage reporting
250
256
  - **Transaction rollback** to isolate tests and maintain a clean database state
251
257
 
252
258
  All test configuration is in `spec/spec_helper.rb`.
@@ -161,7 +161,7 @@ module RubyLLM
161
161
  def complete(...)
162
162
  to_llm.complete(...)
163
163
  rescue ::RubyLLM::Error => e
164
- cleanup_failed_messages if !@message.id.nil? && @message.content && @message.content != ''
164
+ cleanup_failed_messages if !@message&.id.nil? && @message&.content && @message&.content != ''
165
165
  cleanup_orphaned_tool_results
166
166
  raise e
167
167
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Sequel
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
@@ -15,5 +15,29 @@ require_relative '../sequel/plugins/ruby_llm'
15
15
  module RubyLLM
16
16
  module Sequel
17
17
  class UnsupportedFeatureError < StandardError; end
18
+
19
+ class << self
20
+ def use_model_registry!
21
+ # Monkey-patch Models to use database
22
+ RubyLLM::Models.class_eval do
23
+ def self.load_models
24
+ read_from_database
25
+ rescue StandardError => e
26
+ RubyLLM.logger.debug "Failed to load models from database: #{e.message}, falling back to JSON"
27
+ read_from_json
28
+ end
29
+
30
+ def self.read_from_database
31
+ model_class = RubyLLM.config.model_registry_class
32
+ model_class = model_class.constantize if model_class.is_a?(String)
33
+ model_class.all.map(&:to_llm)
34
+ end
35
+
36
+ def load_from_database!
37
+ @models = self.class.read_from_database
38
+ end
39
+ end
40
+ end
41
+ end
18
42
  end
19
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_llm-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Pasquale