Class: Ragents::Provider
- Inherits:
-
Object
- Object
- Ragents::Provider
- Defined in:
- lib/ragents/provider.rb
Overview
Abstract base class for LLM providers. Providers handle communication with LLM APIs and normalize responses.
The recommended provider is RubyLLM, which gives access to 500+ models across all major LLM providers (OpenAI, Anthropic, Gemini, Ollama, etc.)
Direct Known Subclasses
Defined Under Namespace
Classes: APIError, AuthenticationError, ConfigurationError, Error, RateLimitError
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#generate(messages:, tools: [], **options) ⇒ Response
Generate a response from the LLM.
-
#initialize(**config) ⇒ Provider
constructor
A new instance of Provider.
-
#name ⇒ Object
Provider name identifier.
-
#stream(messages:, tools: [], **options) {|chunk| ... } ⇒ Response
Stream a response from the LLM.
Constructor Details
#initialize(**config) ⇒ Provider
Returns a new instance of Provider.
33 34 35 36 |
# File 'lib/ragents/provider.rb', line 33 def initialize(**config) @config = default_config.merge(config) validate_config! end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
31 32 33 |
# File 'lib/ragents/provider.rb', line 31 def config @config end |
Instance Method Details
#generate(messages:, tools: [], **options) ⇒ Response
Generate a response from the LLM
43 44 45 |
# File 'lib/ragents/provider.rb', line 43 def generate(messages:, tools: [], **) raise NotImplementedError, "#{self.class} must implement #generate" end |
#name ⇒ Object
Provider name identifier
58 59 60 |
# File 'lib/ragents/provider.rb', line 58 def name self.class.name.split("::").last.downcase.to_sym end |
#stream(messages:, tools: [], **options) {|chunk| ... } ⇒ Response
Stream a response from the LLM
53 54 55 |
# File 'lib/ragents/provider.rb', line 53 def stream(messages:, tools: [], **, &block) raise NotImplementedError, "#{self.class} must implement #stream" end |