langchainrb_rails 0.1.10 → 0.1.11

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: f9763af7d92b1cd74c550438a35a65edd6030c247bfd676ae63808947a9214ca
4
- data.tar.gz: 316642515d0fddc921fdc8f53b60ce75634ed2bc353e51280927f089c364d44b
3
+ metadata.gz: ac7837afbfe4347fbafa41c1cec9f9c6c14a3efe938e75ae611a2ec986a5fe64
4
+ data.tar.gz: 55b1a04a984a306d1fdea91c0975b0b4f14a91f0035848032c573f2defdc1b6f
5
5
  SHA512:
6
- metadata.gz: 496153be521fe4f50efceaf75e25ae0fec8ae1e78faf52987c6cb117eade71d14831ea75ccc69e7ec7cc6b3243a14330ac3b446507c51ab7db9b6064cdb19e4b
7
- data.tar.gz: 3983b1c299076585a46f0f8f015d90e95dd2accd07757a551a5ff3ee00e47e2bb7a254cd5451b0e9cbab7093a0d1a0cb91f5a50edbd06b4894b39f83a299d3ca
6
+ metadata.gz: 795dd248bf74cfa20e45d2457d43e1833a538a5c399854f41fede624c82fe44d1c7f8e9d7a877776492770910e2431293ab8ab824e447ff2c37aebddc0bef1ac
7
+ data.tar.gz: ed8a5c720b6420e5ae8bb9a51b51c11909afd32e6e1726a084554609096a9d051d7da59df4bb06f0fb343f18540843c375a6840db685f3774ccb82e926c2314b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.11] - 2024-06-16
4
+ - Add destroy_from_vectorsearch hook
5
+
6
+ ## [0.1.10] - 2024-05-20
7
+
3
8
  ## [0.1.9] - 2024-04-19
4
9
  - Bump langchainrb gem to include v0.11.x
5
10
  - Remove pg_vector Overriding Operator Constants
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- langchainrb_rails (0.1.10)
4
+ langchainrb_rails (0.1.11)
5
5
  langchainrb (>= 0.7, < 0.14)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.1.3.2)
11
- actionpack (= 7.1.3.2)
12
- activesupport (= 7.1.3.2)
10
+ actioncable (7.1.3.4)
11
+ actionpack (= 7.1.3.4)
12
+ activesupport (= 7.1.3.4)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
15
  zeitwerk (~> 2.6)
16
- actionmailbox (7.1.3.2)
17
- actionpack (= 7.1.3.2)
18
- activejob (= 7.1.3.2)
19
- activerecord (= 7.1.3.2)
20
- activestorage (= 7.1.3.2)
21
- activesupport (= 7.1.3.2)
16
+ actionmailbox (7.1.3.4)
17
+ actionpack (= 7.1.3.4)
18
+ activejob (= 7.1.3.4)
19
+ activerecord (= 7.1.3.4)
20
+ activestorage (= 7.1.3.4)
21
+ activesupport (= 7.1.3.4)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.1.3.2)
27
- actionpack (= 7.1.3.2)
28
- actionview (= 7.1.3.2)
29
- activejob (= 7.1.3.2)
30
- activesupport (= 7.1.3.2)
26
+ actionmailer (7.1.3.4)
27
+ actionpack (= 7.1.3.4)
28
+ actionview (= 7.1.3.4)
29
+ activejob (= 7.1.3.4)
30
+ activesupport (= 7.1.3.4)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.2)
36
- actionpack (7.1.3.2)
37
- actionview (= 7.1.3.2)
38
- activesupport (= 7.1.3.2)
36
+ actionpack (7.1.3.4)
37
+ actionview (= 7.1.3.4)
38
+ activesupport (= 7.1.3.4)
39
39
  nokogiri (>= 1.8.5)
40
40
  racc
41
41
  rack (>= 2.2.4)
@@ -43,35 +43,35 @@ GEM
43
43
  rack-test (>= 0.6.3)
