Class: LLM
- Inherits:
-
Object
- Object
- LLM
- Defined in:
- lib/llm.rb
Defined Under Namespace
Modules: Info, StopReason
Instance Attribute Summary collapse
-
#canonical_name ⇒ Object
readonly
Returns the value of attribute canonical_name.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(model) ⇒ LLM
constructor
A new instance of LLM.
Constructor Details
#initialize(model) ⇒ LLM
Returns a new instance of LLM.
12 13 14 15 16 17 |
# File 'lib/llm.rb', line 12 def initialize(model) @canonical_name = model[:canonical_name] @display_name = model[:display_name] @provider = model[:provider] @client_class = LLM::Clients::OpenAI # TODO: Allow alternative client classes. end |
Instance Attribute Details
#canonical_name ⇒ Object (readonly)
Returns the value of attribute canonical_name.
23 24 25 |
# File 'lib/llm.rb', line 23 def canonical_name @canonical_name end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
23 24 25 |
# File 'lib/llm.rb', line 23 def display_name @display_name end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
23 24 25 |
# File 'lib/llm.rb', line 23 def provider @provider end |
Class Method Details
.all! ⇒ Object
32 33 34 |
# File 'lib/llm.rb', line 32 def all! known_models end |
.from_string!(model_string) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/llm.rb', line 36 def from_string!(model_string) model = known_models.find { |model| model.canonical_name == model_string } raise ArgumentError, "Unknown model: #{model_string}" unless model model end |
Instance Method Details
#client ⇒ Object
19 20 21 |
# File 'lib/llm.rb', line 19 def client client_class.new(llm: self) end |