Commit 321c23d
authored
Fix chat runtime option matching and add direct service calls (#577)
* Fix chat runtime option matching and add direct service calls
- Store inline question options in _current_options (not just CMS-sourced),
fixing cascading failures where age/reading answers stored as raw strings
instead of full option dicts with typed fields like age_number
- Add internal API handler registry for direct service-layer calls, bypassing
HTTP auth for anonymous chatbot sessions (e.g. /v1/recommend)
- Fix broken import in _find_matching_connection (app.crud.chat → chat_repo)
- Resolve school name server-side from school_wriveted_id during session start
- Add CEL functions for hue profile aggregation (merge, top_keys)
- Expand seed fixtures with book catalog, themes, and flow_file loading
* Update docs for internal service calls, option matching, and seed fixtures
- Fix repository path reference (app/crud/chat_repo.py → app/repositories/)
- Document direct service call architecture for anonymous chatbot sessions
- Document choice option matching behavior (full option objects with typed fields)
- Add top_keys CEL function to aggregation docs
- Fix user scope as read/write (writable by action nodes)
- Document flow_file key for external flow JSON in seed fixtures
- Document server-side school name resolution and theme loading in /start
* Harden seed script: guard missing flow files and fix theme lookup
- _load_flow_config returns None with warning instead of raising
FileNotFoundError when referenced flow JSON is absent
- _ensure_theme uses (name, school_id) composite filter with .first()
to avoid MultipleResultsFound and remove unused seed_key branch
* Fix variable resolver tests to expect preserved types
substitute_object returns raw typed values for single {{var}} refs
(int 30, bool True) rather than stringified versions.
* Add unit tests for top_keys CEL function
Covers ranking, n-parameter limiting, non-numeric value filtering,
empty/non-dict inputs, and the full merge-then-rank pipeline used
in Huey hue profile aggregation.
* Fix limit parsing, internal API URL, and stale option clearing
- Safely parse and clamp limit param in recommend handler (1-50)
- Point api service WRIVETED_INTERNAL_API at internal:8888, not itself
- Always write _current_options (even empty) to clear stale options
from previous questions, preventing incorrect option reuse1 parent 0e888c3 commit 321c23d
File tree
17 files changed
+1009
-118
lines changed- app
- api
- repositories
- services
- tests
- integration
- unit
- docs
- scripts
- fixtures
17 files changed
+1009
-118
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
100 | 132 | | |
101 | 133 | | |
102 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
32 | 47 | | |
33 | 48 | | |
34 | 49 | | |
| |||
145 | 160 | | |
146 | 161 | | |
147 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
148 | 168 | | |
149 | 169 | | |
150 | 170 | | |
| |||
194 | 214 | | |
195 | 215 | | |
196 | 216 | | |
197 | | - | |
| 217 | + | |
198 | 218 | | |
199 | 219 | | |
200 | 220 | | |
| |||
214 | 234 | | |
215 | 235 | | |
216 | 236 | | |
217 | | - | |
| 237 | + | |
218 | 238 | | |
219 | 239 | | |
220 | 240 | | |
| |||
233 | 253 | | |
234 | 254 | | |
235 | 255 | | |
236 | | - | |
237 | | - | |
238 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
239 | 260 | | |
240 | 261 | | |
241 | 262 | | |
| |||
285 | 306 | | |
286 | 307 | | |
287 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
288 | 354 | | |
289 | 355 | | |
290 | 356 | | |
| |||
297 | 363 | | |
298 | 364 | | |
299 | 365 | | |
300 | | - | |
301 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
302 | 369 | | |
303 | 370 | | |
304 | 371 | | |
| |||
307 | 374 | | |
308 | 375 | | |
309 | 376 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
316 | 387 | | |
317 | 388 | | |
318 | 389 | | |
| |||
450 | 521 | | |
451 | 522 | | |
452 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
453 | 532 | | |
454 | 533 | | |
455 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
| |||
108 | 121 | | |
109 | 122 | | |
110 | 123 | | |
| 124 | + | |
111 | 125 | | |
112 | 126 | | |
113 | 127 | | |
| |||
174 | 188 | | |
175 | 189 | | |
176 | 190 | | |
| 191 | + | |
177 | 192 | | |
178 | 193 | | |
179 | 194 | | |
| |||
0 commit comments