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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01b1f21a6cc3de948b270cbd23c95911803accd689598315f655cc320fcdcc4f
4
- data.tar.gz: ec76e4cedde5863f5022bd9842e0360ecbe0e51d39d8287c83c5b83415376023
3
+ metadata.gz: 5f5b6bc37b278c3ccd429b8b37a24256b89675b56b2d0ffad092d55a6b2a93ba
4
+ data.tar.gz: f876cc97ad7180007ad9e57481474232c3695e4538e59d820b94b365cc52def9
5
5
  SHA512:
6
- metadata.gz: 3bc4d41ca7050bc75b1f92276d1826ae43020d10b48bcd07d0fad1838c4f6dadba8f0dd262fe6a3188d2c18514a92f2dd35540ec40a99583d304fff45d585803
7
- data.tar.gz: 1ef19893af1c1a7bf6ea5be4d15da6243cb00629ff79f1bc3c6254f2bebcef1d957a7c1f9a81be5eac3cb16a2b90a2f0894c9158df0922a0fc154760d414d987
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
- source_root File.expand_path("templates", __dir__)
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 create_migration
15
+ def create_labels_migration
13
16
  migration_template "create_rails_ai_kit_labels.rb",
14
- "db/migrate/#{migration_timestamp}_create_rails_ai_kit_labels.rb"
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: -> { RailsAiKit.configuration.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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAiKit
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
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
- require_relative "rails_ai_kit/label_record"
15
- require_relative "rails_ai_kit/classifier"
16
- require_relative "rails_ai_kit/vector_classify"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_ai_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails AI Kit Contributors