llm_memory_pgvector 0.1.1 → 0.1.3
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 +2 -4
- data/lib/llm_memory_pgvector/pgvector_store.rb +29 -8
- data/lib/llm_memory_pgvector/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: aa1b3ab9226fa280c8655446df1fd45cb6a1dfc54779d1c5f71c4f407945fdd6
|
4
|
+
data.tar.gz: 8ae625dae794fbcb87bc915fbb766edbd0a09c5be0afe0c4be3e3ae76e757716
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65069e24e02fa4dca85c4cdbe0a018337ad511a5cc35a680d9ddb31b59d8c9ee0e409de8934a7fc641a477995ba1176f94bfce8e94a55aeae201653895a8bc22
|
7
|
+
data.tar.gz: bed6685f42c5129f75905a511e4ee78b0fbb546068be6f5fadb5e3ba7df2656333b50517a01c810703b4ee3971dc46475fa248d190ead3702e8ad76bdf6b21cf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,15 +4,13 @@ This is a Ruby plugin for the [llm_memory](https://github.com/shohey1226/llm_mem
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
8
|
-
|
9
7
|
Install the gem and add to the application's Gemfile by executing:
|
10
8
|
|
11
|
-
$ bundle add
|
9
|
+
$ bundle add llm_memory_pgvector
|
12
10
|
|
13
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
12
|
|
15
|
-
$ gem install
|
13
|
+
$ gem install llm_memory_pgvector
|
16
14
|
|
17
15
|
Plese don't forget to add `llm_memory`
|
18
16
|
|
@@ -41,16 +41,37 @@ module LlmMemoryPgvector
|
|
41
41
|
@conn.exec("DROP TABLE IF EXISTS #{@index_name}")
|
42
42
|
end
|
43
43
|
|
44
|
+
def list(ids = [])
|
45
|
+
result = if ids.empty?
|
46
|
+
@conn.exec("SELECT * FROM #{@index_name}")
|
47
|
+
else
|
48
|
+
placeholders = ids.map.with_index(1) { |_, i| "$#{i}" }.join(",")
|
49
|
+
@conn.exec_params("SELECT * FROM #{@index_name} WHERE id IN (#{placeholders})", ids)
|
50
|
+
end
|
51
|
+
result.entries
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete(id)
|
55
|
+
result = @conn.exec_params("DELETE FROM #{@index_name} WHERE id = $1", [id])
|
56
|
+
result.cmd_tuples > 0
|
57
|
+
end
|
58
|
+
|
59
|
+
def delete_all
|
60
|
+
@conn.exec("DELETE FROM #{@index_name}")
|
61
|
+
true
|
62
|
+
rescue PG::Error
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
44
66
|
# data = [{ content: "", vector: [], metadata: {} },,]
|
45
67
|
def add(data: [])
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@conn.exec(sql)
|
68
|
+
data.each do |row|
|
69
|
+
@conn.exec_params(
|
70
|
+
"INSERT INTO #{@index_name} (#{@content_key}, #{@metadata_key}, #{@vector_key}) VALUES ($1, $2, $3)",
|
71
|
+
[row[@content_key.to_sym], row[@metadata_key.to_sym].to_json, row[@vector_key.to_sym]]
|
72
|
+
)
|
73
|
+
end
|
74
|
+
list
|
54
75
|
end
|
55
76
|
|
56
77
|
def search(query: [], k: 3)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: llm_memory_pgvector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2023-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: llm_memory
|