Class: Yorishiro::Provider::Base
- Inherits:
-
Object
- Object
- Yorishiro::Provider::Base
- Defined in:
- lib/yorishiro/provider/base.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#chat(_conversation, tools: []) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#context_budget_tokens ⇒ Object
Token budget the conversation should be trimmed to before each request.
- #debug? ⇒ Boolean
- #debug_log(label, data = nil) ⇒ Object
-
#initialize(api_key:, model: nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_key:, model: nil) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/yorishiro/provider/base.rb', line 12 def initialize(api_key:, model: nil) @api_key = api_key @model_name = model || default_model end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/yorishiro/provider/base.rb', line 10 def api_key @api_key end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
10 11 12 |
# File 'lib/yorishiro/provider/base.rb', line 10 def model_name @model_name end |
Class Method Details
.supported_models ⇒ Object
21 22 23 |
# File 'lib/yorishiro/provider/base.rb', line 21 def self.supported_models raise ProviderNotImplementedError, "#{self}.supported_models is not implemented" end |
Instance Method Details
#chat(_conversation, tools: []) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
17 18 19 |
# File 'lib/yorishiro/provider/base.rb', line 17 def chat(_conversation, tools: [], &) # rubocop:disable Lint/UnusedMethodArgument raise ProviderNotImplementedError, "#{self.class}#chat is not implemented" end |
#context_budget_tokens ⇒ Object
Token budget the conversation should be trimmed to before each request. nil means "no known context window" — the conversation is not trimmed. Providers with a fixed local context window (Ollama) override this.
41 42 43 |
# File 'lib/yorishiro/provider/base.rb', line 41 def context_budget_tokens nil end |
#debug? ⇒ Boolean
25 26 27 |
# File 'lib/yorishiro/provider/base.rb', line 25 def debug? ENV["YORISHIRO_DEBUG"] == "1" end |
#debug_log(label, data = nil) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/yorishiro/provider/base.rb', line 29 def debug_log(label, data = nil) return unless debug? warn "[DEBUG] #{label}" warn(data.is_a?(String) ? data : JSON.pretty_generate(data)) if data rescue StandardError nil end |