Commit 46cb6ea
committed
server : auto-insert media marker in embedding / multimodal prompts
The /embedding (and /embeddings, /v1/embeddings) endpoints failed with
"number of media markers in text (0) does not match number of bitmaps (1)"
when passing multimodal data via the "content" object format.
The server initializes the mtmd context with a randomized media marker
(via get_media_marker()), but process_mtmd_prompt() passed the raw prompt
string to mtmd_tokenize() without ensuring it contained the required
markers. The CLI (mtmd-cli.cpp) already handles this by auto-prepending
markers, but the server did not.
Fix: query the actual marker from the mtmd context via mtmd_get_marker()
and auto-insert one per file if the prompt lacks them.
server: auto-insert missing media markers in process_mtmd_prompt
Fixes the /embedding endpoint when multimodal data is provided without
corresponding media markers in the prompt string. Counts existing markers
and prepends only the missing number so the count matches files.size().
Assisted-by: GitHub Copilot
Potential fix for pull request finding
This just makes the wording more accurate
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
server: auto-insert missing media markers in process_mtmd_prompt
Fixes the /embedding endpoint when multimodal data is provided without
corresponding media markers in the prompt string. Counts existing markers
and prepends only the missing number so the count matches files.size().
Assisted-by: GitHub Copilot1 parent 27c8bb4 commit 46cb6ea
1 file changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
705 | 731 | | |
706 | 732 | | |
707 | 733 | | |
708 | | - | |
| 734 | + | |
709 | 735 | | |
710 | 736 | | |
711 | 737 | | |
| |||
0 commit comments