Module: LLM::Google::ResponseAdapter::Completion

Includes:
Contract::Completion
Defined in:
lib/llm/providers/google/response_adapter/completion.rb

Constant Summary

Constants included from Contract

Contract::ContractError

Instance Method Summary collapse

Methods included from Contract

#included

Instance Method Details

#contentString

Returns the LLM response

Returns:

  • (String)

    Returns the LLM response



50
51
52
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 50

def content
  super
end

#content!Hash

Returns the LLM response after parsing it as JSON

Returns:

  • (Hash)

    Returns the LLM response after parsing it as JSON



62
63
64
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 62

def content!
  super
end

#input_tokensInteger

Returns the number of input tokens

Returns:

  • (Integer)

    Returns the number of input tokens



14
15
16
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 14

def input_tokens
  body..promptTokenCount || 0
end

#messagesArray<LLM::Messsage> Also known as: choices

Returns one or more messages

Returns:

  • (Array<LLM::Messsage>)

    Returns one or more messages



7
8
9
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 7

def messages
  adapt_choices
end

#modelString

Returns the model name

Returns:

  • (String)

    Returns the model name



44
45
46
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 44

def model
  body.modelVersion
end

#output_tokensInteger

Returns the number of output tokens

Returns:

  • (Integer)

    Returns the number of output tokens



20
21
22
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 20

def output_tokens
  body..candidatesTokenCount || 0
end

#reasoning_contentString?

Returns the reasoning content when the provider exposes it

Returns:

  • (String, nil)

    Returns the reasoning content when the provider exposes it



56
57
58
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 56

def reasoning_content
  super
end

#reasoning_tokensInteger

Returns the number of reasoning tokens

Returns:

  • (Integer)


26
27
28
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 26

def reasoning_tokens
  body..thoughtsTokenCount || 0
end

#total_tokensInteger

Returns the total number of tokens

Returns:

  • (Integer)

    Returns the total number of tokens



32
33
34
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 32

def total_tokens
  body..totalTokenCount || 0
end

#usageLLM::Usage

Returns usage information

Returns:



38
39
40
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 38

def usage
  super
end