Class: LlmGateway::Adapters::OpenAI::ChatCompletions::BidirectionalMessageMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_gateway/adapters/openai/chat_completions/bidirectional_message_mapper.rb

Direct Known Subclasses

Responses::BidirectionalMessageMapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(direction) ⇒ BidirectionalMessageMapper

Returns a new instance of BidirectionalMessageMapper.



12
13
14
# File 'lib/llm_gateway/adapters/openai/chat_completions/bidirectional_message_mapper.rb', line 12

def initialize(direction)
  @direction = direction
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



10
11
12
# File 'lib/llm_gateway/adapters/openai/chat_completions/bidirectional_message_mapper.rb', line 10

def direction
  @direction
end

Instance Method Details

#map_content(content) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/llm_gateway/adapters/openai/chat_completions/bidirectional_message_mapper.rb', line 16

def map_content(content)
  # Convert string content to text format
  content = { type: "text", text: content } unless content.is_a?(Hash)
  case content[:type]
  when "text"
    map_text_content(content)
  when "file"
    map_file_content(content)
  when "image"
    map_image_content(content)
  when "tool_use"
    map_tool_use_content(content)
  when "function"
    map_tool_use_content(content)
  when "tool_result"
    map_tool_result_content(content)
  else
    content
  end
end