Class: RagRuby::Chunk

Inherits:
Object
  • Object
show all
Defined in:
lib/rag_ruby/chunk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, metadata: {}, document_source: nil, index: 0) ⇒ Chunk

Returns a new instance of Chunk.



7
8
9
10
11
12
13
# File 'lib/rag_ruby/chunk.rb', line 7

def initialize(text:, metadata: {}, document_source: nil, index: 0)
  @text = text
   = 
  @document_source = document_source
  @index = index
  @embedding = nil
end

Instance Attribute Details

#document_source ⇒ Object

Returns the value of attribute document_source.



5
6
7
# File 'lib/rag_ruby/chunk.rb', line 5

def document_source
  @document_source
end

#embedding ⇒ Object

Returns the value of attribute embedding.



5
6
7
# File 'lib/rag_ruby/chunk.rb', line 5

def embedding
  @embedding
end

#index ⇒ Object

Returns the value of attribute index.



5
6
7
# File 'lib/rag_ruby/chunk.rb', line 5

def index
  @index
end

#metadata ⇒ Object

Returns the value of attribute metadata.



5
6
7
# File 'lib/rag_ruby/chunk.rb', line 5

def 
  
end

#text ⇒ Object

Returns the value of attribute text.



5
6
7
# File 'lib/rag_ruby/chunk.rb', line 5

def text
  @text
end

Instance Method Details

#bytesize ⇒ Object



23
24
25
# File 'lib/rag_ruby/chunk.rb', line 23

def bytesize
  text.bytesize
end

#embedded? ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rag_ruby/chunk.rb', line 15

def embedded?
  !@embedding.nil?
end

#to_s ⇒ Object



19
20
21
# File 'lib/rag_ruby/chunk.rb', line 19

def to_s
  text
end