langchainrb_rails 0.1.8 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +31 -31
- data/lib/langchainrb_overrides/vectorsearch/pgvector.rb +1 -9
- data/lib/langchainrb_rails/active_record/hooks.rb +2 -0
- data/lib/langchainrb_rails/generators/langchainrb_rails/base_generator.rb +9 -0
- data/lib/langchainrb_rails/generators/langchainrb_rails/pgvector_generator.rb +2 -11
- data/lib/langchainrb_rails/generators/langchainrb_rails/templates/add_vector_column_template.rb.tt +1 -1
- data/lib/langchainrb_rails/generators/langchainrb_rails/templates/pgvector_initializer.rb.tt +1 -1
- data/lib/langchainrb_rails/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9763af7d92b1cd74c550438a35a65edd6030c247bfd676ae63808947a9214ca
|
4
|
+
data.tar.gz: 316642515d0fddc921fdc8f53b60ce75634ed2bc353e51280927f089c364d44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 496153be521fe4f50efceaf75e25ae0fec8ae1e78faf52987c6cb117eade71d14831ea75ccc69e7ec7cc6b3243a14330ac3b446507c51ab7db9b6064cdb19e4b
|
7
|
+
data.tar.gz: 3983b1c299076585a46f0f8f015d90e95dd2accd07757a551a5ff3ee00e47e2bb7a254cd5451b0e9cbab7093a0d1a0cb91f5a50edbd06b4894b39f83a299d3ca
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
langchainrb_rails (0.1.
|
5
|
-
langchainrb (>= 0.7, < 0.
|
4
|
+
langchainrb_rails (0.1.10)
|
5
|
+
langchainrb (>= 0.7, < 0.14)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -84,9 +84,9 @@ GEM
|
|
84
84
|
addressable (2.8.6)
|
85
85
|
public_suffix (>= 2.0.2, < 6.0)
|
86
86
|
ast (2.4.2)
|
87
|
-
baran (0.1.
|
87
|
+
baran (0.1.11)
|
88
88
|
base64 (0.2.0)
|
89
|
-
bigdecimal (3.1.
|
89
|
+
bigdecimal (3.1.7)
|
90
90
|
brakeman (6.1.2)
|
91
91
|
racc
|
92
92
|
builder (3.2.4)
|
@@ -101,28 +101,27 @@ GEM
|
|
101
101
|
crass (1.0.6)
|
102
102
|
date (3.3.4)
|
103
103
|
diff-lcs (1.5.1)
|
104
|
-
drb (2.2.
|
105
|
-
ruby2_keywords
|
104
|
+
drb (2.2.1)
|
106
105
|
erubi (1.12.0)
|
107
106
|
globalid (1.2.1)
|
108
107
|
activesupport (>= 6.1)
|
109
|
-
i18n (1.14.
|
108
|
+
i18n (1.14.4)
|
110
109
|
concurrent-ruby (~> 1.0)
|
111
110
|
io-console (0.7.2)
|
112
111
|
irb (1.11.2)
|
113
112
|
rdoc
|
114
113
|
reline (>= 0.4.2)
|
115
|
-
json (2.7.
|
116
|
-
json-schema (4.
|
114
|
+
json (2.7.2)
|
115
|
+
json-schema (4.3.0)
|
117
116
|
addressable (>= 2.8)
|
118
|
-
langchainrb (0.
|
117
|
+
langchainrb (0.11.4)
|
119
118
|
activesupport (>= 7.0.8)
|
120
119
|
baran (~> 0.1.9)
|
121
120
|
colorize (~> 1.1.0)
|
122
121
|
json-schema (~> 4)
|
123
122
|
matrix
|
124
123
|
pragmatic_segmenter (~> 0.3.0)
|
125
|
-
tiktoken_ruby (~> 0.0.
|
124
|
+
tiktoken_ruby (~> 0.0.8)
|
126
125
|
to_bool (~> 2.0.0)
|
127
126
|
zeitwerk (~> 2.5)
|
128
127
|
language_server-protocol (3.17.0.3)
|
@@ -139,8 +138,8 @@ GEM
|
|
139
138
|
matrix (0.4.2)
|
140
139
|
method_source (1.0.0)
|
141
140
|
mini_mime (1.1.5)
|
142
|
-
mini_portile2 (2.8.
|
143
|
-
minitest (5.22.
|
141
|
+
mini_portile2 (2.8.6)
|
142
|
+
minitest (5.22.3)
|
144
143
|
mutex_m (0.2.0)
|
145
144
|
net-imap (0.4.10)
|
146
145
|
date
|
@@ -152,15 +151,15 @@ GEM
|
|
152
151
|
net-smtp (0.4.0.1)
|
153
152
|
net-protocol
|
154
153
|
nio4r (2.7.0)
|
155
|
-
nokogiri (1.16.
|
154
|
+
nokogiri (1.16.5)
|
156
155
|
mini_portile2 (~> 2.8.2)
|
157
156
|
racc (~> 1.4)
|
158
|
-
nokogiri (1.16.
|
157
|
+
nokogiri (1.16.5-x86_64-darwin)
|
159
158
|
racc (~> 1.4)
|
160
|
-
nokogiri (1.16.
|
159
|
+
nokogiri (1.16.5-x86_64-linux)
|
161
160
|
racc (~> 1.4)
|
162
161
|
parallel (1.24.0)
|
163
|
-
parser (3.3.0
|
162
|
+
parser (3.3.1.0)
|
164
163
|
ast (~> 2.4.1)
|
165
164
|
racc
|
166
165
|
pragmatic_segmenter (0.3.23)
|
@@ -173,7 +172,7 @@ GEM
|
|
173
172
|
pry (>= 0.13, < 0.15)
|
174
173
|
psych (5.1.2)
|
175
174
|
stringio
|
176
|
-
public_suffix (5.0.
|
175
|
+
public_suffix (5.0.5)
|
177
176
|
racc (1.7.3)
|
178
177
|
rack (3.0.9.1)
|
179
178
|
rack-session (2.0.0)
|
@@ -213,14 +212,15 @@ GEM
|
|
213
212
|
thor (~> 1.0, >= 1.2.2)
|
214
213
|
zeitwerk (~> 2.6)
|
215
214
|
rainbow (3.1.1)
|
216
|
-
rake (13.1
|
217
|
-
rb_sys (0.9.
|
218
|
-
rdoc (6.6.
|
215
|
+
rake (13.2.1)
|
216
|
+
rb_sys (0.9.96)
|
217
|
+
rdoc (6.6.3.1)
|
219
218
|
psych (>= 4.0.0)
|
220
|
-
regexp_parser (2.9.
|
219
|
+
regexp_parser (2.9.1)
|
221
220
|
reline (0.4.3)
|
222
221
|
io-console (~> 0.5)
|
223
|
-
rexml (3.2.
|
222
|
+
rexml (3.2.8)
|
223
|
+
strscan (>= 3.0.9)
|
224
224
|
rspec (3.13.0)
|
225
225
|
rspec-core (~> 3.13.0)
|
226
226
|
rspec-expectations (~> 3.13.0)
|
@@ -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.63.5)
|
238
238
|
json (~> 2.3)
|
239
239
|
language_server-protocol (>= 3.17.0)
|
240
240
|
parallel (~> 1.10)
|
@@ -245,13 +245,12 @@ GEM
|
|
245
245
|
rubocop-ast (>= 1.31.1, < 2.0)
|
246
246
|
ruby-progressbar (~> 1.7)
|
247
247
|
unicode-display_width (>= 2.4.0, < 3.0)
|
248
|
-
rubocop-ast (1.31.
|
249
|
-
parser (>= 3.3.0
|
248
|
+
rubocop-ast (1.31.3)
|
249
|
+
parser (>= 3.3.1.0)
|
250
250
|
rubocop-performance (1.20.1)
|
251
251
|
rubocop (>= 1.48.1, < 2.0)
|
252
252
|
rubocop-ast (>= 1.30.0, < 2.0)
|
253
253
|
ruby-progressbar (1.13.0)
|
254
|
-
ruby2_keywords (0.0.5)
|
255
254
|
standard (1.34.0)
|
256
255
|
language_server-protocol (~> 3.17.0.2)
|
257
256
|
lint_roller (~> 1.0)
|
@@ -267,11 +266,12 @@ GEM
|
|
267
266
|
standardrb (1.0.1)
|
268
267
|
standard
|
269
268
|
stringio (3.1.0)
|
269
|
+
strscan (3.1.0)
|
270
270
|
thor (1.3.0)
|
271
|
-
tiktoken_ruby (0.0.
|
271
|
+
tiktoken_ruby (0.0.8)
|
272
272
|
rb_sys (>= 0.9.86)
|
273
|
-
tiktoken_ruby (0.0.
|
274
|
-
tiktoken_ruby (0.0.
|
273
|
+
tiktoken_ruby (0.0.8-x86_64-darwin)
|
274
|
+
tiktoken_ruby (0.0.8-x86_64-linux)
|
275
275
|
timeout (0.4.1)
|
276
276
|
to_bool (2.0.0)
|
277
277
|
tzinfo (2.0.6)
|
@@ -298,7 +298,7 @@ DEPENDENCIES
|
|
298
298
|
langchainrb_rails!
|
299
299
|
pry-byebug (~> 3.10.0)
|
300
300
|
rails (> 6.0.0)
|
301
|
-
rake (~> 13.
|
301
|
+
rake (~> 13.2)
|
302
302
|
rspec (~> 3.13)
|
303
303
|
rubocop
|
304
304
|
standardrb
|
@@ -15,14 +15,6 @@ module Langchain::Vectorsearch
|
|
15
15
|
# pgvector = Langchain::Vectorsearch::Pgvector.new(llm:)
|
16
16
|
#
|
17
17
|
|
18
|
-
# The operators supported by the PostgreSQL vector search adapter
|
19
|
-
OPERATORS = [
|
20
|
-
"cosine",
|
21
|
-
"euclidean",
|
22
|
-
"inner_product"
|
23
|
-
]
|
24
|
-
DEFAULT_OPERATOR = "cosine"
|
25
|
-
|
26
18
|
attr_reader :operator, :llm
|
27
19
|
attr_accessor :model
|
28
20
|
|
@@ -36,7 +28,7 @@ module Langchain::Vectorsearch
|
|
36
28
|
# These happen in the template files.
|
37
29
|
# depends_on "neighbor"
|
38
30
|
|
39
|
-
@operator = DEFAULT_OPERATOR
|
31
|
+
@operator = OPERATORS[DEFAULT_OPERATOR]
|
40
32
|
|
41
33
|
super(llm: llm)
|
42
34
|
end
|
@@ -112,6 +112,7 @@ module LangchainrbRails
|
|
112
112
|
# @param k [Integer] The number of results to have in context
|
113
113
|
# @yield [String] Stream responses back one String at a time
|
114
114
|
# @return [String] The answer to the question
|
115
|
+
# standard:disable Style/ArgumentsForwarding
|
115
116
|
def ask(question, k: 4, &block)
|
116
117
|
class_variable_get(:@@provider).ask(
|
117
118
|
question: question,
|
@@ -119,6 +120,7 @@ module LangchainrbRails
|
|
119
120
|
&block
|
120
121
|
).chat_completion
|
121
122
|
end
|
123
|
+
# standard:enable Style/ArgumentsForwarding
|
122
124
|
end
|
123
125
|
end
|
124
126
|
end
|
@@ -19,6 +19,15 @@ module LangchainrbRails
|
|
19
19
|
"openai" => "Langchain::LLM::OpenAI",
|
20
20
|
"replicate" => "Langchain::LLM::Replicate"
|
21
21
|
}
|
22
|
+
|
23
|
+
def post_install_message
|
24
|
+
say "Please do the following to start Q&A with your #{model_name} records:", :green
|
25
|
+
say "1. Run `bundle install` to install the new gems."
|
26
|
+
say "2. Set an environment variable ENV['#{llm.upcase}_API_KEY'] for your #{llm_class}."
|
27
|
+
say "3. Run `rails db:migrate` to apply the database migrations to enable pgvector and add the embedding column."
|
28
|
+
say "4. In Rails console, run `#{model_name}.embed!` to set the embeddings for all records."
|
29
|
+
say "5. Ask a question in the Rails console, ie: `#{model_name}.ask('[YOUR QUESTION]')`"
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -35,15 +35,6 @@ module LangchainrbRails
|
|
35
35
|
gem "ruby-openai"
|
36
36
|
end
|
37
37
|
|
38
|
-
def post_install_message
|
39
|
-
say "Please do the following to start Q&A with your #{model_name} records:", :green
|
40
|
-
say "1. Run `bundle install` to install the new gems."
|
41
|
-
say "2. Set `OPENAI_API_KEY` environment variable to your OpenAI API key."
|
42
|
-
say "3. Run `rails db:migrate` to apply the database migrations to enable pgvector and add the embedding column."
|
43
|
-
say "4. In Rails console, run `#{model_name}.embed!` to set the embeddings for all records."
|
44
|
-
say "5. Ask a question in the Rails console, ie: `#{model_name}.ask('[YOUR QUESTION]')`"
|
45
|
-
end
|
46
|
-
|
47
38
|
private
|
48
39
|
|
49
40
|
# @return [String] Name of the model
|
@@ -67,8 +58,8 @@ module LangchainrbRails
|
|
67
58
|
end
|
68
59
|
|
69
60
|
# @return [Integer] Dimension of the vector to be used
|
70
|
-
def
|
71
|
-
llm_class.
|
61
|
+
def vector_dimensions
|
62
|
+
llm_class.default_dimensions
|
72
63
|
end
|
73
64
|
end
|
74
65
|
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.
|
4
|
+
version: 0.1.10
|
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-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: langchainrb
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.7'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
22
|
+
version: '0.14'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '0.7'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '0.
|
32
|
+
version: '0.14'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: pry-byebug
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|