Class: Rubyagents::Model
- Inherits:
-
Object
- Object
- Rubyagents::Model
- Defined in:
- lib/rubyagents/model.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Attribute Summary collapse
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(messages, tools: nil, &on_stream) ⇒ Object
-
#initialize(model_name) ⇒ Model
constructor
A new instance of Model.
Constructor Details
#initialize(model_name) ⇒ Model
Returns a new instance of Model.
91 92 93 |
# File 'lib/rubyagents/model.rb', line 91 def initialize(model_name) @model_name = model_name end |
Class Attribute Details
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
68 69 70 |
# File 'lib/rubyagents/model.rb', line 68 def registry @registry end |
Instance Attribute Details
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
89 90 91 |
# File 'lib/rubyagents/model.rb', line 89 def model_name @model_name end |
Class Method Details
.for(model_id) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rubyagents/model.rb', line 74 def for(model_id) if model_id.include?("/") prefix, model_name = model_id.split("/", 2) adapter_class = @registry[prefix] if adapter_class adapter_class.new(model_name) else Models::RubyLLMAdapter.new(model_name, provider: prefix) end else Models::RubyLLMAdapter.new(model_id) end end |
.register(prefix, klass) ⇒ Object
70 71 72 |
# File 'lib/rubyagents/model.rb', line 70 def register(prefix, klass) @registry[prefix] = klass end |
Instance Method Details
#generate(messages, tools: nil, &on_stream) ⇒ Object
95 96 97 |
# File 'lib/rubyagents/model.rb', line 95 def generate(, tools: nil, &on_stream) raise NotImplementedError, "#{self.class} must implement #generate" end |