Skip to content

docs: add guide for using custom model names with acts_as helpers #171

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

matheuscumpian
Copy link

While integrating RubyLLM with an existing Rails application that already had a Chat model, I discovered that the framework supports using custom model names with the acts_as helpers. This isn't explicitly documented, but is a valuable feature for real-world Rails applications where naming conflicts or existing conventions might exist.

Let me know if I'm missing something on this behaviour

Extend the Rails guide to explain how to customize model names when using
the acts_as_chat, acts_as_message, and acts_as_tool_call helpers.
@matheuscumpian
Copy link
Author

closes #183

Copy link
Owner

@crmne crmne left a comment

Choose a reason for hiding this comment

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

Thanks @matheuscumpian. Only a couple changes needed before merging.

@@ -474,6 +474,46 @@ This setup allows for:

Your `Chat`, `Message`, and `ToolCall` models are standard ActiveRecord models. You can add any other associations, validations, scopes, callbacks, or methods as needed for your application logic. The `acts_as` helpers provide the core persistence bridge to RubyLLM without interfering with other model behavior.

{: .note }
You can use custom model names by passing parameters to the `acts_as` helpers. For example, if you prefer `Conversation` over `Chat`, you could use `acts_as_chat` in your `Conversation` model and then specify `chat_class: 'Conversation'` in your `Message` model's `acts_as_message` call.
Copy link
Owner

Choose a reason for hiding this comment

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

No need for a note when the content is right below.

{: .note }
You can use custom model names by passing parameters to the `acts_as` helpers. For example, if you prefer `Conversation` over `Chat`, you could use `acts_as_chat` in your `Conversation` model and then specify `chat_class: 'Conversation'` in your `Message` model's `acts_as_message` call.

#### Using Custom Model Names
Copy link
Owner

Choose a reason for hiding this comment

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

Why <h4>? it's right after an h2 so I'd say h3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants