Class: Langchain::LLM::AI21Response
Instance Attribute Summary
Attributes inherited from BaseResponse
#context, #model, #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/ai21_response.rb', line 13
def chat_completion
raw_response.dig(:choices, 0, :message, :content)
end
|
#completion ⇒ Object
9
10
11
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 9
def completion
completions.dig(0, :data, :text)
end
|
#completion_tokens ⇒ Object
21
22
23
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 21
def completion_tokens
raw_response.dig(:usage, :completion_tokens).to_i
end
|
#completions ⇒ Object
5
6
7
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 5
def completions
raw_response.dig(:completions)
end
|
#prompt_tokens ⇒ Object
17
18
19
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 17
def prompt_tokens
raw_response.dig(:usage, :prompt_tokens).to_i
end
|
#role ⇒ Object
29
30
31
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 29
def role
raw_response.dig(:choices, 0, :message, :role)
end
|
#total_tokens ⇒ Object
25
26
27
|
# File 'lib/langchain/llm/response/ai21_response.rb', line 25
def total_tokens
raw_response.dig(:usage, :total_tokens).to_i
end
|