rails_ai_kit 0.1.1 → 0.1.3
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/CHANGELOG.md +15 -0
- data/lib/generators/rails_ai_kit/install_generator.rb +6 -9
- data/lib/rails_ai_kit/label_record.rb +1 -1
- data/lib/rails_ai_kit/version.rb +1 -1
- data/lib/rails_ai_kit.rb +19 -8
- 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: 5f5b6bc37b278c3ccd429b8b37a24256b89675b56b2d0ffad092d55a6b2a93ba
|
|
4
|
+
data.tar.gz: f876cc97ad7180007ad9e57481474232c3695e4538e59d820b94b365cc52def9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fddc5b46a839156459abc6ba82419329d66aeca703b76151663a9b66296e0d9867467422ce71dd067f998e99c22639eb8fabc558e5ea07f34c4e697faf8694ca
|
|
7
|
+
data.tar.gz: 7a1420f049a63341d5783b20e08c7948ac4347c51a65ebfe71c6691f5f88ae9507174b16ccf1e42648c9ebd2dcbfc37aa7235ef378a99a63da525977bae016be
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.1.3] - 2026-03-07
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Ensure Neighbor gem is required in `on_load(:active_record)` when app loads rails_ai_kit before neighbor (Gemfile order)
|
|
10
|
+
- Install generator: use `ActiveRecord::Generators::Migration` and correct `source_root` (`install/templates`) so migration and initializer are found
|
|
11
|
+
- Install generator: rename task to `create_labels_migration` to avoid shadowing Migration’s `create_migration`
|
|
12
|
+
|
|
13
|
+
## [0.1.2] - 2026-03-07
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Compatibility with Neighbor 0.6: load label_record, classifier, and vector_classify in `ActiveSupport.on_load(:active_record)` so `has_neighbors` is available
|
|
18
|
+
- Use integer for `dimensions` in LabelRecord (Neighbor 0.6 does not support proc)
|
|
19
|
+
|
|
5
20
|
## [0.1.1] - 2026-03-07
|
|
6
21
|
|
|
7
22
|
### Fixed
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "rails/generators"
|
|
4
|
+
require "rails/generators/active_record/migration"
|
|
4
5
|
|
|
5
6
|
module RailsAiKit
|
|
6
7
|
module Generators
|
|
7
8
|
class InstallGenerator < Rails::Generators::Base
|
|
8
|
-
|
|
9
|
+
include ActiveRecord::Generators::Migration
|
|
10
|
+
|
|
11
|
+
source_root File.expand_path("install/templates", __dir__)
|
|
9
12
|
|
|
10
13
|
desc "Creates a migration to enable pgvector and add rails_ai_kit_labels table for label embeddings"
|
|
11
14
|
|
|
12
|
-
def
|
|
15
|
+
def create_labels_migration
|
|
13
16
|
migration_template "create_rails_ai_kit_labels.rb",
|
|
14
|
-
"db/migrate
|
|
17
|
+
"db/migrate/create_rails_ai_kit_labels.rb"
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
def create_initializer
|
|
18
21
|
copy_file "rails_ai_kit.rb", "config/initializers/rails_ai_kit.rb"
|
|
19
22
|
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def migration_timestamp
|
|
24
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
25
|
-
end
|
|
26
23
|
end
|
|
27
24
|
end
|
|
28
25
|
end
|
|
@@ -7,7 +7,7 @@ module RailsAiKit
|
|
|
7
7
|
class LabelRecord < ActiveRecord::Base
|
|
8
8
|
self.table_name = "rails_ai_kit_labels"
|
|
9
9
|
|
|
10
|
-
has_neighbors :embedding, dimensions:
|
|
10
|
+
has_neighbors :embedding, dimensions: RailsAiKit.configuration.embedding_dimensions
|
|
11
11
|
|
|
12
12
|
validates :classifier_name, presence: true
|
|
13
13
|
validates :label_name, presence: true
|
data/lib/rails_ai_kit/version.rb
CHANGED
data/lib/rails_ai_kit.rb
CHANGED
|
@@ -11,9 +11,25 @@ require_relative "rails_ai_kit/embedding_providers/base"
|
|
|
11
11
|
require_relative "rails_ai_kit/embedding_providers/openai"
|
|
12
12
|
require_relative "rails_ai_kit/embedding_providers/cohere"
|
|
13
13
|
require_relative "rails_ai_kit/embedding_service"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
# Load models and AR integration only after ActiveRecord is ready.
|
|
16
|
+
# Neighbor 0.6+ adds has_neighbors in its own on_load(:active_record).
|
|
17
|
+
# Gemfile order can make our hook run before Neighbor's (or before neighbor is required).
|
|
18
|
+
# So we ensure the neighbor gem is loaded and has_neighbors is on Base before our models.
|
|
19
|
+
ActiveSupport.on_load(:active_record) do
|
|
20
|
+
unless ActiveRecord::Base.respond_to?(:has_neighbors)
|
|
21
|
+
require "neighbor" # load gem so Neighbor and its lib are available
|
|
22
|
+
require "neighbor/attribute"
|
|
23
|
+
require "neighbor/model"
|
|
24
|
+
require "neighbor/normalized_attribute"
|
|
25
|
+
ActiveRecord::Base.extend(Neighbor::Model)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
require_relative "rails_ai_kit/label_record"
|
|
29
|
+
require_relative "rails_ai_kit/classifier"
|
|
30
|
+
require_relative "rails_ai_kit/vector_classify"
|
|
31
|
+
ActiveRecord::Base.include RailsAiKit::VectorClassify
|
|
32
|
+
end
|
|
17
33
|
|
|
18
34
|
module RailsAiKit
|
|
19
35
|
# Top-level classifier using default classifier name. For custom name use Classifier.new(classifier_name: "MyClassifier").
|
|
@@ -21,8 +37,3 @@ module RailsAiKit
|
|
|
21
37
|
Classifier.new(classifier_name: classifier_name)
|
|
22
38
|
end
|
|
23
39
|
end
|
|
24
|
-
|
|
25
|
-
# Optional Rails integration: extend ActiveRecord so vector_classify is available.
|
|
26
|
-
if defined?(ActiveRecord::Base)
|
|
27
|
-
ActiveRecord::Base.include RailsAiKit::VectorClassify
|
|
28
|
-
end
|