Class: Kreuzberg::Result::Chunk

Inherits:
Struct
  • Object
show all
Defined in:
lib/kreuzberg/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#byte_endInteger (readonly)

Returns Ending byte offset (UTF-8).

Returns:

  • (Integer)

    Ending byte offset (UTF-8)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#byte_startInteger (readonly)

Returns Starting byte offset (UTF-8).

Returns:

  • (Integer)

    Starting byte offset (UTF-8)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#chunk_indexObject

Returns the value of attribute chunk_index

Returns:

  • (Object)

    the current value of chunk_index



46
47
48
# File 'lib/kreuzberg/result.rb', line 46

def chunk_index
  @chunk_index
end

#chunk_typeObject

Returns the value of attribute chunk_type

Returns:

  • (Object)

    the current value of chunk_type



46
47
48
# File 'lib/kreuzberg/result.rb', line 46

def chunk_type
  @chunk_type
end

#contentString (readonly)

Returns Chunk content.

Returns:

  • (String)

    Chunk content



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#embeddingObject

Returns the value of attribute embedding

Returns:

  • (Object)

    the current value of embedding



46
47
48
# File 'lib/kreuzberg/result.rb', line 46

def embedding
  @embedding
end

#first_pageInteger? (readonly)

Returns First page number (1-indexed).

Returns:

  • (Integer, nil)

    First page number (1-indexed)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#last_pageInteger? (readonly)

Returns Last page number (1-indexed).

Returns:

  • (Integer, nil)

    Last page number (1-indexed)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#token_countInteger? (readonly)

Returns Approximate token count (may be nil).

Returns:

  • (Integer, nil)

    Approximate token count (may be nil)



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kreuzberg/result.rb', line 46

Chunk = Struct.new(
  :content,
  :byte_start,
  :byte_end,
  :token_count,
  :chunk_index,
  :total_chunks,
  :first_page,
  :last_page,
  :chunk_type,
  :embedding
) do
  def to_h
    {
      content: content,
      byte_start: byte_start,
      byte_end: byte_end,
      token_count: token_count,
      chunk_index: chunk_index,
      total_chunks: total_chunks,
      first_page: first_page,
      last_page: last_page,
      chunk_type: chunk_type,
      embedding: embedding
    }
  end
end

#total_chunksObject

Returns the value of attribute total_chunks

Returns:

  • (Object)

    the current value of total_chunks



46
47
48
# File 'lib/kreuzberg/result.rb', line 46

def total_chunks
  @total_chunks
end

Instance Method Details

#to_hObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/kreuzberg/result.rb', line 58

def to_h
  {
    content: content,
    byte_start: byte_start,
    byte_end: byte_end,
    token_count: token_count,
    chunk_index: chunk_index,
    total_chunks: total_chunks,
    first_page: first_page,
    last_page: last_page,
    chunk_type: chunk_type,
    embedding: embedding
  }
end