Class: LLM::Response::Completion

Inherits:
LLM::Response show all
Defined in:
lib/llm/response/completion.rb

Instance Attribute Summary

Attributes inherited from LLM::Response

#body

Instance Method Summary collapse

Methods inherited from LLM::Response

#initialize

Constructor Details

This class inherits a constructor from LLM::Response

Instance Method Details

#choicesArray<LLM::Message>

Returns an array of messages

Returns:



15
16
17
# File 'lib/llm/response/completion.rb', line 15

def choices
  parsed[:choices]
end

#completion_tokensInteger

Returns the count of completion tokens

Returns:

  • (Integer)

    Returns the count of completion tokens



29
30
31
# File 'lib/llm/response/completion.rb', line 29

def completion_tokens
  parsed[:completion_tokens]
end

#modelString

Returns the model name used for the completion

Returns:

  • (String)

    Returns the model name used for the completion



8
9
10
# File 'lib/llm/response/completion.rb', line 8

def model
  parsed[:model]
end

#prompt_tokensInteger

Returns the count of prompt tokens

Returns:

  • (Integer)

    Returns the count of prompt tokens



22
23
24
# File 'lib/llm/response/completion.rb', line 22

def prompt_tokens
  parsed[:prompt_tokens]
end

#total_tokensInteger

Returns the total count of tokens

Returns:

  • (Integer)

    Returns the total count of tokens



36
37
38
# File 'lib/llm/response/completion.rb', line 36

def total_tokens
  prompt_tokens + completion_tokens
end