Skip to content

Commit

Permalink
Fix cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Moeki Kawakami committed Mar 9, 2024
1 parent 8f0b6cb commit 0a791f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/baran/text_splitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def chunks(text, metadata: nil)
chunk = { text: chunk, cursor: cursor }
chunk[:metadata] = metadata if metadata
chunks << chunk
cursor += chunk.length
cursor += chunk[:text].length
end

chunks
Expand Down
1 change: 1 addition & 0 deletions test/test_text_splitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_chunks

assert_equal 2, documents.size
assert_equal 'text', documents[0][:text]
assert_equal 4, documents[1][:cursor]
end

def test_chunks_with_metadata
Expand Down

0 comments on commit 0a791f2

Please sign in to comment.