Class: Maglev::VectorStores::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/maglev/vector_stores/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner_type:, owner_id:, owner_model_name:, source:, chunk_index:, content:, content_checksum:, embedding_model:, embedding:, id: nil, owner: nil, distance: nil) ⇒ Document

Returns a new instance of Document.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/maglev/vector_stores/document.rb', line 10

def initialize(owner_type:, owner_id:, owner_model_name:, source:, chunk_index:,
  content:, content_checksum:, embedding_model:, embedding:, id: nil,
  owner: nil, distance: nil)
  @owner_type = owner_type
  @owner_id = owner_id
  @owner_model_name = owner_model_name
  @source = source
  @chunk_index = chunk_index
  @content = content
  @content_checksum = content_checksum
  @embedding_model = embedding_model
  @embedding = embedding
  @id = id || "#{owner_type}:#{owner_id}:#{source}:#{chunk_index}"
  @owner = owner
  @distance = distance
  freeze
end

Instance Attribute Details

#chunk_indexObject (readonly)

Returns the value of attribute chunk_index.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def chunk_index
  @chunk_index
end

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def content
  @content
end

#content_checksumObject (readonly)

Returns the value of attribute content_checksum.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def content_checksum
  @content_checksum
end

#distanceObject (readonly)

Returns the value of attribute distance.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def distance
  @distance
end

#embeddingObject (readonly)

Returns the value of attribute embedding.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def embedding
  @embedding
end

#embedding_modelObject (readonly)

Returns the value of attribute embedding_model.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def embedding_model
  @embedding_model
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def id
  @id
end

#ownerObject (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def owner
  @owner
end

#owner_idObject (readonly)

Returns the value of attribute owner_id.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def owner_id
  @owner_id
end

#owner_model_nameObject (readonly)

Returns the value of attribute owner_model_name.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def owner_model_name
  @owner_model_name
end

#owner_typeObject (readonly)

Returns the value of attribute owner_type.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def owner_type
  @owner_type
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/maglev/vector_stores/document.rb', line 6

def source
  @source
end

Instance Method Details

#metadataObject



28
29
30
31
32
33
34
35
36
# File 'lib/maglev/vector_stores/document.rb', line 28

def 
  {
    owner_type: owner_type,
    owner_id: owner_id,
    owner_model_name: owner_model_name,
    source: source,
    chunk_index: chunk_index
  }
end