44
44
  rails-dom-testing (~> 2.2)
45
45
  rails-html-sanitizer (~> 1.6)
46
- actiontext (7.1.3.2)
47
- actionpack (= 7.1.3.2)
48
- activerecord (= 7.1.3.2)
49
- activestorage (= 7.1.3.2)
50
- activesupport (= 7.1.3.2)
46
+ actiontext (7.1.3.4)
47
+ actionpack (= 7.1.3.4)
48
+ activerecord (= 7.1.3.4)
49
+ activestorage (= 7.1.3.4)
50
+ activesupport (= 7.1.3.4)
51
51
  globalid (>= 0.6.0)
52
52
  nokogiri (>= 1.8.5)
53
- actionview (7.1.3.2)
54
- activesupport (= 7.1.3.2)
53
+ actionview (7.1.3.4)
54
+ activesupport (= 7.1.3.4)
55
55
  builder (~> 3.1)
56
56
  erubi (~> 1.11)
57
57
  rails-dom-testing (~> 2.2)
58
58
  rails-html-sanitizer (~> 1.6)
59
- activejob (7.1.3.2)
60
- activesupport (= 7.1.3.2)
59
+ activejob (7.1.3.4)
60
+ activesupport (= 7.1.3.4)
61
61
  globalid (>= 0.3.6)
62
- activemodel (7.1.3.2)
63
- activesupport (= 7.1.3.2)
64
- activerecord (7.1.3.2)
65
- activemodel (= 7.1.3.2)
66
- activesupport (= 7.1.3.2)
62
+ activemodel (7.1.3.4)
63
+ activesupport (= 7.1.3.4)
64
+ activerecord (7.1.3.4)
65
+ activemodel (= 7.1.3.4)
66
+ activesupport (= 7.1.3.4)
67
67
  timeout (>= 0.4.0)
68
- activestorage (7.1.3.2)
69
- actionpack (= 7.1.3.2)
70
- activejob (= 7.1.3.2)
71
- activerecord (= 7.1.3.2)
72
- activesupport (= 7.1.3.2)
68
+ activestorage (7.1.3.4)
69
+ actionpack (= 7.1.3.4)
70
+ activejob (= 7.1.3.4)
71
+ activerecord (= 7.1.3.4)
72
+ activesupport (= 7.1.3.4)
73
73
  marcel (~> 1.0)
74
- activesupport (7.1.3.2)
74
+ activesupport (7.1.3.4)
75
75
  base64
76
76
  bigdecimal
77
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -86,17 +86,17 @@ GEM
86
86
  ast (2.4.2)
87
87
  baran (0.1.11)
88
88
  base64 (0.2.0)
89
- bigdecimal (3.1.7)
89
+ bigdecimal (3.1.8)
90
90
  brakeman (6.1.2)
91
91
  racc
92
- builder (3.2.4)
92
+ builder (3.3.0)
93
93
  bundler-audit (0.9.1)
94
94
  bundler (>= 1.2.0, < 3)
95
95
  thor (~> 1.0)
96
96
  byebug (11.1.3)
97
97
  coderay (1.1.3)
98
98
  colorize (1.1.0)
99
- concurrent-ruby (1.2.3)
99
+ concurrent-ruby (1.3.3)
100
100
  connection_pool (2.4.1)
101
101
  crass (1.0.6)
102
102
  date (3.3.4)
@@ -105,11 +105,11 @@ GEM
105
105
  erubi (1.12.0)
106
106
  globalid (1.2.1)
107
107
  activesupport (>= 6.1)
108
- i18n (1.14.4)
108
+ i18n (1.14.5)
109
109
  concurrent-ruby (~> 1.0)
110
110
  io-console (0.7.2)
111
- irb (1.11.2)
112
- rdoc
111
+ irb (1.13.1)
112
+ rdoc (>= 4.0.0)
113
113
  reline (>= 0.4.2)
