Class: InstLLM::Response::EmbeddingResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/inst_llm/response/embedding_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, embeddings) ⇒ EmbeddingResponse

Returns a new instance of EmbeddingResponse.



8
9
10
11
# File 'lib/inst_llm/response/embedding_response.rb', line 8

def initialize(model, embeddings)
  @model = model
  @embeddings = embeddings
end

Instance Attribute Details

#embeddingsObject (readonly)

Returns the value of attribute embeddings.



6
7
8
# File 'lib/inst_llm/response/embedding_response.rb', line 6

def embeddings
  @embeddings
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/inst_llm/response/embedding_response.rb', line 6

def model
  @model
end

Class Method Details

.from_cohere_embed(model:, response:) ⇒ Object



14
15
16
17
18
19
# File 'lib/inst_llm/response/embedding_response.rb', line 14

def from_cohere_embed(model:, response:)
  embeddings = response["embeddings"].map.with_index do |embedding, i|
    { object: "embedding", embedding: embedding, index: i }
  end
  new(model, embeddings)
end