Class: LLM::OpenAI::ResponseParser::RespondParser

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/openai/response_parser/respond_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ RespondParser

Returns a new instance of RespondParser.



7
8
9
# File 'lib/llm/providers/openai/response_parser/respond_parser.rb', line 7

def initialize(body)
  @body = OpenStruct.from_hash(body)
end

Instance Method Details

#format(response) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/llm/providers/openai/response_parser/respond_parser.rb', line 11

def format(response)
  {
    id:,
    model:,
    input_tokens:,
    output_tokens:,
    total_tokens:,
    outputs: [format_message(response)]
  }
end