Class: Riffer::Providers::Base
- Inherits:
-
Object
- Object
- Riffer::Providers::Base
- Includes:
- Helpers::Dependencies, Messages::Converter
- Defined in:
- lib/riffer/providers/base.rb
Overview
Base class for all LLM providers in the Riffer framework.
Subclasses must implement perform_generate_text and perform_stream_text.
Direct Known Subclasses
Instance Method Summary collapse
-
#generate_text(prompt: nil, system: nil, messages: nil, model: nil, **options) ⇒ Object
Generates text using the provider.
-
#stream_text(prompt: nil, system: nil, messages: nil, model: nil, **options) ⇒ Object
Streams text from the provider.
Methods included from Messages::Converter
Instance Method Details
#generate_text(prompt: nil, system: nil, messages: nil, model: nil, **options) ⇒ Object
Generates text using the provider.
- prompt
-
String or nil - the user prompt (required when messages is not provided)
- system
-
String or nil - an optional system message
- messages
-
Array or nil - optional messages array
- model
-
String or nil - optional model string to override the configured model
- options
-
Hash - additional options passed to the model invocation
Returns Riffer::Messages::Assistant - the generated assistant message.
19 20 21 22 23 24 |
# File 'lib/riffer/providers/base.rb', line 19 def generate_text(prompt: nil, system: nil, messages: nil, model: nil, **) validate_input!(prompt: prompt, system: system, messages: ) = (prompt: prompt, system: system, messages: ) () perform_generate_text(, model: model, **) end |
#stream_text(prompt: nil, system: nil, messages: nil, model: nil, **options) ⇒ Object
Streams text from the provider.
- prompt
-
String or nil - the user prompt (required when messages is not provided)
- system
-
String or nil - an optional system message
- messages
-
Array or nil - optional messages array
- model
-
String or nil - optional model string to override the configured model
- options
-
Hash - additional options passed to the model invocation
Returns Enumerator - an enumerator yielding stream events.
35 36 37 38 39 40 |
# File 'lib/riffer/providers/base.rb', line 35 def stream_text(prompt: nil, system: nil, messages: nil, model: nil, **) validate_input!(prompt: prompt, system: system, messages: ) = (prompt: prompt, system: system, messages: ) () perform_stream_text(, model: model, **) end |