Class: RubyLLM::Models::Registry::FileStore
- Inherits:
-
Object
- Object
- RubyLLM::Models::Registry::FileStore
- Defined in:
- lib/ruby_llm/models/registry.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #etag ⇒ Object
-
#initialize(path) ⇒ FileStore
constructor
A new instance of FileStore.
- #read ⇒ Object
- #write(models, etag: nil) ⇒ Object
Constructor Details
#initialize(path) ⇒ FileStore
Returns a new instance of FileStore.
16 17 18 19 |
# File 'lib/ruby_llm/models/registry.rb', line 16 def initialize(path) @path = path.respond_to?(:path) ? path.path : path.to_s raise ModelRegistryError, 'A model registry file path is required' if @path.empty? end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/ruby_llm/models/registry.rb', line 14 def path @path end |
Instance Method Details
#etag ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby_llm/models/registry.rb', line 25 def etag return unless File.file?(path) value = File.read(etag_path).strip value unless value.empty? rescue Errno::ENOENT nil rescue SystemCallError => e raise ModelRegistryError, "Could not read the model registry ETag from #{etag_path}: #{e.}" end |
#read ⇒ Object
21 22 23 |
# File 'lib/ruby_llm/models/registry.rb', line 21 def read Registry.read(path) end |
#write(models, etag: nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ruby_llm/models/registry.rb', line 36 def write(models, etag: nil) FileUtils.mkdir_p(File.dirname(path)) atomic_write(path, Registry.pretty_json(models)) write_etag(etag) models end |