langchainrb_rails 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +74 -74
- data/lib/langchainrb_overrides/vectorsearch/pgvector.rb +10 -0
- data/lib/langchainrb_rails/active_record/hooks.rb +13 -0
- data/lib/langchainrb_rails/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: ac7837afbfe4347fbafa41c1cec9f9c6c14a3efe938e75ae611a2ec986a5fe64
|
|
4
|
+
data.tar.gz: 55b1a04a984a306d1fdea91c0975b0b4f14a91f0035848032c573f2defdc1b6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 795dd248bf74cfa20e45d2457d43e1833a538a5c399854f41fede624c82fe44d1c7f8e9d7a877776492770910e2431293ab8ab824e447ff2c37aebddc0bef1ac
|
|
7
|
+
data.tar.gz: ed8a5c720b6420e5ae8bb9a51b51c11909afd32e6e1726a084554609096a9d051d7da59df4bb06f0fb343f18540843c375a6840db685f3774ccb82e926c2314b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
langchainrb_rails (0.1.
|
|
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.
|
|
11
|
-
actionpack (= 7.1.3.
|
|
12
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
17
|
-
actionpack (= 7.1.3.
|
|
18
|
-
activejob (= 7.1.3.
|
|
19
|
-
activerecord (= 7.1.3.
|
|
20
|
-
activestorage (= 7.1.3.
|
|
21
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
27
|
-
actionpack (= 7.1.3.
|
|
28
|
-
actionview (= 7.1.3.
|
|
29
|
-
activejob (= 7.1.3.
|
|
30
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
37
|
-
actionview (= 7.1.3.
|
|
38
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
47
|
-
actionpack (= 7.1.3.
|
|
48
|
-
activerecord (= 7.1.3.
|
|
49
|
-
activestorage (= 7.1.3.
|
|
50
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
54
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
60
|
-
activesupport (= 7.1.3.
|
|
59
|
+
activejob (7.1.3.4)
|
|
60
|
+
activesupport (= 7.1.3.4)
|
|
61
61
|
globalid (>= 0.3.6)
|
|
62
|
-
activemodel (7.1.3.
|
|
63
|
-
activesupport (= 7.1.3.
|
|
64
|
-
activerecord (7.1.3.
|
|
65
|
-
activemodel (= 7.1.3.
|
|
66
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
69
|
-
actionpack (= 7.1.3.
|
|
70
|
-
activejob (= 7.1.3.
|
|
71
|
-
activerecord (= 7.1.3.
|
|
72
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
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.
|
|
89
|
+
bigdecimal (3.1.8)
|
|
90
90
|
brakeman (6.1.2)
|
|
91
91
|
racc
|
|
92
|
-
builder (3.
|
|
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.
|
|
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.
|
|
108
|
+
i18n (1.14.5)
|
|
109
109
|
concurrent-ruby (~> 1.0)
|
|
110
110
|
io-console (0.7.2)
|
|
111
|
-
irb (1.
|
|
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.
|
|
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.
|
|
142
|
-
minitest (5.
|
|
141
|
+
mini_portile2 (2.8.7)
|
|
142
|
+
minitest (5.23.1)
|
|
143
143
|
mutex_m (0.2.0)
|
|
144
|
-
net-imap (0.4.
|
|
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.
|
|
151
|
+
net-smtp (0.5.0)
|
|
152
152
|
net-protocol
|
|
153
|
-
nio4r (2.7.
|
|
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.
|
|
177
|
-
rack (3.0.
|
|
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.
|
|
186
|
-
actioncable (= 7.1.3.
|
|
187
|
-
actionmailbox (= 7.1.3.
|
|
188
|
-
actionmailer (= 7.1.3.
|
|
189
|
-
actionpack (= 7.1.3.
|
|
190
|
-
actiontext (= 7.1.3.
|
|
191
|
-
actionview (= 7.1.3.
|
|
192
|
-
activejob (= 7.1.3.
|
|
193
|
-
activemodel (= 7.1.3.
|
|
194
|
-
activerecord (= 7.1.3.
|
|
195
|
-
activestorage (= 7.1.3.
|
|
196
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
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.
|
|
207
|
-
actionpack (= 7.1.3.
|
|
208
|
-
activesupport (= 7.1.3.
|
|
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.
|
|
217
|
+
rdoc (6.7.0)
|
|
218
218
|
psych (>= 4.0.0)
|
|
219
|
-
regexp_parser (2.9.
|
|
220
|
-
reline (0.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
#
|
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.
|
|
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-
|
|
11
|
+
date: 2024-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: langchainrb
|