Commit 61874ea
fix(llm): auto-shape multimodal mediaPath messages in chat template
LLMController.generate() collected imagePaths from messages with a
mediaPath but did not transform their content into the array form
([{type:'image'}, {type:'text', text}]) that the chat template needs
to emit the image placeholder. Calling generate() directly with a
vision-capable model thus threw "More images paths provided than
'<image>' placeholders in prompt" from native. sendMessage() worked
because it built its own historyForTemplate that did the transformation.
Move the transformation into applyChatTemplate so both call sites get
correct behavior, and remove the now-redundant historyForTemplate block
from sendMessage. Public Message.content type unchanged; external
callers always pass plain strings, the controller handles the array
form internally.
Refs #1086 (items 1 and 2 — with item 1 fixed, item 2's type mismatch
no longer surfaces because external callers never need to construct
the array form themselves).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent da22171 commit 61874ea
1 file changed
Lines changed: 23 additions & 14 deletions
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | 357 | | |
370 | 358 | | |
371 | 359 | | |
| |||
383 | 371 | | |
384 | 372 | | |
385 | 373 | | |
386 | | - | |
| 374 | + | |
387 | 375 | | |
388 | 376 | | |
389 | 377 | | |
| |||
448 | 436 | | |
449 | 437 | | |
450 | 438 | | |
451 | | - | |
| 439 | + | |
452 | 440 | | |
453 | 441 | | |
454 | 442 | | |
455 | 443 | | |
456 | 444 | | |
457 | 445 | | |
458 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
0 commit comments