bx_builder_chain 0.1.6 → 0.1.7
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/Gemfile +6 -1
- data/Gemfile.lock +155 -1
- data/Rakefile +103 -0
- data/lib/bx_builder_chain/version.rb +1 -1
- data/lib/generators/bx_builder_chain/templates/app/controllers/bx_builder_chain/documents_controller.rb +14 -21
- data/lib/generators/bx_builder_chain/templates/app/models/bx_builder_chain/document.rb +2 -0
- data/lib/pgvector/pg.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: 2f1c1f9ea5cdc963d3fb3b18014d5a41d5fd02f95e29b5e35ce513430b5f65e3
|
4
|
+
data.tar.gz: b193911735fd53950dad77a3809d33f6200212e9ef47ef146ba54977c179c1ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8b367eb68dd0b967d38c5877b4c293a193e263e7fb4408c7ad81a8ce6404199ba07f1dd88dbe1043e96aed57918d36090b0355173aa0d9c95bb966d40aaa041
|
7
|
+
data.tar.gz: 5311cc6046109e3a016cbc24aaba5d0741117af9a5d609606696279bc983d00b2d2b733566852cfaf0d6d44d4c77a8a44bde6c0b9edbf0feaada3fe0e58095d3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bx_builder_chain (0.1.
|
4
|
+
bx_builder_chain (0.1.6)
|
5
5
|
baran (= 0.1.7)
|
6
6
|
docx (~> 0.8.0)
|
7
7
|
dotenv (~> 2.8)
|
@@ -17,25 +17,122 @@ GEM
|
|
17
17
|
remote: https://rubygems.org/
|
18
18
|
specs:
|
19
19
|
Ascii85 (1.1.0)
|
20
|
+
actioncable (6.1.7.6)
|
21
|
+
actionpack (= 6.1.7.6)
|
22
|
+
activesupport (= 6.1.7.6)
|
23
|
+
nio4r (~> 2.0)
|
24
|
+
websocket-driver (>= 0.6.1)
|
25
|
+
actionmailbox (6.1.7.6)
|
26
|
+
actionpack (= 6.1.7.6)
|
27
|
+
activejob (= 6.1.7.6)
|
28
|
+
activerecord (= 6.1.7.6)
|
29
|
+
activestorage (= 6.1.7.6)
|
30
|
+
activesupport (= 6.1.7.6)
|
31
|
+
mail (>= 2.7.1)
|
32
|
+
actionmailer (6.1.7.6)
|
33
|
+
actionpack (= 6.1.7.6)
|
34
|
+
actionview (= 6.1.7.6)
|
35
|
+
activejob (= 6.1.7.6)
|
36
|
+
activesupport (= 6.1.7.6)
|
37
|
+
mail (~> 2.5, >= 2.5.4)
|
38
|
+
rails-dom-testing (~> 2.0)
|
39
|
+
actionpack (6.1.7.6)
|
40
|
+
actionview (= 6.1.7.6)
|
41
|
+
activesupport (= 6.1.7.6)
|
42
|
+
rack (~> 2.0, >= 2.0.9)
|
43
|
+
rack-test (>= 0.6.3)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
46
|
+
actiontext (6.1.7.6)
|
47
|
+
actionpack (= 6.1.7.6)
|
48
|
+
activerecord (= 6.1.7.6)
|
49
|
+
activestorage (= 6.1.7.6)
|
50
|
+
activesupport (= 6.1.7.6)
|
51
|
+
nokogiri (>= 1.8.5)
|
52
|
+
actionview (6.1.7.6)
|
53
|
+
activesupport (= 6.1.7.6)
|
54
|
+
builder (~> 3.1)
|
55
|
+
erubi (~> 1.4)
|
56
|
+
rails-dom-testing (~> 2.0)
|
57
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
58
|
+
activejob (6.1.7.6)
|
59
|
+
activesupport (= 6.1.7.6)
|
60
|
+
globalid (>= 0.3.6)
|
61
|
+
activemodel (6.1.7.6)
|
62
|
+
activesupport (= 6.1.7.6)
|
63
|
+
activerecord (6.1.7.6)
|
64
|
+
activemodel (= 6.1.7.6)
|
65
|
+
activesupport (= 6.1.7.6)
|
66
|
+
activestorage (6.1.7.6)
|
67
|
+
actionpack (= 6.1.7.6)
|
68
|
+
activejob (= 6.1.7.6)
|
69
|
+
activerecord (= 6.1.7.6)
|
70
|
+
activesupport (= 6.1.7.6)
|
71
|
+
marcel (~> 1.0)
|
72
|
+
mini_mime (>= 1.1.0)
|
73
|
+
activesupport (6.1.7.6)
|
74
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
75
|
+
i18n (>= 1.6, < 2)
|
76
|
+
minitest (>= 5.1)
|
77
|
+
tzinfo (~> 2.0)
|
78
|
+
zeitwerk (~> 2.3)
|
20
79
|
afm (0.2.2)
|
21
80
|
ast (2.4.2)
|
22
81
|
baran (0.1.7)
|
82
|
+
builder (3.2.4)
|
23
83
|
coderay (1.1.3)
|
84
|
+
concurrent-ruby (1.2.2)
|
85
|
+
crass (1.0.6)
|
86
|
+
database_cleaner (2.0.2)
|
87
|
+
database_cleaner-active_record (>= 2, < 3)
|
88
|
+
database_cleaner-active_record (2.1.0)
|
89
|
+
activerecord (>= 5.a)
|
90
|
+
database_cleaner-core (~> 2.0.0)
|
91
|
+
database_cleaner-core (2.0.1)
|
92
|
+
date (3.3.3)
|
24
93
|
diff-lcs (1.5.0)
|
25
94
|
docx (0.8.0)
|
26
95
|
nokogiri (~> 1.13, >= 1.13.0)
|
27
96
|
rubyzip (~> 2.0)
|
28
97
|
dotenv (2.8.1)
|
98
|
+
erubi (1.12.0)
|
99
|
+
fakeredis (0.9.2)
|
100
|
+
redis (~> 4.8)
|
29
101
|
faraday (2.7.10)
|
30
102
|
faraday-net_http (>= 2.0, < 3.1)
|
31
103
|
ruby2_keywords (>= 0.0.4)
|
32
104
|
faraday-multipart (1.0.4)
|
33
105
|
multipart-post (~> 2)
|
34
106
|
faraday-net_http (3.0.2)
|
107
|
+
globalid (1.2.1)
|
108
|
+
activesupport (>= 6.1)
|
35
109
|
hashery (2.1.2)
|
110
|
+
i18n (1.14.1)
|
111
|
+
concurrent-ruby (~> 1.0)
|
36
112
|
json (2.6.3)
|
113
|
+
loofah (2.21.3)
|
114
|
+
crass (~> 1.0.2)
|
115
|
+
nokogiri (>= 1.12.0)
|
116
|
+
mail (2.8.1)
|
117
|
+
mini_mime (>= 0.1.1)
|
118
|
+
net-imap
|
119
|
+
net-pop
|
120
|
+
net-smtp
|
121
|
+
marcel (1.0.2)
|
37
122
|
method_source (1.0.0)
|
123
|
+
mini_mime (1.1.5)
|
124
|
+
minitest (5.20.0)
|
38
125
|
multipart-post (2.3.0)
|
126
|
+
net-imap (0.3.7)
|
127
|
+
date
|
128
|
+
net-protocol
|
129
|
+
net-pop (0.1.2)
|
130
|
+
net-protocol
|
131
|
+
net-protocol (0.2.1)
|
132
|
+
timeout
|
133
|
+
net-smtp (0.3.3)
|
134
|
+
net-protocol
|
135
|
+
nio4r (2.5.9)
|
39
136
|
nokogiri (1.13.10-arm64-darwin)
|
40
137
|
racc (~> 1.4)
|
41
138
|
parallel (1.23.0)
|
@@ -53,8 +150,39 @@ GEM
|
|
53
150
|
coderay (~> 1.1)
|
54
151
|
method_source (~> 1.0)
|
55
152
|
racc (1.7.1)
|
153
|
+
rack (2.2.8)
|
154
|
+
rack-test (2.1.0)
|
155
|
+
rack (>= 1.3)
|
156
|
+
rails (6.1.7.6)
|
157
|
+
actioncable (= 6.1.7.6)
|
158
|
+
actionmailbox (= 6.1.7.6)
|
159
|
+
actionmailer (= 6.1.7.6)
|
160
|
+
actionpack (= 6.1.7.6)
|
161
|
+
actiontext (= 6.1.7.6)
|
162
|
+
actionview (= 6.1.7.6)
|
163
|
+
activejob (= 6.1.7.6)
|
164
|
+
activemodel (= 6.1.7.6)
|
165
|
+
activerecord (= 6.1.7.6)
|
166
|
+
activestorage (= 6.1.7.6)
|
167
|
+
activesupport (= 6.1.7.6)
|
168
|
+
bundler (>= 1.15.0)
|
169
|
+
railties (= 6.1.7.6)
|
170
|
+
sprockets-rails (>= 2.0.0)
|
171
|
+
rails-dom-testing (2.2.0)
|
172
|
+
activesupport (>= 5.0.0)
|
173
|
+
minitest
|
174
|
+
nokogiri (>= 1.6)
|
175
|
+
rails-html-sanitizer (1.5.0)
|
176
|
+
loofah (~> 2.19, >= 2.19.1)
|
177
|
+
railties (6.1.7.6)
|
178
|
+
actionpack (= 6.1.7.6)
|
179
|
+
activesupport (= 6.1.7.6)
|
180
|
+
method_source
|
181
|
+
rake (>= 12.2)
|
182
|
+
thor (~> 1.0)
|
56
183
|
rainbow (3.1.1)
|
57
184
|
rake (13.0.6)
|
185
|
+
redis (4.8.1)
|
58
186
|
regexp_parser (2.8.1)
|
59
187
|
rexml (3.2.6)
|
60
188
|
roo (2.8.3)
|
@@ -72,6 +200,14 @@ GEM
|
|
72
200
|
rspec-mocks (3.12.6)
|
73
201
|
diff-lcs (>= 1.2.0, < 2.0)
|
74
202
|
rspec-support (~> 3.12.0)
|
203
|
+
rspec-rails (6.0.3)
|
204
|
+
actionpack (>= 6.1)
|
205
|
+
activesupport (>= 6.1)
|
206
|
+
railties (>= 6.1)
|
207
|
+
rspec-core (~> 3.12)
|
208
|
+
rspec-expectations (~> 3.12)
|
209
|
+
rspec-mocks (~> 3.12)
|
210
|
+
rspec-support (~> 3.12)
|
75
211
|
rspec-support (3.12.1)
|
76
212
|
rubocop (1.50.2)
|
77
213
|
json (~> 2.3)
|
@@ -93,8 +229,22 @@ GEM
|
|
93
229
|
ruby2_keywords (0.0.5)
|
94
230
|
rubyzip (2.3.2)
|
95
231
|
sequel (5.71.0)
|
232
|
+
sprockets (4.2.1)
|
233
|
+
concurrent-ruby (~> 1.0)
|
234
|
+
rack (>= 2.2.4, < 4)
|
235
|
+
sprockets-rails (3.4.2)
|
236
|
+
actionpack (>= 5.2)
|
237
|
+
activesupport (>= 5.2)
|
238
|
+
sprockets (>= 3.0.0)
|
239
|
+
thor (1.2.2)
|
240
|
+
timeout (0.4.0)
|
96
241
|
ttfunk (1.7.0)
|
242
|
+
tzinfo (2.0.6)
|
243
|
+
concurrent-ruby (~> 1.0)
|
97
244
|
unicode-display_width (2.4.2)
|
245
|
+
websocket-driver (0.7.6)
|
246
|
+
websocket-extensions (>= 0.1.0)
|
247
|
+
websocket-extensions (0.1.5)
|
98
248
|
zeitwerk (2.6.11)
|
99
249
|
|
100
250
|
PLATFORMS
|
@@ -103,15 +253,19 @@ PLATFORMS
|
|
103
253
|
DEPENDENCIES
|
104
254
|
baran
|
105
255
|
bx_builder_chain!
|
256
|
+
database_cleaner
|
106
257
|
docx
|
107
258
|
dotenv
|
259
|
+
fakeredis
|
108
260
|
nokogiri
|
109
261
|
pdf-reader
|
110
262
|
pg
|
111
263
|
pry
|
264
|
+
rails
|
112
265
|
rake (~> 13.0)
|
113
266
|
roo
|
114
267
|
rspec (~> 3.0)
|
268
|
+
rspec-rails
|
115
269
|
rubocop (~> 1.21)
|
116
270
|
ruby-openai
|
117
271
|
sequel (~> 5.71)
|
data/Rakefile
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
|
+
require 'fileutils'
|
6
|
+
require "dotenv"
|
7
|
+
|
8
|
+
Dotenv.load
|
5
9
|
|
6
10
|
RSpec::Core::RakeTask.new(:spec)
|
7
11
|
|
@@ -10,3 +14,102 @@ require "rubocop/rake_task"
|
|
10
14
|
RuboCop::RakeTask.new
|
11
15
|
|
12
16
|
task default: %i[spec rubocop]
|
17
|
+
|
18
|
+
namespace :test do
|
19
|
+
desc "Creates a dummy Rails app for testing"
|
20
|
+
task :dummy_rails do
|
21
|
+
require 'rails'
|
22
|
+
|
23
|
+
puts "Creating Rails Test App"
|
24
|
+
dummy_path = File.expand_path("spec/dummy", __dir__)
|
25
|
+
system("rm -rf #{dummy_path}") if File.directory?(dummy_path)
|
26
|
+
|
27
|
+
rails_version = Rails::VERSION::STRING
|
28
|
+
rails_new_command = "rails _#{rails_version}_ new #{dummy_path} --skip-bundle --skip-git --skip-keeps --skip-action-mailbox --skip-action-mailer --skip-action-text --skip-active-storage --skip-action-cable --skip-puma --skip-bootsnap --skip-spring --skip-listen --skip-javascript --skip-turbolinks --skip-test --skip-system-test --quiet"
|
29
|
+
unless system(rails_new_command)
|
30
|
+
puts "Error while installing Rails Test App. Exiting."
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
# Copy .env across
|
35
|
+
env_source_path = File.expand_path(".env", __dir__)
|
36
|
+
env_dest_path = File.join(dummy_path, ".env")
|
37
|
+
|
38
|
+
# Check if the source .env file exists and then copy
|
39
|
+
if File.exist?(env_source_path)
|
40
|
+
FileUtils.cp(env_source_path, env_dest_path)
|
41
|
+
puts "Copied .env file to the dummy Rails app."
|
42
|
+
else
|
43
|
+
puts "No .env file found in the gem root directory."
|
44
|
+
end
|
45
|
+
|
46
|
+
# remove the asset pipeline initializer file
|
47
|
+
puts 'Removing assets initializer...'
|
48
|
+
assets_file_path = File.expand_path("spec/dummy/config/initializers/assets.rb")
|
49
|
+
File.delete(assets_file_path) if File.exist?(assets_file_path)
|
50
|
+
|
51
|
+
|
52
|
+
puts "Adding gems"
|
53
|
+
# adding gem
|
54
|
+
gemfile_path = "#{dummy_path}/Gemfile"
|
55
|
+
open(gemfile_path, 'a') do |f|
|
56
|
+
f.puts "\ngem 'bx_builder_chain', path: '#{File.expand_path('../../', dummy_path)}'"
|
57
|
+
f.puts "\ngem 'pg'"
|
58
|
+
end
|
59
|
+
|
60
|
+
unless system("cd #{dummy_path} && bundle install")
|
61
|
+
puts "Error while installing gems. Exiting."
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
|
65
|
+
puts "Generating builder chain rails files"
|
66
|
+
# Installing Gems
|
67
|
+
unless system("cd #{dummy_path} && bundle exec rails g bx_builder_chain:install")
|
68
|
+
puts "Error while Generating builder chain rails files. Exiting."
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "\nUpdating DB config"
|
73
|
+
# Update db config
|
74
|
+
database_config_path = File.join(dummy_path, 'config', 'database.yml')
|
75
|
+
|
76
|
+
# Create a hash for the new database configuration
|
77
|
+
pg_config = '
|
78
|
+
default: &default
|
79
|
+
adapter: postgresql
|
80
|
+
encoding: unicode
|
81
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
82
|
+
timeout: 5000
|
83
|
+
host: <%= ENV.fetch("DB_HOSTNAME") { "localhost" } %>
|
84
|
+
username: <%= ENV.fetch("DB_USER") { "postgres" } %>
|
85
|
+
password: <%= ENV.fetch("DB_PASSWORD") { "password" } %>
|
86
|
+
port: <%= ENV.fetch("DB_PORT") { "5432" } %>
|
87
|
+
|
88
|
+
development:
|
89
|
+
<<: *default
|
90
|
+
database: <%= ENV.fetch("DB_NAME") { "dev_db" } %>
|
91
|
+
|
92
|
+
test:
|
93
|
+
<<: *default
|
94
|
+
database: <%= ENV.fetch("DB_NAME") { "test_db" } %>
|
95
|
+
|
96
|
+
production:
|
97
|
+
<<: *default
|
98
|
+
database: <%= ENV.fetch("DB_NAME") { "prod_db" } %>
|
99
|
+
'
|
100
|
+
|
101
|
+
# Write the new configuration to database.yml
|
102
|
+
File.open(database_config_path, 'w') do |f|
|
103
|
+
f.write pg_config
|
104
|
+
end
|
105
|
+
|
106
|
+
puts "Setting up DB"
|
107
|
+
# Installing Gems
|
108
|
+
unless system("cd #{dummy_path} && bundle exec rails db:create && bundle exec rails db:migrate")
|
109
|
+
puts "Error while setting up the db. Exiting."
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
puts "Created dummy Rails app in spec/dummy"
|
114
|
+
end
|
115
|
+
end
|
@@ -13,25 +13,27 @@ module BxBuilderChain
|
|
13
13
|
def delete_documents
|
14
14
|
return render json: { error: 'No document IDs provided' }, status: :bad_request unless params[:ids].present?
|
15
15
|
|
16
|
-
# Filter documents by the provided IDs and the namespace from the current user groups
|
17
16
|
documents_to_delete = BxBuilderChain::Document.where(id: params[:ids], namespace: current_user_document_groups.first)
|
18
|
-
|
19
|
-
# Destroy the documents
|
20
17
|
documents_to_delete.destroy_all
|
21
18
|
|
22
19
|
render json: { success: 'Documents deleted successfully' }
|
23
20
|
end
|
24
21
|
|
25
22
|
def upload_and_process
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
llm_class_name: LLM_CLASS_NAME # optional defaults to 'BxBuilderChain::Llm::OpenAi'
|
31
|
-
)
|
23
|
+
result = document_service.upload_and_process
|
24
|
+
|
25
|
+
render_result(result)
|
26
|
+
end
|
32
27
|
|
33
|
-
|
28
|
+
def upload_and_process_later
|
29
|
+
result = document_service.upload_and_process_later
|
30
|
+
|
31
|
+
render_result(result)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
34
35
|
|
36
|
+
def render_result(result)
|
35
37
|
if result[:error]
|
36
38
|
render json: { error: result[:error] }, status: :bad_request
|
37
39
|
else
|
@@ -39,24 +41,15 @@ module BxBuilderChain
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
43
|
-
service
|
44
|
+
def document_service
|
45
|
+
@service ||= DocumentUploadService.new(
|
44
46
|
files: params[:files],
|
45
47
|
current_user_groups: current_user_document_groups,
|
46
48
|
client_class_name: CLIENT_CLASS_NAME,
|
47
49
|
llm_class_name: LLM_CLASS_NAME
|
48
50
|
)
|
49
|
-
result = service.upload_and_process_later
|
50
|
-
|
51
|
-
if result[:error]
|
52
|
-
render json: { error: result[:error] }, status: :bad_request
|
53
|
-
else
|
54
|
-
render json: result
|
55
|
-
end
|
56
51
|
end
|
57
52
|
|
58
|
-
private
|
59
|
-
|
60
53
|
def current_user_document_groups
|
61
54
|
params[:current_user_groups].to_s.split(',').reject(&:blank?)
|
62
55
|
# replace this with the actual user document permission groups
|
@@ -7,6 +7,8 @@ module BxBuilderChain
|
|
7
7
|
|
8
8
|
before_destroy :destroy_associated_data
|
9
9
|
after_update :update_associated_embedding_namespaces, if: :saved_change_to_namespace?
|
10
|
+
|
11
|
+
validates :name, uniqueness: { scope: :namespace, message: "and namespace combination already exists" }
|
10
12
|
|
11
13
|
private
|
12
14
|
|
data/lib/pgvector/pg.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bx_builder_chain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Ketelle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|