114
114
  json (2.7.2)
115
115
  json-schema (4.3.0)
@@ -134,23 +134,23 @@ GEM
134
134
  net-imap
135
135
  net-pop
136
136
  net-smtp
137
- marcel (1.0.2)
137
+ marcel (1.0.4)
138
138
  matrix (0.4.2)
139
139
  method_source (1.0.0)
140
140
  mini_mime (1.1.5)
141
- mini_portile2 (2.8.6)
142
- minitest (5.22.3)
141
+ mini_portile2 (2.8.7)
142
+ minitest (5.23.1)
143
143
  mutex_m (0.2.0)
144
- net-imap (0.4.10)
144
+ net-imap (0.4.12)
145
145
  date
146
146
  net-protocol
147
147
  net-pop (0.1.2)
148
148
  net-protocol
149
149
  net-protocol (0.2.2)
150
150
  timeout
151
- net-smtp (0.4.0.1)
151
+ net-smtp (0.5.0)
152
152
  net-protocol
153
- nio4r (2.7.0)
153
+ nio4r (2.7.3)
154
154
  nokogiri (1.16.5)
155
155
  mini_portile2 (~> 2.8.2)
156
156
  racc (~> 1.4)
@@ -173,8 +173,8 @@ GEM
173
173
  psych (5.1.2)
174
174
  stringio
175
175
  public_suffix (5.0.5)
176
- racc (1.7.3)
177
- rack (3.0.9.1)
176
+ racc (1.8.0)
177
+ rack (3.0.11)
178
178
  rack-session (2.0.0)
179
179
  rack (>= 3.0.0)
180
180
  rack-test (2.1.0)
@@ -182,20 +182,20 @@ GEM
182
182
  rackup (2.1.0)
183
183
  rack (>= 3)
184
184
  webrick (~> 1.8)
185
- rails (7.1.3.2)
186
- actioncable (= 7.1.3.2)
187
- actionmailbox (= 7.1.3.2)
188
- actionmailer (= 7.1.3.2)
189
- actionpack (= 7.1.3.2)
190
- actiontext (= 7.1.3.2)
191
- actionview (= 7.1.3.2)
192
- activejob (= 7.1.3.2)
193
- activemodel (= 7.1.3.2)
194
- activerecord (= 7.1.3.2)
195
- activestorage (= 7.1.3.2)
196
- activesupport (= 7.1.3.2)
185
+ rails (7.1.3.4)
186
+ actioncable (= 7.1.3.4)
187
+ actionmailbox (= 7.1.3.4)
188
+ actionmailer (= 7.1.3.4)
189
+ actionpack (= 7.1.3.4)
190
+ actiontext (= 7.1.3.4)
191
+ actionview (= 7.1.3.4)
192
+ activejob (= 7.1.3.4)
193
+ activemodel (= 7.1.3.4)
194
+ activerecord (= 7.1.3.4)
195
+ activestorage (= 7.1.3.4)
196
+ activesupport (= 7.1.3.4)
197
197
  bundler (>= 1.15.0)
198
- railties (= 7.1.3.2)
198
+ railties (= 7.1.3.4)
199
199
  rails-dom-testing (2.2.0)
200
200
  activesupport (>= 5.0.0)
201
201
  minitest
@@ -203,9 +203,9 @@ GEM
203
203
  rails-html-sanitizer (1.6.0)
204
204
  loofah (~> 2.21)
205
205
  nokogiri (~> 1.14)
206
- railties (7.1.3.2)
207
- actionpack (= 7.1.3.2)
208
- activesupport (= 7.1.3.2)
206
+ railties (7.1.3.4)
207
+ actionpack (= 7.1.3.4)
208
+ activesupport (= 7.1.3.4)
209
209
  irb
210
210
  rackup (>= 1.0.0)
211
211
  rake (>= 12.2)
@@ -214,10 +214,10 @@ GEM
214
214
  rainbow (3.1.1)
