Class: Roseflow::OpenRouter::Model
- Inherits:
-
Object
- Object
- Roseflow::OpenRouter::Model
- Defined in:
- lib/roseflow/open_router/model.rb
Instance Attribute Summary collapse
-
#context_length ⇒ Object
readonly
Returns the value of attribute context_length.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#call(operation, options) {|chunk| ... } ⇒ Faraday::Response
Calls the model.
-
#chat(messages, options = {}) {|chunk| ... } ⇒ OpenAI::ChatResponse
Convenience method for chat completions.
-
#initialize(model, provider) ⇒ Model
constructor
A new instance of Model.
- #max_tokens ⇒ Object
Constructor Details
#initialize(model, provider) ⇒ Model
Returns a new instance of Model.
18 19 20 21 22 |
# File 'lib/roseflow/open_router/model.rb', line 18 def initialize(model, provider) @model_ = model @provider_ = provider assign_attributes end |
Instance Attribute Details
#context_length ⇒ Object (readonly)
Returns the value of attribute context_length.
16 17 18 |
# File 'lib/roseflow/open_router/model.rb', line 16 def context_length @context_length end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/roseflow/open_router/model.rb', line 16 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/roseflow/open_router/model.rb', line 16 def name @name end |
Instance Method Details
#call(operation, options) {|chunk| ... } ⇒ Faraday::Response
Calls the model.
45 46 47 48 |
# File 'lib/roseflow/open_router/model.rb', line 45 def call(operation, , &block) operation = OperationHandler.new(operation, .merge({ model: name })).call client.post(operation, &block) end |
#chat(messages, options = {}) {|chunk| ... } ⇒ OpenAI::ChatResponse
Convenience method for chat completions.
34 35 36 37 |
# File 'lib/roseflow/open_router/model.rb', line 34 def chat(, = {}, &block) response = call(:completion, .merge({ messages: , model: name }), &block) ChatResponse.new(response) unless block_given? end |
#max_tokens ⇒ Object
24 25 26 |
# File 'lib/roseflow/open_router/model.rb', line 24 def max_tokens @context_length end |