Class: Truffle::Providers::Base
- Inherits:
-
Object
- Object
- Truffle::Providers::Base
- Defined in:
- lib/truffle/providers/base.rb
Overview
The contract every provider implements. This single seam is what makes Truffle provider-agnostic: the agent loop only ever calls #chat and reads a Truffle::Response back. Swapping OpenAI for Anthropic or a local model is a one-line change at construction time. Every provider is written from scratch against this seam; there are no runtime gem dependencies.
Subclasses must implement #chat. They are free to translate Truffle::Message objects and tool schemas into their native wire format however they like.
Direct Known Subclasses
Instance Method Summary collapse
- #chat(messages:, tools: [], model: nil, **options) ⇒ Truffle::Response
-
#name ⇒ Object
Human-readable provider id, used in events and errors.
Instance Method Details
#chat(messages:, tools: [], model: nil, **options) ⇒ Truffle::Response
18 19 20 |
# File 'lib/truffle/providers/base.rb', line 18 def chat(messages:, tools: [], model: nil, **) raise NotImplementedError, "#{self.class} must implement #chat" end |
#name ⇒ Object
Human-readable provider id, used in events and errors.
23 24 25 |
# File 'lib/truffle/providers/base.rb', line 23 def name self.class.name.split("::").last.downcase end |