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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bb3982f419d252f6e94018548685566d9775993ad6349957211a4d686e9a10c
4
- data.tar.gz: 783c3d1683d654903f745aa6b1fd973787b03581792a1292a0d5724c6983eda8
3
+ metadata.gz: 262c77cc37284572d2ae586351fa8a0de84ab842df2b6145263bb36387107ef6
4
+ data.tar.gz: 663f5528780513d3480696f93505146be9d3735e35f5e4da55c33d552d375687
5
5
  SHA512:
6
- metadata.gz: f1fe4ad36c5c12c7260cff5bf29046330d2e649a0f8d96707b13831f09c2c185cf88c5a202f3621eb03cb87fae1df6f7bb75a6bdac5cd9471a4e4637daaafa5f
7
- data.tar.gz: f0effcbf9679194a32ece6ff84cc26cf0c5cea5956c9a51ee1a33ba3e32bf4ea56807bba9a463b9edc227d1cb572508bfad70e3a1e8063c5f374e12e1e97d834
6
+ metadata.gz: cf3ccaedef7d42260d76d5c923300f466195d981285617f811d0888273134db9d8e23ce3cbb2e994f6f0c3352e7364da9a2256fa9004bd5a06b01c14e79a4ece
7
+ data.tar.gz: 47cbfcfc417a4fca10742a6484d9f379f3003c1f97ca6720e3d04937dc7cd3a32332682c160c0f6c727a5ade5e843a685d58c50faa237d812eeee3ad90b99f03
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.1.2
1
+ ruby 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.6] - 2023-01-25
4
+ - Fix bug when multiple ActiveRecord models use vectorsearch
5
+ - Bump langchainrb version
6
+ - Avoid extra query when Pgvector is used
7
+
3
8
  ## [0.1.5] - 2023-11-30
4
9
  - Qdrant vectorsearch generator
5
10
 
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- langchainrb_rails (0.1.5)
5
- langchainrb (~> 0.7.0)
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.2)
11
- actionpack (= 7.1.2)
12
- activesupport (= 7.1.2)
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.2)
17
- actionpack (= 7.1.2)
18
- activejob (= 7.1.2)
19
- activerecord (= 7.1.2)
20
- activestorage (= 7.1.2)
21
- activesupport (= 7.1.2)
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.2)
27
- actionpack (= 7.1.2)
28
- actionview (= 7.1.2)
29
- activejob (= 7.1.2)
30
- activesupport (= 7.1.2)
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.2)
37
- actionview (= 7.1.2)
38
- activesupport (= 7.1.2)
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.2)
47
- actionpack (= 7.1.2)
48
- activerecord (= 7.1.2)
49
- activestorage (= 7.1.2)
50
- activesupport (= 7.1.2)
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.2)
54
- activesupport (= 7.1.2)
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.2)
60
- activesupport (= 7.1.2)
59
+ activejob (7.1.3)
60
+ activesupport (= 7.1.3)
61
61
  globalid (>= 0.3.6)
62
- activemodel (7.1.2)
63
- activesupport (= 7.1.2)
64
- activerecord (7.1.2)
65
- activemodel (= 7.1.2)
66
- activesupport (= 7.1.2)
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.2)
69
- actionpack (= 7.1.2)
70
- activejob (= 7.1.2)
71
- activerecord (= 7.1.2)
72
- activesupport (= 7.1.2)
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.2)
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.5)
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.4)
90
- brakeman (6.0.1)
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.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.6.0)
111
- irb (1.9.0)
111
+ io-console (0.7.2)
112
+ irb (1.11.1)
112
113
  rdoc
113
- reline (>= 0.3.8)
114
- json (2.6.3)
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.7.5)
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.21.4)
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.20.0)
142
+ minitest (5.21.2)
142
143
  mutex_m (0.2.0)
143
- net-imap (0.4.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.5.9)
153
- nokogiri (1.15.4)
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.15.4-x86_64-darwin)
157
+ nokogiri (1.16.0-x86_64-darwin)
157
158
  racc (~> 1.4)
158
- nokogiri (1.15.4-x86_64-linux)
159
+ nokogiri (1.16.0-x86_64-linux)
159
160
  racc (~> 1.4)
160
- parallel (1.23.0)
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.1.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.2)
185
- actioncable (= 7.1.2)
186
- actionmailbox (= 7.1.2)
187
- actionmailer (= 7.1.2)
188
- actionpack (= 7.1.2)
189
- actiontext (= 7.1.2)
190
- actionview (= 7.1.2)
191
- activejob (= 7.1.2)
192
- activemodel (= 7.1.2)
193
- activerecord (= 7.1.2)
194
- activestorage (= 7.1.2)
195
- activesupport (= 7.1.2)
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.2)
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.2)
206
- actionpack (= 7.1.2)
207
- activesupport (= 7.1.2)
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.83)
216
- rdoc (6.6.0)
216
+ rb_sys (0.9.87)
217
+ rdoc (6.6.2)
217
218
  psych (>= 4.0.0)
218
- regexp_parser (2.8.2)
219
- reline (0.4.0)
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.57.2)
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.28.1, < 2.0)
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.19.1)
249
- rubocop (>= 1.7.0, < 2.0)
250
- rubocop-ast (>= 0.4.0)
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.32.0)
254
+ standard (1.33.0)
254
255
  language_server-protocol (~> 3.17.0.2)
255
256
  lint_roller (~> 1.0)
256
- rubocop (~> 1.57.2)
257
+ rubocop (~> 1.59.0)
257
258
  standard-custom (~> 1.0.0)
258
- standard-performance (~> 1.2)
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.2.1)
263
+ standard-performance (1.3.0)
263
264
  lint_roller (~> 1.1)
264
- rubocop-performance (~> 1.19.1)
265
+ rubocop-performance (~> 1.20.1)
265
266
  standardrb (1.0.1)
266
267
  standard
267
- stringio (3.0.9)
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, k: 4, &block)
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
- LangchainrbRails.config.vectorsearch.model = self
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LangchainrbRails
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
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.5
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: 2023-11-30 00:00:00.000000000 Z
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.7.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.7.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.3.7
132
+ rubygems_version: 3.4.10
127
133
  signing_key:
128
134
  specification_version: 4
129
135
  summary: Rails wrapper for langchainrb gem