speaky 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/speaky/concern.rb +1 -21
- data/lib/speaky/vectorstore_base.rb +0 -7
- data/lib/speaky/vectorstore_qdrant.rb +0 -4
- data/lib/speaky/version.rb +1 -1
- data/lib/speaky.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6be1d021d8ebe259d6aa37fe46dc536e8be03b0e4b19309ad06733625bb91ff
|
4
|
+
data.tar.gz: 5a5b658cd9ea7878362d436cee77b322be437e0a6bca88db844eb56cd06719af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e149649e103d758b87dbb73b3417f1fbdf8e0e73838b24f602fc17204fc2a972fee798eed57aa9c0b92d30ffbeae18047eaa845e248af1355dce1f72b006ed
|
7
|
+
data.tar.gz: ca90c2c737d2f2e151c2f35a8b2b429f116aeb386c02951aa87e119635d0f06cf86fbd1ab9dc4764014d5c830998d6fd9299dee00d4877282fcaa567f4e961dd
|
data/README.md
CHANGED
@@ -62,8 +62,6 @@ class MyModel < ApplicationRecord
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Add any callbacks that should update the model instance data in the vector store.
|
65
|
-
after_create :create_for_speaky
|
66
|
-
after_update :update_for_speaky
|
67
65
|
after_save :save_for_speaky
|
68
66
|
after_destroy :destroy_for_speaky
|
69
67
|
end
|
data/lib/speaky/concern.rb
CHANGED
@@ -11,7 +11,7 @@ module Speaky
|
|
11
11
|
self.to_json
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def save_for_speaky
|
15
15
|
begin
|
16
16
|
Speaky.vectorstore.add(self.id, self.as_speaky)
|
17
17
|
rescue StandardError => e
|
@@ -21,16 +21,6 @@ module Speaky
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def update_for_speaky
|
25
|
-
begin
|
26
|
-
Speaky.vectorstore.update(self.id, self.as_speaky)
|
27
|
-
rescue StandardError => e
|
28
|
-
Rails.logger.error(e)
|
29
|
-
errors.add(:base, 'Failed to update for speaky')
|
30
|
-
raise ActiveRecord::Rollback
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
24
|
def destroy_for_speaky
|
35
25
|
begin
|
36
26
|
Speaky.vectorstore.remove(self.id)
|
@@ -40,15 +30,5 @@ module Speaky
|
|
40
30
|
raise ActiveRecord::Rollback
|
41
31
|
end
|
42
32
|
end
|
43
|
-
|
44
|
-
def save_for_speaky
|
45
|
-
ActiveRecord::Base.transaction do
|
46
|
-
if self.new_record?
|
47
|
-
create_for_speaky
|
48
|
-
else
|
49
|
-
update_for_speaky
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
33
|
end
|
54
34
|
end
|
@@ -17,13 +17,6 @@ module Speaky
|
|
17
17
|
raise NotImplementedError
|
18
18
|
end
|
19
19
|
|
20
|
-
# Update a vector in the vectorstore.
|
21
|
-
# NOTE: If the vector does not exist, it will be added.
|
22
|
-
# Returns a boolean.
|
23
|
-
def update(id, data)
|
24
|
-
raise NotImplementedError
|
25
|
-
end
|
26
|
-
|
27
20
|
# Remove a vector from the vectorstore.
|
28
21
|
# NOTE: If the vector does not exist, it will be ignored.
|
29
22
|
# Returns a boolean.
|
data/lib/speaky/version.rb
CHANGED
data/lib/speaky.rb
CHANGED
@@ -111,11 +111,11 @@ module Speaky
|
|
111
111
|
Rails.application.eager_load!
|
112
112
|
rails_models = ActiveRecord::Base.descendants
|
113
113
|
rails_models.each do |rails_model|
|
114
|
-
next unless rails_model.instance_methods.include?(:
|
114
|
+
next unless rails_model.instance_methods.include?(:save_for_speaky)
|
115
115
|
|
116
116
|
rails_model.find_in_batches do |batch|
|
117
117
|
batch.each do |record|
|
118
|
-
record.
|
118
|
+
record.save_for_speaky
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|