Class: Legion::Extensions::Llm::Responses::EmbeddingResponse
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::Responses::EmbeddingResponse
- Defined in:
- lib/legion/extensions/llm/responses/embedding_response.rb
Overview
Normalized embedding provider response.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#vectors ⇒ Object
readonly
Returns the value of attribute vectors.
Instance Method Summary collapse
-
#initialize(vectors:, model:, tokens: nil, metadata: {}, raw: nil) ⇒ EmbeddingResponse
constructor
A new instance of EmbeddingResponse.
- #to_h ⇒ Object
- #to_internal_h ⇒ Object
Constructor Details
#initialize(vectors:, model:, tokens: nil, metadata: {}, raw: nil) ⇒ EmbeddingResponse
Returns a new instance of EmbeddingResponse.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 11 def initialize(vectors:, model:, tokens: nil, metadata: {}, raw: nil) @vectors = vectors @model = model @tokens = tokens @metadata = ThinkingExtractor.extract(nil, metadata: ). @internal_metadata = .to_h @raw = raw freeze end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 9 def @metadata end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 9 def model @model end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
9 10 11 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 9 def raw @raw end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
9 10 11 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 9 def tokens @tokens end |
#vectors ⇒ Object (readonly)
Returns the value of attribute vectors.
9 10 11 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 9 def vectors @vectors end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 22 def to_h { vectors: vectors, model: model, tokens: tokens, metadata: }.compact end |
#to_internal_h ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/llm/responses/embedding_response.rb', line 31 def to_internal_h to_h.merge(metadata: @internal_metadata, raw: raw).compact end |