Module: LLM::OpenAI::Response::Responds

Defined in:
lib/llm/providers/openai/response/responds.rb

Instance Method Summary collapse

Instance Method Details

#output_textString

Returns the aggregated text content from the response outputs.

Returns:

  • (String)


17
18
19
# File 'lib/llm/providers/openai/response/responds.rb', line 17

def output_text
  choices.find(&:assistant?).content || ""
end

#response_idObject



6
# File 'lib/llm/providers/openai/response/responds.rb', line 6

def response_id = respond_to?(:response) ? response["id"] : id

#choicesObject



7
# File 'lib/llm/providers/openai/response/responds.rb', line 7

def choices = [format_message]

#annotationsObject



8
# File 'lib/llm/providers/openai/response/responds.rb', line 8

def annotations = choices[0].annotations

#prompt_tokensObject



10
# File 'lib/llm/providers/openai/response/responds.rb', line 10

def prompt_tokens = body.usage&.input_tokens

#completion_tokensObject



11
# File 'lib/llm/providers/openai/response/responds.rb', line 11

def completion_tokens = body.usage&.output_tokens

#total_tokensObject



12
# File 'lib/llm/providers/openai/response/responds.rb', line 12

def total_tokens = body.usage&.total_tokens

#modelObject



5
# File 'lib/llm/providers/openai/response/responds.rb', line 5

def model = body.model