Class: Boxcars::VectorStore::InMemory::BuildFromArray
- Inherits:
-
Object
- Object
- Boxcars::VectorStore::InMemory::BuildFromArray
- Includes:
- Boxcars::VectorStore
- Defined in:
- lib/boxcars/vector_store/in_memory/build_from_array.rb
Instance Method Summary collapse
-
#call ⇒ Hash
Vector_store: array of Inventor::VectorStore::Document.
-
#initialize(embedding_tool: :openai, input_array: nil) ⇒ Hash
constructor
each hash item should have content and metadata [ { content: “hello”, metadata: { a: 1 } }, { content: “hi”, metadata: { a: 1 } }, { content: “bye”, metadata: { a: 1 } }, { content: “what’s this”, metadata: { a: 1 } } ].
Methods included from Boxcars::VectorStore
Constructor Details
#initialize(embedding_tool: :openai, input_array: nil) ⇒ Hash
each hash item should have content and metadata [
{ content: "hello", metadata: { a: 1 } },
{ content: "hi", metadata: { a: 1 } },
{ content: "bye", metadata: { a: 1 } },
{ content: "what's this", metadata: { a: 1 } }
]
19 20 21 22 23 24 |
# File 'lib/boxcars/vector_store/in_memory/build_from_array.rb', line 19 def initialize(embedding_tool: :openai, input_array: nil) validate_params(, input_array) @embedding_tool = @input_array = input_array @memory_vectors = [] end |
Instance Method Details
#call ⇒ Hash
Returns vector_store: array of Inventor::VectorStore::Document.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/boxcars/vector_store/in_memory/build_from_array.rb', line 27 def call texts = input_array.map { |doc| doc[:content] } vectors = generate_vectors(texts) add_vectors(vectors, input_array) { type: :in_memory, vector_store: memory_vectors } end |