Class: Durable::Llm::Providers::Cohere::CohereResponse
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Cohere::CohereResponse
- Defined in:
- lib/durable/llm/providers/cohere.rb
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
- #choices ⇒ Object
-
#initialize(response) ⇒ CohereResponse
constructor
A new instance of CohereResponse.
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ CohereResponse
Returns a new instance of CohereResponse.
150 151 152 |
# File 'lib/durable/llm/providers/cohere.rb', line 150 def initialize(response) @raw_response = response end |
Instance Attribute Details
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
148 149 150 |
# File 'lib/durable/llm/providers/cohere.rb', line 148 def raw_response @raw_response end |
Instance Method Details
#choices ⇒ Object
154 155 156 |
# File 'lib/durable/llm/providers/cohere.rb', line 154 def choices @raw_response.dig('message', 'content')&.map { |generation| CohereChoice.new(generation) } || [] end |
#to_s ⇒ Object
158 159 160 |
# File 'lib/durable/llm/providers/cohere.rb', line 158 def to_s choices.map(&:to_s).join(' ') end |