Class: Langchain::LLM::ReplicateResponse

Inherits:
BaseResponse show all
Defined in:
lib/langchain/llm/response/replicate_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, #completion_tokens, #initialize, #prompt_tokens, #total_tokens

Constructor Details

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

Instance Method Details

#completionObject



12
13
14
# File 'lib/langchain/llm/response/replicate_response.rb', line 12

def completion
  completions.first
end

#completionsObject



5
6
7
8
9
10
# File 'lib/langchain/llm/response/replicate_response.rb', line 5

def completions
  # Response comes back as an array of strings, e.g.: ["Hi", "how ", "are ", "you?"]
  # The first array element is missing a space at the end, so we add it manually
  raw_response.output[0] += " "
  [raw_response.output.join]
end

#created_atObject



16
17
18
# File 'lib/langchain/llm/response/replicate_response.rb', line 16

def created_at
  Time.parse(raw_response.created_at)
end

#embeddingObject



20
21
22
# File 'lib/langchain/llm/response/replicate_response.rb', line 20

def embedding
  embeddings.first
end

#embeddingsObject



24
25
26
# File 'lib/langchain/llm/response/replicate_response.rb', line 24

def embeddings
  [raw_response.output]
end