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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -3
- data/lib/llm_memory/loaders/file_loader.rb +3 -1
- data/lib/llm_memory/stores/redis_store.rb +6 -1
- data/lib/llm_memory/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5876cf6c293ca2371eab3021704be2710c8b3d558e501543bde4acf6898595
|
4
|
+
data.tar.gz: 232d45abb20fb82b09b0f8ba6b22c12168d498cd8e23110d56446ae5265991aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 128b6f275d904d2fafb8c7e0c1a26d33462edc015a33b1a3da6b4f1dc6f73ba51ae15f76f25d00221baa167956af06f1d5cd081fe8ab54e54b44c783c7380a98
|
7
|
+
data.tar.gz: 693ec575ca7b4add6b64afb6f3608a3ca6c989274c4f896aaf7520df5e82a0c051d062dd24bd6975a12c585bfaed91b6c4c1a96195e5f1831b05ee3c3679659a
|
data/Gemfile.lock
CHANGED
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 =
|
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(
|
data/lib/llm_memory/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tokenizers
|