llm_memory 0.1.11 → 0.1.12

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: c72d46a390a534d27ea5ee90bfb2950b75fd16f5320af2a431a314bcee13be30
4
- data.tar.gz: 974f529b0158cf5b4a8d4330dca59fe2fd3c2ee37cdca6465d98abee0f84db18
3
+ metadata.gz: 7d5876cf6c293ca2371eab3021704be2710c8b3d558e501543bde4acf6898595
4
+ data.tar.gz: 232d45abb20fb82b09b0f8ba6b22c12168d498cd8e23110d56446ae5265991aa
5
5
  SHA512:
6
- metadata.gz: 697d7a93bc637ec00004e68cd83dac1077e9705706e6b0123131acfaac201ce7979eeef63772bae35c53fa1b95ea7123f23399e5ee0ea1b454c689b6aa0f6a33
7
- data.tar.gz: ab67fd9ec6c1297b5308dfc28b9475bab46e28aa3b4f2af1694a9053ed7203c80e478320c11663a49583e43762814b85e0bdc52d2ea7002274a282609b1db9bd
6
+ metadata.gz: 128b6f275d904d2fafb8c7e0c1a26d33462edc015a33b1a3da6b4f1dc6f73ba51ae15f76f25d00221baa167956af06f1d5cd081fe8ab54e54b44c783c7380a98
7
+ data.tar.gz: 693ec575ca7b4add6b64afb6f3608a3ca6c989274c4f896aaf7520df5e82a0c051d062dd24bd6975a12c585bfaed91b6c4c1a96195e5f1831b05ee3c3679659a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- llm_memory (0.1.11)
4
+ llm_memory (0.1.12)
5
5
  redis (~> 4.6.0)
6
6
  ruby-openai (~> 3.7.0)
7
7
  tokenizers (~> 0.3.3)
data/README.md CHANGED
@@ -54,8 +54,10 @@ end
54
54
 
55
55
  To use LLM Memory, follow these steps:
56
56
 
57
+ If you want to use pgvector instead of Redisearch. You can use the plugin. Please check the doc and change the setup steps(2&3)
58
+
57
59
  1. Install the gem: gem install llm_memory
58
- 2. Set up Redis with Redisearch module enabled - Go to [Reids Cloud](https://redis.com/redis-enterprise-cloud/overview/) and get the redis url
60
+ 2. Set up Redis with Redisearch module enabled - Go to [Reids Cloud](https://redis.com/redis-enterprise-cloud/overview/) and get the redis url.
59
61
  3. Configure LLM Memory to connect to your Redis instance
60
62
  4. Use LlmMemory::Wernicke to load data from your external sources
61
63
  5. Use LlmMemory::Hippocampus to search for relevant information based on user queries
@@ -71,12 +73,13 @@ docs = LlmMemory::Wernicke.load(:file, "/tmp/a_directory")
71
73
  # docs = [{
72
74
  # content: "Hi there",
73
75
  # metadata: {
74
- # file_name: "a.txt"
76
+ # file_name: "a.txt",
77
+ # timestamp: "20201231235959"
75
78
  # }
76
79
  # },,,]
77
80
 
78
81
  hippocampus = LlmMemory::Hippocampus.new
79
- hippocampus.memorize(docs)
82
+ res = hippocampus.memorize(docs)
80
83
 
81
84
  query_str = "What is my name?"
82
85
  related_docs = hippocampus.query(query_str, limit: 3)
@@ -14,11 +14,13 @@ module LlmMemory
14
14
 
15
15
  file_name = File.basename(file_path)
16
16
  file_content = File.read(file_path)
17
+ ctime = File.ctime(file_path)
17
18
 
18
19
  files_array << {
19
20
  content: file_content,
20
21
  metadata: {
21
- file_name: file_name
22
+ file_name: file_name,
23
+ timestamp: ctime.strftime("%Y%m%d%H%M%S") # YYMMDDHHmmss
22
24
  }
23
25
  }
24
26
  end
@@ -79,7 +79,12 @@ module LlmMemory
79
79
  result = {}
80
80
  @client.pipelined do |pipeline|
81
81
  data.each_with_index do |d, i|
82
- key = "#{@index_name}:#{SecureRandom.uuid.delete("-")}"
82
+ key = @index_name # index_name:create_time:metadata_timestamp:uuid
83
+ timestamp = d.dig(:metadata, :timestamp)
84
+ key += ":#{Time.now.strftime("%Y%m%d%H%M%S")}"
85
+ key += ":#{timestamp}"
86
+ key += ":#{SecureRandom.hex(8)}"
87
+
83
88
  meta_json = d[:metadata].nil? ? "" : d[:metadata].to_json # serialize
84
89
  vector_value = d[:vector].map(&:to_f).pack("f*")
85
90
  pipeline.hset(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmMemory
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shohei Kameda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-02 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tokenizers