Commit 8e3361b
Updated acts_as_* helpers to use canonical 'rails-style' foreign keys (crmne#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 crmne#150
Co-authored-by: Carmine Paolino <[email protected]>1 parent aaf4169 commit 8e3361b
File tree
2 files changed
+95
-24
lines changed- lib/ruby_llm/active_record
- spec/ruby_llm/active_record
2 files changed
+95
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | | - | |
| 47 | + | |
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
45 | | - | |
| 54 | + | |
46 | 55 | | |
| 56 | + | |
47 | 57 | | |
48 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
52 | | - | |
| 65 | + | |
53 | 66 | | |
54 | 67 | | |
55 | 68 | | |
| |||
159 | 172 | | |
160 | 173 | | |
161 | 174 | | |
162 | | - | |
| 175 | + | |
163 | 176 | | |
164 | 177 | | |
165 | 178 | | |
166 | | - | |
167 | 179 | | |
168 | 180 | | |
169 | 181 | | |
| 182 | + | |
| 183 | + | |
170 | 184 | | |
171 | 185 | | |
172 | 186 | | |
| |||
185 | 199 | | |
186 | 200 | | |
187 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
188 | 207 | | |
189 | 208 | | |
190 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
22 | 32 | | |
23 | 33 | | |
24 | 34 | | |
| |||
30 | 40 | | |
31 | 41 | | |
32 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
33 | 54 | | |
34 | 55 | | |
35 | 56 | | |
36 | 57 | | |
37 | 58 | | |
38 | 59 | | |
39 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
40 | 69 | | |
41 | 70 | | |
42 | 71 | | |
| |||
45 | 74 | | |
46 | 75 | | |
47 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
48 | 82 | | |
49 | 83 | | |
50 | 84 | | |
51 | 85 | | |
52 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
53 | 92 | | |
54 | 93 | | |
55 | 94 | | |
56 | 95 | | |
57 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
58 | 102 | | |
59 | 103 | | |
60 | 104 | | |
| |||
71 | 115 | | |
72 | 116 | | |
73 | 117 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
77 | 123 | | |
78 | 124 | | |
79 | 125 | | |
80 | 126 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
85 | 134 | | |
86 | | - | |
87 | 135 | | |
88 | 136 | | |
89 | 137 | | |
| |||
124 | 172 | | |
125 | 173 | | |
126 | 174 | | |
127 | | - | |
128 | | - | |
129 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
130 | 180 | | |
131 | 181 | | |
132 | 182 | | |
| |||
145 | 195 | | |
146 | 196 | | |
147 | 197 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
153 | 205 | | |
154 | 206 | | |
155 | 207 | | |
| |||
0 commit comments