Class: Soka::LLMs::Base
- Inherits:
-
Object
- Object
- Soka::LLMs::Base
- Defined in:
- lib/soka/llms/base.rb
Overview
Base class for LLM providers
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #chat(messages, **params) ⇒ Object
-
#initialize(model: nil, api_key: nil, **options) ⇒ Base
constructor
A new instance of Base.
- #streaming_chat(messages, **params) ⇒ Object
- #supports_streaming? ⇒ Boolean
Constructor Details
#initialize(model: nil, api_key: nil, **options) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 |
# File 'lib/soka/llms/base.rb', line 17 def initialize(model: nil, api_key: nil, **) @model = model || default_model @api_key = api_key || api_key_from_env = .merge() validate_configuration! end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/soka/llms/base.rb', line 15 def api_key @api_key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
15 16 17 |
# File 'lib/soka/llms/base.rb', line 15 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/soka/llms/base.rb', line 15 def end |
Instance Method Details
#chat(messages, **params) ⇒ Object
24 25 26 |
# File 'lib/soka/llms/base.rb', line 24 def chat(, **params) raise NotImplementedError, "#{self.class} must implement #chat method" end |
#streaming_chat(messages, **params) ⇒ Object
28 29 30 |
# File 'lib/soka/llms/base.rb', line 28 def streaming_chat(, **params, &) raise NotImplementedError, "#{self.class} does not support streaming" end |
#supports_streaming? ⇒ Boolean
32 33 34 |
# File 'lib/soka/llms/base.rb', line 32 def supports_streaming? false end |