22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/llm_gateway/adapters/openai/responses/output_mapper.rb', line 22
def self.map_choices(choices)
return [] unless choices
message_mapper = BidirectionalMessageMapper.new(LlmGateway::DIRECTION_OUT)
choices.map do |choice|
content = if choice[:id].start_with?("fc_")
{
id: choice[:id],
role: choice[:role] || "assistant", content: [ message_mapper.map_content(choice) ].flatten
}
else
content = message_mapper.map_content(choice)
id = content.delete(:id)
{
id: choice[:id] || id,
role: choice[:role],
content: [ content ].flatten
}
end
end
end
|