215
215
  rake (13.2.1)
216
216
  rb_sys (0.9.96)
217
- rdoc (6.6.3.1)
217
+ rdoc (6.7.0)
218
218
  psych (>= 4.0.0)
219
- regexp_parser (2.9.1)
220
- reline (0.4.3)
219
+ regexp_parser (2.9.2)
220
+ reline (0.5.8)
221
221
  io-console (~> 0.5)
222
222
  rexml (3.2.8)
223
223
  strscan (>= 3.0.9)
@@ -234,7 +234,7 @@ GEM
234
234
  diff-lcs (>= 1.2.0, < 2.0)
235
235
  rspec-support (~> 3.13.0)
236
236
  rspec-support (3.13.0)
237
- rubocop (1.63.5)
237
+ rubocop (1.64.0)
238
238
  json (~> 2.3)
239
239
  language_server-protocol (>= 3.17.0)
240
240
  parallel (~> 1.10)
@@ -267,7 +267,7 @@ GEM
267
267
  standard
268
268
  stringio (3.1.0)
269
269
  strscan (3.1.0)
270
- thor (1.3.0)
270
+ thor (1.3.1)
271
271
  tiktoken_ruby (0.0.8)
272
272
  rb_sys (>= 0.9.86)
273
273
  tiktoken_ruby (0.0.8-x86_64-darwin)
@@ -283,7 +283,7 @@ GEM
283
283
  websocket-extensions (>= 0.1.0)
284
284
  websocket-extensions (0.1.5)
285
285
  yard (0.9.36)
286
- zeitwerk (2.6.13)
286
+ zeitwerk (2.6.15)
287
287
 
288
288
  PLATFORMS
289
289
  ruby
@@ -55,6 +55,16 @@ module Langchain::Vectorsearch
55
55
  add_texts(texts: texts, ids: ids)
56
56
  end
57
57
 
58
+ # Remove vectors from the index
59
+ #
60
+ # @param ids [Array<String>] The ids of the vectors to remove
61
+ # @return [Boolean] true
62
+ def remove_texts(ids:)
63
+ # Since the record is being destroyed and the `embedding` is a column on the record,
64
+ # we don't need to do anything here.
65
+ true
66
+ end
67
+
58
68
  # Invoke a rake task that will create an initializer (`config/initializers/langchain.rb`) file
59
69
  # and db/migrations/* files
60
70
  def create_default_schema
@@ -6,12 +6,14 @@ module LangchainrbRails
6
6
  # * `vectorsearch` class method to set the vector search provider
7
7
  # * `similarity_search` class method to search for similar texts
8
8
  # * `upsert_to_vectorsearch` instance method to upsert the record to the vector search provider
9
+ # * `destroy_from_vectorsearch` instance method to remove the record from the vector search provider
9
10
  #
10
11
  # Usage:
11
12
  # class Recipe < ActiveRecord::Base
12
13
  # vectorsearch
13
14
  #
14
15
  # after_save :upsert_to_vectorsearch
16
+ # after_destroy :destroy_from_vectorsearch
15
17
  #
16
18
  # # Overwriting how the model is serialized before it's indexed
17
19
  # def as_vector
@@ -56,6 +58,17 @@ module LangchainrbRails
56
58
  end
57
59
  end
58
60
 
61
+ # Remove the record from the vector search provider
62
+ # This method should be called in an ActiveRecord `after_destroy` callback
63
+ #
64
+ # @return [Boolean] true
65
+ # @raise [Error] Removing from vector search DB failed
66
+ def destroy_from_vectorsearch
67
+ self.class.class_variable_get(:@@provider).remove_texts(
68
+ ids: [id]
69
+ )
70
+ end
71
+
59
72
  # Used to serialize the DB record to an indexable vector text
60
73
  # Overwrite this method in your model to customize
61
74
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LangchainrbRails
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: langchainrb_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-20 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: langchainrb