langchainrb_rails 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +90 -89
- data/lib/langchainrb_overrides/vectorsearch/pgvector.rb +1 -1
- data/lib/langchainrb_rails/active_record/hooks.rb +4 -2
- data/lib/langchainrb_rails/version.rb +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 262c77cc37284572d2ae586351fa8a0de84ab842df2b6145263bb36387107ef6
|
4
|
+
data.tar.gz: 663f5528780513d3480696f93505146be9d3735e35f5e4da55c33d552d375687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3ccaedef7d42260d76d5c923300f466195d981285617f811d0888273134db9d8e23ce3cbb2e994f6f0c3352e7364da9a2256fa9004bd5a06b01c14e79a4ece
|
7
|
+
data.tar.gz: 47cbfcfc417a4fca10742a6484d9f379f3003c1f97ca6720e3d04937dc7cd3a32332682c160c0f6c727a5ade5e843a685d58c50faa237d812eeee3ad90b99f03
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.2.2
|
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.
|
5
|
-
langchainrb (
|
4
|
+
langchainrb_rails (0.1.6)
|
5
|
+
langchainrb (>= 0.7, < 0.10)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (7.1.
|
11
|
-
actionpack (= 7.1.
|
12
|
-
activesupport (= 7.1.
|
10
|
+
actioncable (7.1.3)
|
11
|
+
actionpack (= 7.1.3)
|
12
|
+
activesupport (= 7.1.3)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
15
|
zeitwerk (~> 2.6)
|
16
|
-
actionmailbox (7.1.
|
17
|
-
actionpack (= 7.1.
|
18
|
-
activejob (= 7.1.
|
19
|
-
activerecord (= 7.1.
|
20
|
-
activestorage (= 7.1.
|
21
|
-
activesupport (= 7.1.
|
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)
|
22
22
|
mail (>= 2.7.1)
|
23
23
|
net-imap
|
24
24
|
net-pop
|
25
25
|
net-smtp
|
26
|
-
actionmailer (7.1.
|
27
|
-
actionpack (= 7.1.
|
28
|
-
actionview (= 7.1.
|
29
|
-
activejob (= 7.1.
|
30
|
-
activesupport (= 7.1.
|
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)
|
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.
|
37
|
-
actionview (= 7.1.
|
38
|
-
activesupport (= 7.1.
|
36
|
+
actionpack (7.1.3)
|
37
|
+
actionview (= 7.1.3)
|
38
|
+
activesupport (= 7.1.3)
|
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.
|
47
|
-
actionpack (= 7.1.
|
48
|
-
activerecord (= 7.1.
|
49
|
-
activestorage (= 7.1.
|
50
|
-
activesupport (= 7.1.
|
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)
|
51
51
|
globalid (>= 0.6.0)
|
52
52
|
nokogiri (>= 1.8.5)
|
53
|
-
actionview (7.1.
|
54
|
-
activesupport (= 7.1.
|
53
|
+
actionview (7.1.3)
|
54
|
+
activesupport (= 7.1.3)
|
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.
|
60
|
-
activesupport (= 7.1.
|
59
|
+
activejob (7.1.3)
|
60
|
+
activesupport (= 7.1.3)
|
61
61
|
globalid (>= 0.3.6)
|
62
|
-
activemodel (7.1.
|
63
|
-
activesupport (= 7.1.
|
64
|
-
activerecord (7.1.
|
65
|
-
activemodel (= 7.1.
|
66
|
-
activesupport (= 7.1.
|
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)
|
67
67
|
timeout (>= 0.4.0)
|
68
|
-
activestorage (7.1.
|
69
|
-
actionpack (= 7.1.
|
70
|
-
activejob (= 7.1.
|
71
|
-
activerecord (= 7.1.
|
72
|
-
activesupport (= 7.1.
|
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)
|
73
73
|
marcel (~> 1.0)
|
74
|
-
activesupport (7.1.
|
74
|
+
activesupport (7.1.3)
|
75
75
|
base64
|
76
76
|
bigdecimal
|
77
77
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -81,13 +81,14 @@ GEM
|
|
81
81
|
minitest (>= 5.1)
|
82
82
|
mutex_m
|
83
83
|
tzinfo (~> 2.0)
|
84
|
-
addressable (2.8.
|
84
|
+
addressable (2.8.6)
|
85
85
|
public_suffix (>= 2.0.2, < 6.0)
|
86
86
|
ast (2.4.2)
|
87
87
|
baran (0.1.10)
|
88
88
|
base64 (0.2.0)
|
89
|
-
bigdecimal (3.1.
|
90
|
-
brakeman (6.
|
89
|
+
bigdecimal (3.1.6)
|
90
|
+
brakeman (6.1.1)
|
91
|
+
racc
|
91
92
|
builder (3.2.4)
|
92
93
|
bundler-audit (0.9.1)
|
93
94
|
bundler (>= 1.2.0, < 3)
|
@@ -95,7 +96,7 @@ GEM
|
|
95
96
|
byebug (11.1.3)
|
96
97
|
coderay (1.1.3)
|
97
98
|
colorize (0.8.1)
|
98
|
-
concurrent-ruby (1.2.
|
99
|
+
concurrent-ruby (1.2.3)
|
99
100
|
connection_pool (2.4.1)
|
100
101
|
crass (1.0.6)
|
101
102
|
date (3.3.4)
|
@@ -107,14 +108,14 @@ GEM
|
|
107
108
|
activesupport (>= 6.1)
|
108
109
|
i18n (1.14.1)
|
109
110
|
concurrent-ruby (~> 1.0)
|
110
|
-
io-console (0.
|
111
|
-
irb (1.
|
111
|
+
io-console (0.7.2)
|
112
|
+
irb (1.11.1)
|
112
113
|
rdoc
|
113
|
-
reline (>= 0.
|
114
|
-
json (2.
|
114
|
+
reline (>= 0.4.2)
|
115
|
+
json (2.7.1)
|
115
116
|
json-schema (4.0.0)
|
116
117
|
addressable (>= 2.8)
|
117
|
-
langchainrb (0.
|
118
|
+
langchainrb (0.9.0)
|
118
119
|
baran (~> 0.1.9)
|
119
120
|
colorize (~> 0.8.1)
|
120
121
|
json-schema (~> 4.0.0)
|
@@ -125,7 +126,7 @@ GEM
|
|
125
126
|
zeitwerk (~> 2.5)
|
126
127
|
language_server-protocol (3.17.0.3)
|
127
128
|
lint_roller (1.1.0)
|
128
|
-
loofah (2.
|
129
|
+
loofah (2.22.0)
|
129
130
|
crass (~> 1.0.2)
|
130
131
|
nokogiri (>= 1.12.0)
|
131
132
|
mail (2.8.1)
|
@@ -138,26 +139,26 @@ GEM
|
|
138
139
|
method_source (1.0.0)
|
139
140
|
mini_mime (1.1.5)
|
140
141
|
mini_portile2 (2.8.5)
|
141
|
-
minitest (5.
|
142
|
+
minitest (5.21.2)
|
142
143
|
mutex_m (0.2.0)
|
143
|
-
net-imap (0.4.
|
144
|
+
net-imap (0.4.9.1)
|
144
145
|
date
|
145
146
|
net-protocol
|
146
147
|
net-pop (0.1.2)
|
147
148
|
net-protocol
|
148
149
|
net-protocol (0.2.2)
|
149
150
|
timeout
|
150
|
-
net-smtp (0.4.0)
|
151
|
+
net-smtp (0.4.0.1)
|
151
152
|
net-protocol
|
152
|
-
nio4r (2.
|
153
|
-
nokogiri (1.
|
153
|
+
nio4r (2.7.0)
|
154
|
+
nokogiri (1.16.0)
|
154
155
|
mini_portile2 (~> 2.8.2)
|
155
156
|
racc (~> 1.4)
|
156
|
-
nokogiri (1.
|
157
|
+
nokogiri (1.16.0-x86_64-darwin)
|
157
158
|
racc (~> 1.4)
|
158
|
-
nokogiri (1.
|
159
|
+
nokogiri (1.16.0-x86_64-linux)
|
159
160
|
racc (~> 1.4)
|
160
|
-
parallel (1.
|
161
|
+
parallel (1.24.0)
|
161
162
|
parser (3.2.2.4)
|
162
163
|
ast (~> 2.4.1)
|
163
164
|
racc
|
@@ -169,7 +170,7 @@ GEM
|
|
169
170
|
pry-byebug (3.10.1)
|
170
171
|
byebug (~> 11.0)
|
171
172
|
pry (>= 0.13, < 0.15)
|
172
|
-
psych (5.1.
|
173
|
+
psych (5.1.2)
|
173
174
|
stringio
|
174
175
|
public_suffix (5.0.4)
|
175
176
|
racc (1.7.3)
|
@@ -181,20 +182,20 @@ GEM
|
|
181
182
|
rackup (2.1.0)
|
182
183
|
rack (>= 3)
|
183
184
|
webrick (~> 1.8)
|
184
|
-
rails (7.1.
|
185
|
-
actioncable (= 7.1.
|
186
|
-
actionmailbox (= 7.1.
|
187
|
-
actionmailer (= 7.1.
|
188
|
-
actionpack (= 7.1.
|
189
|
-
actiontext (= 7.1.
|
190
|
-
actionview (= 7.1.
|
191
|
-
activejob (= 7.1.
|
192
|
-
activemodel (= 7.1.
|
193
|
-
activerecord (= 7.1.
|
194
|
-
activestorage (= 7.1.
|
195
|
-
activesupport (= 7.1.
|
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)
|
196
197
|
bundler (>= 1.15.0)
|
197
|
-
railties (= 7.1.
|
198
|
+
railties (= 7.1.3)
|
198
199
|
rails-dom-testing (2.2.0)
|
199
200
|
activesupport (>= 5.0.0)
|
200
201
|
minitest
|
@@ -202,9 +203,9 @@ GEM
|
|
202
203
|
rails-html-sanitizer (1.6.0)
|
203
204
|
loofah (~> 2.21)
|
204
205
|
nokogiri (~> 1.14)
|
205
|
-
railties (7.1.
|
206
|
-
actionpack (= 7.1.
|
207
|
-
activesupport (= 7.1.
|
206
|
+
railties (7.1.3)
|
207
|
+
actionpack (= 7.1.3)
|
208
|
+
activesupport (= 7.1.3)
|
208
209
|
irb
|
209
210
|
rackup (>= 1.0.0)
|
210
211
|
rake (>= 12.2)
|
@@ -212,11 +213,11 @@ GEM
|
|
212
213
|
zeitwerk (~> 2.6)
|
213
214
|
rainbow (3.1.1)
|
214
215
|
rake (13.1.0)
|
215
|
-
rb_sys (0.9.
|
216
|
-
rdoc (6.6.
|
216
|
+
rb_sys (0.9.87)
|
217
|
+
rdoc (6.6.2)
|
217
218
|
psych (>= 4.0.0)
|
218
|
-
regexp_parser (2.8.
|
219
|
-
reline (0.4.
|
219
|
+
regexp_parser (2.8.3)
|
220
|
+
reline (0.4.2)
|
220
221
|
io-console (~> 0.5)
|
221
222
|
rexml (3.2.6)
|
222
223
|
rspec (3.12.0)
|
@@ -232,7 +233,7 @@ GEM
|
|
232
233
|
diff-lcs (>= 1.2.0, < 2.0)
|
233
234
|
rspec-support (~> 3.12.0)
|
234
235
|
rspec-support (3.12.1)
|
235
|
-
rubocop (1.
|
236
|
+
rubocop (1.59.0)
|
236
237
|
json (~> 2.3)
|
237
238
|
language_server-protocol (>= 3.17.0)
|
238
239
|
parallel (~> 1.10)
|
@@ -240,31 +241,31 @@ GEM
|
|
240
241
|
rainbow (>= 2.2.2, < 4.0)
|
241
242
|
regexp_parser (>= 1.8, < 3.0)
|
242
243
|
rexml (>= 3.2.5, < 4.0)
|
243
|
-
rubocop-ast (>= 1.
|
244
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
244
245
|
ruby-progressbar (~> 1.7)
|
245
246
|
unicode-display_width (>= 2.4.0, < 3.0)
|
246
247
|
rubocop-ast (1.30.0)
|
247
248
|
parser (>= 3.2.1.0)
|
248
|
-
rubocop-performance (1.
|
249
|
-
rubocop (>= 1.
|
250
|
-
rubocop-ast (>=
|
249
|
+
rubocop-performance (1.20.1)
|
250
|
+
rubocop (>= 1.48.1, < 2.0)
|
251
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
251
252
|
ruby-progressbar (1.13.0)
|
252
253
|
ruby2_keywords (0.0.5)
|
253
|
-
standard (1.
|
254
|
+
standard (1.33.0)
|
254
255
|
language_server-protocol (~> 3.17.0.2)
|
255
256
|
lint_roller (~> 1.0)
|
256
|
-
rubocop (~> 1.
|
257
|
+
rubocop (~> 1.59.0)
|
257
258
|
standard-custom (~> 1.0.0)
|
258
|
-
standard-performance (~> 1.
|
259
|
+
standard-performance (~> 1.3)
|
259
260
|
standard-custom (1.0.2)
|
260
261
|
lint_roller (~> 1.0)
|
261
262
|
rubocop (~> 1.50)
|
262
|
-
standard-performance (1.
|
263
|
+
standard-performance (1.3.0)
|
263
264
|
lint_roller (~> 1.1)
|
264
|
-
rubocop-performance (~> 1.
|
265
|
+
rubocop-performance (~> 1.20.1)
|
265
266
|
standardrb (1.0.1)
|
266
267
|
standard
|
267
|
-
stringio (3.0
|
268
|
+
stringio (3.1.0)
|
268
269
|
thor (1.3.0)
|
269
270
|
tiktoken_ruby (0.0.6)
|
270
271
|
rb_sys (~> 0.9.68)
|
@@ -105,7 +105,7 @@ module Langchain::Vectorsearch
|
|
105
105
|
# @param k [Integer] The number of results to have in context
|
106
106
|
# @yield [String] Stream responses back one String at a time
|
107
107
|
# @return [String] The answer to the question
|
108
|
-
def ask(question
|
108
|
+
def ask(question:, k: 4, &block)
|
109
109
|
# Noisy as the embedding column has a lot of data
|
110
110
|
ActiveRecord::Base.logger.silence do
|
111
111
|
search_results = similarity_search(query: question, k: k)
|
@@ -71,12 +71,12 @@ module LangchainrbRails
|
|
71
71
|
#
|
72
72
|
# @param provider [Object] The `Langchain::Vectorsearch::*` instance
|
73
73
|
def vectorsearch
|
74
|
-
class_variable_set(:@@provider, LangchainrbRails.config.vectorsearch)
|
74
|
+
class_variable_set(:@@provider, LangchainrbRails.config.vectorsearch.dup)
|
75
75
|
|
76
76
|
# Pgvector-specific configuration
|
77
77
|
if LangchainrbRails.config.vectorsearch.is_a?(Langchain::Vectorsearch::Pgvector)
|
78
78
|
has_neighbors(:embedding)
|
79
|
-
|
79
|
+
class_variable_get(:@@provider).model = self
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -99,6 +99,8 @@ module LangchainrbRails
|
|
99
99
|
k: k
|
100
100
|
)
|
101
101
|
|
102
|
+
return records if LangchainrbRails.config.vectorsearch.is_a?(Langchain::Vectorsearch::Pgvector)
|
103
|
+
|
102
104
|
# We use "__id" when Weaviate is the provider
|
103
105
|
ids = records.map { |record| record.try("id") || record.dig("__id") }
|
104
106
|
where(id: ids)
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: langchainrb
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
22
|
+
version: '0.10'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.7'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
32
|
+
version: '0.10'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: pry-byebug
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
129
|
- !ruby/object:Gem::Version
|
124
130
|
version: '0'
|
125
131
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.4.10
|
127
133
|
signing_key:
|
128
134
|
specification_version: 4
|
129
135
|
summary: Rails wrapper for langchainrb gem
|