Module: LLM::Google::ResponseAdapter::Completion
- Includes:
- Contract::Completion
- Defined in:
- lib/llm/providers/google/response_adapter/completion.rb
Constant Summary
Constants included from Contract
Instance Method Summary collapse
-
#content ⇒ String
Returns the LLM response.
-
#content! ⇒ Hash
Returns the LLM response after parsing it as JSON.
-
#input_tokens ⇒ Integer
Returns the number of input tokens.
-
#messages ⇒ Array<LLM::Messsage>
(also: #choices)
Returns one or more messages.
-
#model ⇒ String
Returns the model name.
-
#output_tokens ⇒ Integer
Returns the number of output tokens.
-
#reasoning_content ⇒ String?
Returns the reasoning content when the provider exposes it.
-
#reasoning_tokens ⇒ Integer
Returns the number of reasoning tokens.
-
#total_tokens ⇒ Integer
Returns the total number of tokens.
-
#usage ⇒ LLM::Usage
Returns usage information.
Methods included from Contract
Instance Method Details
#content ⇒ 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
62 63 64 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 62 def content! super end |
#input_tokens ⇒ 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.usageMetadata.promptTokenCount || 0 end |
#messages ⇒ Array<LLM::Messsage> Also known as: choices
Returns one or more messages
7 8 9 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 7 def adapt_choices end |
#model ⇒ 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_tokens ⇒ 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.usageMetadata.candidatesTokenCount || 0 end |
#reasoning_content ⇒ String?
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_tokens ⇒ Integer
Returns the number of reasoning tokens
26 27 28 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 26 def reasoning_tokens body.usageMetadata.thoughtsTokenCount || 0 end |
#total_tokens ⇒ 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.usageMetadata.totalTokenCount || 0 end |
#usage ⇒ LLM::Usage
Returns usage information
38 39 40 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 38 def usage super end |