Class: Langchain::LLM::AnthropicResponse
Instance Attribute Summary
Attributes inherited from BaseResponse
#context, #raw_response
Instance Method Summary
collapse
#chat_completions, #created_at, #embedding, #embeddings, #initialize
Instance Method Details
#chat_completion ⇒ Object
13
14
15
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 13
def chat_completion
raw_response.dig("content", 0, "text")
end
|
#completion ⇒ Object
9
10
11
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 9
def completion
completions.first
end
|
#completion_tokens ⇒ Object
37
38
39
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 37
def completion_tokens
raw_response.dig("usage", "output_tokens").to_i
end
|
#completions ⇒ Object
17
18
19
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 17
def completions
[raw_response.dig("completion")]
end
|
#log_id ⇒ Object
29
30
31
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 29
def log_id
raw_response.dig("log_id")
end
|
#model ⇒ Object
5
6
7
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 5
def model
raw_response.dig("model")
end
|
#prompt_tokens ⇒ Object
33
34
35
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 33
def prompt_tokens
raw_response.dig("usage", "input_tokens").to_i
end
|
#role ⇒ Object
45
46
47
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 45
def role
raw_response.dig("role")
end
|
#stop ⇒ Object
25
26
27
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 25
def stop
raw_response.dig("stop")
end
|
#stop_reason ⇒ Object
21
22
23
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 21
def stop_reason
raw_response.dig("stop_reason")
end
|
#total_tokens ⇒ Object
41
42
43
|
# File 'lib/langchain/llm/response/anthropic_response.rb', line 41
def total_tokens
prompt_tokens + completion_tokens
end
|