Class: LlmGateway::Adapters::OpenAI::ChatCompletions::InputMapper

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

Direct Known Subclasses

Groq::InputMapper, Responses::InputMapper

Class Method Summary collapse

Class Method Details

.map(data) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/llm_gateway/adapters/openai/chat_completions/input_mapper.rb', line 10

def self.map(data)
  {
    messages: map_messages(data[:messages]),
    tools: map_tools(data[:tools]),
    system: map_system(data[:system])
  }
end

.map_content(content) ⇒ Object



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/input_mapper.rb', line 18

def self.map_content(content)
  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", "function"
    map_tool_use_content(content)
  when "tool_result"
    map_tool_result_content(content)
  else
    content
  end
end