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
-
#cache_read_tokens ⇒ Integer
Returns the number of cached input tokens, or 0 when the provider does not report cache usage.
-
#cache_write_tokens ⇒ Integer
Returns the number of cache creation input tokens, or 0 when the provider does not report cache creation usage.
-
#content ⇒ String
Returns the LLM response.
-
#content! ⇒ Hash
Returns the LLM response after parsing it as JSON.
- #id ⇒ Object
-
#input_audio_tokens ⇒ Integer
Returns the number of input audio tokens, or 0 when the provider does not report input audio usage.
-
#input_image_tokens ⇒ Integer
Returns the number of input image tokens, or 0 when the provider does not report input image usage.
-
#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_audio_tokens ⇒ Integer
Returns the number of output audio tokens, or 0 when the provider does not report output audio usage.
-
#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
#cache_read_tokens ⇒ Integer
Returns the number of cached input tokens, or 0 when the provider does not report cache usage
56 57 58 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 56 def cache_read_tokens 0 end |
#cache_write_tokens ⇒ Integer
Returns the number of cache creation input tokens, or 0 when the provider does not report cache creation usage
62 63 64 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 62 def cache_write_tokens 0 end |
#content ⇒ String
Returns the LLM response
86 87 88 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 86 def content super end |
#content! ⇒ Hash
Returns the LLM response after parsing it as JSON
98 99 100 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 98 def content! super end |
#id ⇒ Object
14 15 16 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 14 def id body["responseId"] end |
#input_audio_tokens ⇒ Integer
Returns the number of input audio tokens, or 0 when the provider does not report input audio usage
38 39 40 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 38 def input_audio_tokens super end |
#input_image_tokens ⇒ Integer
Returns the number of input image tokens, or 0 when the provider does not report input image usage
50 51 52 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 50 def input_image_tokens super end |
#input_tokens ⇒ Integer
Returns the number of input tokens
20 21 22 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 20 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
80 81 82 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 80 def model body.modelVersion end |
#output_audio_tokens ⇒ Integer
Returns the number of output audio tokens, or 0 when the provider does not report output audio usage
44 45 46 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 44 def output_audio_tokens super end |
#output_tokens ⇒ Integer
Returns the number of output tokens
26 27 28 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 26 def output_tokens body.usageMetadata.candidatesTokenCount || 0 end |
#reasoning_content ⇒ String?
Returns the reasoning content when the provider exposes it
92 93 94 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 92 def reasoning_content super end |
#reasoning_tokens ⇒ Integer
Returns the number of reasoning tokens
32 33 34 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 32 def reasoning_tokens body.usageMetadata.thoughtsTokenCount || 0 end |
#total_tokens ⇒ Integer
Returns the total number of tokens
68 69 70 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 68 def total_tokens body.usageMetadata.totalTokenCount || 0 end |
#usage ⇒ LLM::Usage
Returns usage information
74 75 76 |
# File 'lib/llm/providers/google/response_adapter/completion.rb', line 74 def usage super end |