ruby_llm-sequel 0.1.0 → 0.1.1

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: ca798a25ce99f4041c275112f8b98547d41081c8aa3f6ba471a206ee9a3a5b95
4
+ data.tar.gz: 9527f83e686789683dfc650c9e5893983f76d636e06565065450d6c0879be556
5
5
  SHA512:
6
- metadata.gz: 91a0ad1ef357c27909b064abcbbd6b5cc83b256d1de8b280f8b0d60e6d7fa71c9b9bda191a8d80ded993eb100cb3ad9b68f2483fd9fe9dd15ace65e7d17bc834
7
- data.tar.gz: 85d122fcad93f5c14af4e5897c9173a69b0c1725a231f60bd8d0b606da31f696cf8f837d9653e2973540230ae8273079fbdde15fe92f132a759aa90c509b8976
6
+ metadata.gz: 1fe594e587d11a662a64eef422eea7f7d636d478908dcbb74fc4e44c7d9b2c2467c851d9f0c7480621b67499a071abae6e4328d343fe4ac24ca1187af2109766
7
+ data.tar.gz: f442118b9e1e524fbdc646b3deb6af963aaa8f687a7eae4a03a5d48c07992c0ce902c646e6c9cbe92fa5a58ab20e034f14297b16e7b1515b8aaf5490050bd759
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`.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Sequel
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Pasquale