Class: Langchain::LLM::AwsBedrockMetaResponse

Inherits:
BaseResponse
  • Object
show all
Defined in:
lib/langchain/llm/response/aws_bedrock_meta_response.rb

Instance Attribute Summary

Attributes inherited from BaseResponse

#context, #model, #raw_response

Instance Method Summary collapse

Methods inherited from BaseResponse

#chat_completion, #chat_completions, #created_at, #embedding, #embeddings, #initialize

Constructor Details

This class inherits a constructor from Langchain::LLM::BaseResponse

Instance Method Details

#completionObject



5
6
7
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 5

def completion
  completions.first
end

#completion_tokensObject



21
22
23
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 21

def completion_tokens
  raw_response.dig("generation_token_count").to_i
end

#completionsObject



9
10
11
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 9

def completions
  [raw_response.dig("generation")]
end

#prompt_tokensObject



17
18
19
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 17

def prompt_tokens
  raw_response.dig("prompt_token_count").to_i
end

#stop_reasonObject



13
14
15
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 13

def stop_reason
  raw_response.dig("stop_reason")
end

#total_tokensObject



25
26
27
# File 'lib/langchain/llm/response/aws_bedrock_meta_response.rb', line 25

def total_tokens
  prompt_tokens + completion_tokens
end