Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/_test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
bundle install
bundle exec appraisal ${{ matrix.rails-version }} bundle install
- name: Run eager-load guard (appraisal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really needed. you can do it in the test helper

run: bundle exec appraisal ${{ matrix.rails-version }} ruby -e "require 'ruby_llm'; Zeitwerk::Loader.eager_load_all"

- name: Run tests
if: matrix.ruby-version != '4.0' || matrix.rails-version != 'rails-8.1'
run: bundle exec appraisal ${{ matrix.rails-version }} bin/rspec-queue
Expand Down
6 changes: 2 additions & 4 deletions lib/ruby_llm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
loader.ignore("#{__dir__}/tasks")
loader.ignore("#{__dir__}/generators")
loader.ignore("#{__dir__}/ruby_llm/active_record")
loader.ignore("#{__dir__}/ruby_llm/railtie.rb")
loader.setup

Expand Down Expand Up @@ -107,7 +108,4 @@ def logger
RubyLLM::Provider.register :vertexai, RubyLLM::Providers::VertexAI
RubyLLM::Provider.register :xai, RubyLLM::Providers::XAI

if defined?(Rails::Railtie)
require 'ruby_llm/railtie'
require 'ruby_llm/active_record/acts_as'
end
require 'ruby_llm/railtie' if defined?(Rails::Railtie)
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/acts_as.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/concern'
require 'active_support/inflector'

module RubyLLM
module ActiveRecord
# Adds chat and message persistence capabilities to ActiveRecord models.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/acts_as_legacy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/concern'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every require should in line 4 of railtie , after if defined?(Rails::Railtie)

Then you dont have dups.

require 'active_support/inflector'

module RubyLLM
module ActiveRecord
# Adds chat and message persistence capabilities to ActiveRecord models.
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_llm/active_record/chat_methods.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'active_support/concern'

module RubyLLM
module ActiveRecord
# Methods mixed into chat models.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/message_methods.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/concern'
require 'ruby_llm/active_record/payload_helpers'

module RubyLLM
module ActiveRecord
# Methods mixed into message models.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/model_methods.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/concern'
require 'active_support/core_ext/module/delegation'

module RubyLLM
module ActiveRecord
# Methods mixed into model registry models.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/payload_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/core_ext/object/blank'
require 'json'

module RubyLLM
module ActiveRecord
# Shared helpers for parsing serialized payloads on ActiveRecord-backed models.
Expand Down
3 changes: 3 additions & 0 deletions lib/ruby_llm/active_record/tool_call_methods.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'active_support/concern'
require 'ruby_llm/active_record/payload_helpers'

module RubyLLM
module ActiveRecord
# Methods mixed into tool call models.
Expand Down
6 changes: 6 additions & 0 deletions lib/ruby_llm/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class Railtie < Rails::Railtie

initializer 'ruby_llm.active_record' do
ActiveSupport.on_load :active_record do
require 'ruby_llm/active_record/payload_helpers'
require 'ruby_llm/active_record/chat_methods'
require 'ruby_llm/active_record/message_methods'
require 'ruby_llm/active_record/model_methods'
require 'ruby_llm/active_record/tool_call_methods'

if RubyLLM.config.use_new_acts_as
require 'ruby_llm/active_record/acts_as'
::ActiveRecord::Base.include RubyLLM::ActiveRecord::ActsAs
Expand Down
2 changes: 2 additions & 0 deletions spec/ruby_llm/active_record_tool_error_helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require 'spec_helper'
require 'ruby_llm/active_record/message_methods'
require 'ruby_llm/active_record/tool_call_methods'

RSpec.describe RubyLLM::ActiveRecord do
describe RubyLLM::ActiveRecord::MessageMethods do
Expand Down
Loading