@@ -74,9 +74,12 @@ class Chat < ActiveRecord::Base # rubocop:disable Lint/ConstantDefinitionInBlock
74
74
acts_as_chat
75
75
end
76
76
77
- class BotChat < ActiveRecord ::Base # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
78
- include RubyLLM ::ActiveRecord ::ActsAs
79
- acts_as_chat message_class : 'BotMessage' , tool_call_class : 'BotToolCall'
77
+ module Assistants # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
78
+ class BotChat < ActiveRecord ::Base # rubocop:disable RSpec/LeakyConstantDeclaration
79
+ self . table_name = 'bot_chats'
80
+ include RubyLLM ::ActiveRecord ::ActsAs
81
+ acts_as_chat message_class : 'BotMessage' , tool_call_class : 'BotToolCall'
82
+ end
80
83
end
81
84
82
85
class Message < ActiveRecord ::Base # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
@@ -86,7 +89,7 @@ class Message < ActiveRecord::Base # rubocop:disable Lint/ConstantDefinitionInBl
86
89
87
90
class BotMessage < ActiveRecord ::Base # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
88
91
include RubyLLM ::ActiveRecord ::ActsAs
89
- acts_as_message chat_class : 'BotChat' , tool_call_class : 'BotToolCall'
92
+ acts_as_message chat_class : 'Assistants:: BotChat' , tool_call_class : 'BotToolCall'
90
93
end
91
94
92
95
class ToolCall < ActiveRecord ::Base # rubocop:disable Lint/ConstantDefinitionInBlock,RSpec/LeakyConstantDeclaration
@@ -115,7 +118,7 @@ def execute(expression:)
115
118
116
119
shared_examples 'a chainable chat method' do |method_name , *args |
117
120
it "returns a Chat instance for ##{ method_name } " do
118
- [ Chat , BotChat ] . each do |chat_class |
121
+ [ Chat , Assistants :: BotChat ] . each do |chat_class |
119
122
chat = chat_class . create! ( model_id : 'gpt-4.1-nano' )
120
123
result = chat . public_send ( method_name , *args )
121
124
expect ( result ) . to be_a ( chat_class )
@@ -125,7 +128,7 @@ def execute(expression:)
125
128
126
129
shared_examples 'a chainable callback method' do |callback_name |
127
130
it "supports #{ callback_name } callback" do # rubocop:disable RSpec/ExampleLength
128
- [ Chat , BotChat ] . each do |chat_class |
131
+ [ Chat , Assistants :: BotChat ] . each do |chat_class |
129
132
chat = chat_class . create! ( model_id : 'gpt-4.1-nano' )
130
133
result = chat . public_send ( callback_name ) do
131
134
# no-op for testing
@@ -172,7 +175,7 @@ def execute(expression:)
172
175
173
176
describe 'with_tools functionality' do
174
177
it 'returns a Chat instance when using with_tool' do
175
- [ Chat , BotChat ] . each do |chat_class |
178
+ [ Chat , Assistants :: BotChat ] . each do |chat_class |
176
179
chat = chat_class . create! ( model_id : 'gpt-4.1-nano' )
177
180
with_tool_result = chat . with_tool ( Calculator )
178
181
expect ( with_tool_result ) . to be_a ( chat_class )
@@ -196,7 +199,7 @@ def execute(expression:)
196
199
it_behaves_like 'a chainable callback method' , :on_end_message
197
200
198
201
it 'supports method chaining with tools' do # rubocop:disable RSpec/ExampleLength
199
- [ Chat , BotChat ] . each do |chat_class |
202
+ [ Chat , Assistants :: BotChat ] . each do |chat_class |
200
203
chat = chat_class . create! ( model_id : 'gpt-4.1-nano' )
201
204
chat . with_tool ( Calculator )
202
205
. with_temperature ( 0.5 )
0 commit comments