Class: Durable::Llm::Providers::Cohere::CohereResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/durable/llm/providers/cohere.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ CohereResponse

Returns a new instance of CohereResponse.



73
74
75
# File 'lib/durable/llm/providers/cohere.rb', line 73

def initialize(response)
  @raw_response = response
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



71
72
73
# File 'lib/durable/llm/providers/cohere.rb', line 71

def raw_response
  @raw_response
end

Instance Method Details

#choicesObject



77
78
79
# File 'lib/durable/llm/providers/cohere.rb', line 77

def choices
  [@raw_response.dig('message', 'content')].flatten.map { |generation| CohereChoice.new(generation) }
end

#to_sObject



81
82
83
# File 'lib/durable/llm/providers/cohere.rb', line 81

def to_s
  choices.map(&:to_s).join(' ')
end