Struggling to get Custom Model Names working #356
Replies: 1 comment 1 reply
-
I managed to get this working a different way, by leaving normal names on the references columns and defining the foreign_key instead:
Then removing the custom foreign_keys from the models:
From there I'm able to successfully replicate the Weather tool example from https://rubyllm.com/tools/#what-are-tools : ![]() I am able to run commands like The setup still feels a little off to me since it doesn't really match the suggested results from https://rubyllm.com/rails/#customizing-models - would love to know which of these approaches feels like a better long-term match for RubyLLM? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all. I'm 95% of the way towards finishing an installation with a custom namespace but struggling with the foreign key settings.
TLDR, I want to namespace the models into LLM::Chat, LLM::Message, and LLM::ToolCall, but when I create a chat I'm getting an Undefined Column error:
This command creates the Chat:
This command creates the
.ask
and then fails onPG::UndefinedColumn: ERROR: column llm_tool_calls.message_id
even though I have set the foreign key in the model.Migrations
Here are my migrations:
db/migrate/20250814055646_create_llm_chats.rb
:db/migrate/20250814055647_create_llm_messages.rb
:db/migrate/20250814055648_create_llm_tool_calls.rb
:Models
And here are my Models:
app/models/llm/chat.rb
:app/models/llm/message.rb
:app/models/llm/tool_call.rb
:Schema
Here's my schema as it's created. You can see llm_tool_calls.llm_message_id exists as a column, and above it is set as
message_foreign_key: "llm_message_id"
, but doesn't seem to be getting used.Beta Was this translation helpful? Give feedback.
All reactions