Class: LlmGateway::Adapters::Anthropic::OutputMapper
- Inherits:
-
Object
- Object
- LlmGateway::Adapters::Anthropic::OutputMapper
- Defined in:
- lib/llm_gateway/adapters/anthropic/output_mapper.rb
Class Method Summary collapse
Class Method Details
.map(data) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/llm_gateway/adapters/anthropic/output_mapper.rb', line 17 def self.map(data) { id: data[:id], model: data[:model], usage: data[:usage], choices: map_choices(data) } end |
.map_choices(data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/llm_gateway/adapters/anthropic/output_mapper.rb', line 28 def self.map_choices(data) = BidirectionalMessageMapper.new(LlmGateway::DIRECTION_OUT) content = if data[:content].is_a?(Array) data[:content].map do |content| .map_content(content) end else data[:content] ? [ .map_content(data[:content]) ] : [] end # Claude returns content directly at root level, not in a choices array # We need to construct the choices array from the full response data [ { content: content, # Use content directly from Claude response finish_reason: data[:stop_reason], role: "assistant" } ] end |