-
-
Notifications
You must be signed in to change notification settings - Fork 127
Updated acts_as_* helpers to use canonical 'rails-style' foreign keys #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… when custom class names are used. Closes crmne#150
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #151 +/- ##
==========================================
+ Coverage 93.57% 93.65% +0.07%
==========================================
Files 87 87
Lines 3160 3199 +39
Branches 421 422 +1
==========================================
+ Hits 2957 2996 +39
Misses 203 203 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…#151) This updates the acts_as_message, acts_as_chat and acts_as_tool class methods to use Rails-style foreign keys whenever custom class names are used as options. For example: ``` class FooMessage < ActiveRecord::Base acts_as_message chat_class: 'FooChat', tool_call_class: 'FooToolCall' end ``` will now set the foreign key on the `belongs_to :chat` association to be `foo_chat_id`, instead of `chat_id`, and will set the foreign key on `belongs_to :parent_tool_call` association to `foo_tool_call_id` instead of just `tool_call_id`. This is consistent with Rails' naming conventions for class names and foreign keys. Changes are backwards-compatible with existing code/behavior, and don't require a major or minor version bump. Updated test cases to ensure that the associations are working, but didn't re-record VCR tests, since I don't have an OpenAPI key. Closes #150 Co-authored-by: Carmine Paolino <[email protected]>
Please re-open - this introduces a regression. |
@bborn best to open a new PR |
Give me a bit and I can put in a PR that replaces the current hack with ActiveSupport::Inflector.foreign_key |
…ith-image * 'main' of github.com:crmne/ruby_llm: (24 commits) Enhance Rails guide with detailed persistence flow explanation and setup instructions Remove work-in-progress warning from models documentation generation Add validation considerations for Message model and update persistence flow documentation Add note about upcoming OpenAI headers support in v1.3.0 Handle OpenAI organization and project IDs (crmne#162) Refactor acts_as_message and acts_as_tool_call methods to improve parameter handling and default values Remove reasoning section from available models documentation and rake task Remove debug logging for pricing in OpenRouter models Updated models page Fixed pricing parsing for OpenRouter Updated models Add warning about work in progress for Parsera integration in available models documentation Major refactoring of ModelInfo and Parsera API support for listing LLM capabilities and pricing. Fix inflector (crmne#159) Use foreign_key instead of to_s for acts_as methods (crmne#157) Fixes #embed fails when using default embedding model Add support for logging to file via configuration (crmne#148) Updated acts_as_* helpers to use canonical 'rails-style' foreign keys (crmne#151) refactor(media): streamline content formatting methods across providers Fixed Calling `chat.to_llm` keeps appending messages to the message array ...
This updates the acts_as_message, acts_as_chat and acts_as_tool class methods to use Rails-style foreign keys whenever custom class names are used as options. For example:
will now set the foreign key on the
belongs_to :chat
association to befoo_chat_id
, instead ofchat_id
, and will set the foreign key onbelongs_to :parent_tool_call
association tofoo_tool_call_id
instead of justtool_call_id
.This is consistent with Rails' naming conventions for class names and foreign keys. Changes are backwards-compatible with existing code/behavior, and don't require a major or minor version bump.
Updated test cases to ensure that the associations are working, but didn't re-record VCR tests, since I don't have an OpenAPI key.
Closes #150