llm_memory_pgvector 0.1.2 → 0.1.3

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: 02a8d906cb751a0dffa89839cc7f293c970c618285c917ca5521ed9091f4cad0
4
- data.tar.gz: 7eeced97f49923746900caf68269041f93621f588cf743195aa4acdcdb725d8f
3
+ metadata.gz: aa1b3ab9226fa280c8655446df1fd45cb6a1dfc54779d1c5f71c4f407945fdd6
4
+ data.tar.gz: 8ae625dae794fbcb87bc915fbb766edbd0a09c5be0afe0c4be3e3ae76e757716
5
5
  SHA512:
6
- metadata.gz: c92ec2de76562dca9b5b3a8d0c0414858d58a73fc1cf43a575e96dd446016eb780f42ef4ae04354eec3bb63e615bef7f2efb4b6aae3a4faffc507e0a78efa781
7
- data.tar.gz: 8989283b6f74ffb336b479114aa3b5a43790442924f51582c5ab3e6402e7460fe3cabd466591877dfc6c9aaf0f95037a926c24fa8b506aa5ecfd2ce9b2ae3a35
6
+ metadata.gz: 65069e24e02fa4dca85c4cdbe0a018337ad511a5cc35a680d9ddb31b59d8c9ee0e409de8934a7fc641a477995ba1176f94bfce8e94a55aeae201653895a8bc22
7
+ data.tar.gz: bed6685f42c5129f75905a511e4ee78b0fbb546068be6f5fadb5e3ba7df2656333b50517a01c810703b4ee3971dc46475fa248d190ead3702e8ad76bdf6b21cf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- llm_memory_pgvector (0.1.1)
4
+ llm_memory_pgvector (0.1.3)
5
5
  llm_memory (~> 0.1.7)
6
6
  pg (~> 1.5.3)
7
7
  pgvector (~> 0.2.0)
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 UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORGg
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 UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install llm_memory_pgvector
16
14
 
17
15
  Plese don't forget to add `llm_memory`
18
16
 
@@ -41,6 +41,28 @@ 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
68
  data.each do |row|
@@ -49,6 +71,7 @@ module LlmMemoryPgvector
49
71
  [row[@content_key.to_sym], row[@metadata_key.to_sym].to_json, row[@vector_key.to_sym]]
50
72
  )
51
73
  end
74
+ list
52
75
  end
53
76
 
54
77
  def search(query: [], k: 3)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmMemoryPgvector
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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.2
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-05-18 00:00:00.000000000 Z
11
+ date: 2023-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: llm_memory