llm_memory 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85f3330ed767cc28b5a3276a7772678c36726ce04562c184a4e6dcf287d14d1d
4
- data.tar.gz: 3e1ae83b2517f7f80bb857de5024b62b886bb6a045428f2d40159e48818cf286
3
+ metadata.gz: 072b5fa983000a18bccb6e5d0185663cbb30547a0fd6cc6194e1d4235ae833fb
4
+ data.tar.gz: 7233ecf0cbbb254b08cbf7d1fe747b8374e1e3baa3b6214a1ba5fa64ecd0360d
5
5
  SHA512:
6
- metadata.gz: dba158d07c4a97a5b2e6bb1a98987173ba427a18a1a06d0a422f366ab2f7335ac168aea0351657b0c7f957352e6ffe747a2d817deb7c8d5454010c2ec535999a
7
- data.tar.gz: 1db3ccb501f3b56d6e6dc00997f3f085b74f395521ffbbc1775bc5799bc388410523f6f209cfc185efbbf1437177c07dd5ee1725a49f6a27b207c6fc296067aa
6
+ metadata.gz: 9e670ee60c3e780343317d2b2175ea5cf9fefdaa8b4ce81b13ec1b32caa3cbd13ad4363dec63ebaabf803e434897eb34a21d4b4e0b37b60bb4b3ff22b6a9a80c
7
+ data.tar.gz: e4defb25011469c10b36c6d4b98763dcb56a673eaedb2709741769de0fc888a8d30e4301f5444c88dbb07c31b8a290ae0fbfae584d9d93a21c6c7ce34d96c40b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- llm_memory (0.1.3)
4
+ llm_memory (0.1.4)
5
5
  redis (~> 4.6.0)
6
6
  ruby-openai (~> 3.7.0)
7
7
  tiktoken_ruby (~> 0.0.4)
@@ -23,7 +23,7 @@ module LlmMemory
23
23
  raise "Store '#{store_name}' not found." unless store_class
24
24
  @store = store_class.new(index_name: index_name)
25
25
 
26
- # word count, not char count
26
+ # char count, not word count
27
27
  @chunk_size = chunk_size
28
28
  @chunk_overlap = chunk_overlap
29
29
  end
@@ -87,18 +87,14 @@ module LlmMemory
87
87
  docs.each do |item|
88
88
  content = item[:content]
89
89
  metadata = item[:metadata]
90
- words = content.split
91
-
92
- if words.length > @chunk_size
90
+ if content.length > @chunk_size
93
91
  start_index = 0
94
-
95
- while start_index < words.length
96
- end_index = [start_index + @chunk_size, words.length].min
97
- chunk_words = words[start_index...end_index]
98
- chunk = chunk_words.join(" ")
92
+ while start_index < content.length
93
+ end_index = [start_index + @chunk_size, content.length].min
94
+ chunk = content[start_index...end_index]
99
95
  result << {content: chunk, metadata: metadata}
100
-
101
- start_index += @chunk_size - @chunk_overlap # Move index to create a overlap
96
+ break if end_index == content.length
97
+ start_index += @chunk_size - @chunk_overlap
102
98
  end
103
99
  else
104
100
  result << {content: content, metadata: metadata}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmMemory
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shohei Kameda