diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a9ee102e..076c565b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -98,6 +98,26 @@
`LlamaStructuredOutput.parse` still decode it); trim replies you compare
exactly. `ChatSession` and its tool loop store assistant turns in `history`
without that whitespace, so the next prompt is unchanged.
+- **Behavior change:** an image or audio part of a chat request to a GGUF
+ model takes the place it has in its message, as llama.cpp's `llama-server`
+ renders it ([#964](https://github.com/leehack/llamadart/issues/964)). For
+ Qwen3.5 and Qwen2.5-Omni it was attached before the whole prompt, and for
+ GLM-OCR it was wrapped in the image start and end tokens twice, so prompts
+ for media turns of these models change. A chat template no longer writes
+ its own text for a media part: Qwen's `Picture N: ` under `add_vision_id`,
+ the Kimi-K2 wrapper, Reka's run of image tokens and Cohere's
+ `<|IMG_PATCH|>` are gone, as on `llama-server`. A placeholder string that
+ a chat message quotes (` `, ``, `[IMG]`, `<__media__>`) is text
+ instead of a part. Where the runtime would still read such a string as a
+ part, it reaches the model with a zero-width space (U+200B) after its
+ first character, which the model may repeat in its answer: a quoted
+ `<__media__>` in `create` on native; every placeholder the bridge
+ rewrites in `create` on Web; and every placeholder `generate` reads in the
+ prompt `chatTemplate` returns for messages with media and in `create` on
+ a custom backend without `BackendChatPromptGeneration`, which
+ `package:llamadart/backend.dart` now exports. A prompt written for
+ `generate` keeps its placeholders, and `chatTemplate` output for messages
+ without media is unchanged.
## 0.11.1
diff --git a/doc/litert_lm_templates.md b/doc/litert_lm_templates.md
index 66e4d7a75..a5961628a 100644
--- a/doc/litert_lm_templates.md
+++ b/doc/litert_lm_templates.md
@@ -209,9 +209,9 @@ Templates are committed as jinja under `tool/litert_lm_templates/` and embedded
into `lib/src/backends/litert_lm/litert_lm_chat_templates.dart` by a generator.
Start from the canonical template llama.cpp uses. Keep any runtime
content-shape adapter in this source and cover it with prompt-parity tests.
-An adapter that reads content part lists either renders image and audio parts
-or rejects both: the Dart renderer gives a template that reads part lists
-media as typed parts unless it rejects both kinds. Pin the result in
+The Dart renderer gives an adapter the media marker in the message text and
+never an image or audio part. It still reports an adapter that reads content
+part lists but rejects both kinds as reading strings only. Pin the result in
`test/unit/core/template/template_caps_cache_fixtures_test.dart`.
1. Copy the canonical jinja into `tool/litert_lm_templates/.jinja`
diff --git a/doc/webgpu_bridge.md b/doc/webgpu_bridge.md
index 70960841f..f49378657 100644
--- a/doc/webgpu_bridge.md
+++ b/doc/webgpu_bridge.md
@@ -342,6 +342,17 @@ gates against real assets and models; its header lists the setup.
exported from `package:llamadart`.
- Large model URL loads can use a worker-thread fetch-backed path to reduce
contiguous `ArrayBuffer` pressure, but only after an explicit opt-in.
+- With media parts the bridge reads its marker `<__media__>` and the
+ placeholders it rewrites to it (``, `[IMG]`, `<|image|>`, ` `,
+ `<|img|>`, `<|vision_start|><|image_pad|><|vision_end|>` and its
+ `video_pad` form, ``, `<|audio|>`, `<|image_N|>`, `<|audio_N|>`) as
+ a part wherever they are in the prompt, and the pinned assets have no
+ option that turns this off. For a prompt that `LlamaEngine.create` rendered,
+ `WebGpuLlamaBackend` writes `<__media__>` where each part was and puts a
+ zero-width space after the first character of any such string in the rest,
+ so a message that quotes one is not read as media. A prompt passed to
+ `generate` goes to the bridge as written. A bridge option that takes the
+ marker with the request would make the zero-width space unnecessary.
- Bridge runtimes can provide `llama_webgpu_core_mem64.js/.wasm`. When the
page sets `__llamadartBridgeCoreModuleUrlMem64` and memory64 is preferred,
the bridge tries the wasm64 core first and falls back to wasm32.
diff --git a/lib/backend.dart b/lib/backend.dart
index 228dd74de..b508c805a 100644
--- a/lib/backend.dart
+++ b/lib/backend.dart
@@ -29,6 +29,7 @@ export 'src/backends/backend.dart'
LlamaBackend,
BackendAvailability,
BackendBatchEmbeddings,
+ BackendChatPromptGeneration,
BackendDartLogLevel,
BackendDecision,
BackendDecisionCapabilities,
diff --git a/lib/src/backends/backend.dart b/lib/src/backends/backend.dart
index e9a383671..dd07c8900 100644
--- a/lib/src/backends/backend.dart
+++ b/lib/src/backends/backend.dart
@@ -294,6 +294,34 @@ abstract class BackendRuntimeIdentity {
LlamaRuntime? get runtime;
}
+/// Optional backend capability for a prompt that `LlamaEngine.create`
+/// rendered from chat messages with media parts, as opposed to a prompt the
+/// caller of `LlamaEngine.generate` wrote.
+///
+/// A backend that reads media placeholders in the prompt of
+/// [LlamaBackend.generate] (`<__media__>`, ``, ` ` and the like)
+/// would also read one that a chat message only quotes. With this interface
+/// the engine hands such a backend the rendered prompt apart from a caller's.
+/// Without it the engine passes the prompt to [LlamaBackend.generate] with
+/// `<__media__>` where each part was and a zero-width space (U+200B) after
+/// the first character of every other placeholder string.
+abstract class BackendChatPromptGeneration {
+ /// Generates like [LlamaBackend.generate] from the chat-rendered [prompt].
+ ///
+ /// [mediaMarker] stands in [prompt] once for each image or audio part of
+ /// [parts], in order, where that part was in its message. It is a random
+ /// string, drawn once for the isolate, that message text does not hold.
+ /// Everything else in [prompt] is template or message text: the backend
+ /// must not rewrite a placeholder in it or read it as media.
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ required String mediaMarker,
+ List? parts,
+ });
+}
+
/// Internal backend probe for media the loaded model takes directly, without
/// a multimodal projector.
abstract class BackendDirectMediaInput {
diff --git a/lib/src/backends/llama_cpp/llama_cpp_backend.dart b/lib/src/backends/llama_cpp/llama_cpp_backend.dart
index ce4b54ebe..c90098e4b 100644
--- a/lib/src/backends/llama_cpp/llama_cpp_backend.dart
+++ b/lib/src/backends/llama_cpp/llama_cpp_backend.dart
@@ -44,6 +44,7 @@ class NativeLlamaBackend
BackendVideoRuntimeSupport,
BackendGenerationLimitReporting,
BackendGenerationUsageReporting,
+ BackendChatPromptGeneration,
BackendDartLogLevel {
Isolate? _isolate;
SendPort? _sendPort;
@@ -506,6 +507,29 @@ class NativeLlamaBackend
String prompt,
GenerationParams params, {
List? parts,
+ }) => _generate(contextHandle, prompt, params, parts: parts);
+
+ @override
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ required String mediaMarker,
+ List? parts,
+ }) => _generate(
+ contextHandle,
+ prompt,
+ params,
+ parts: parts,
+ chatMediaMarker: mediaMarker,
+ );
+
+ Stream> _generate(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ List? parts,
+ String? chatMediaMarker,
}) {
final failure = _workerFailure;
if (failure != null) return Stream>.error(failure);
@@ -533,6 +557,7 @@ class NativeLlamaBackend
prompt,
params,
parts,
+ chatMediaMarker,
);
}
@@ -585,6 +610,7 @@ class NativeLlamaBackend
String prompt,
GenerationParams params,
List? parts,
+ String? chatMediaMarker,
) {
final rp = _openResponsePort();
@@ -654,6 +680,7 @@ class NativeLlamaBackend
cancelToken.address,
rp.sendPort,
parts: parts,
+ chatMediaMarker: chatMediaMarker,
),
);
} catch (error, stackTrace) {
diff --git a/lib/src/backends/llama_cpp/llama_cpp_service.dart b/lib/src/backends/llama_cpp/llama_cpp_service.dart
index 1924bcf0f..fdf0f8aed 100644
--- a/lib/src/backends/llama_cpp/llama_cpp_service.dart
+++ b/lib/src/backends/llama_cpp/llama_cpp_service.dart
@@ -4707,6 +4707,9 @@ class LlamaCppService {
/// Supports multimodal input via [parts].
/// Calls [onLimit] before the stream closes when a token limit ended the
/// generation.
+ ///
+ /// The caller wrote [prompt]: a media placeholder in it stands for a part,
+ /// and parts without one go before the prompt.
Stream> generate(
int contextHandle,
String prompt,
@@ -4714,6 +4717,44 @@ class LlamaCppService {
int cancelTokenAddress, {
List? parts,
void Function(BackendGenerationLimit limit)? onLimit,
+ }) => _generate(
+ contextHandle,
+ prompt,
+ params,
+ cancelTokenAddress,
+ parts: parts,
+ onLimit: onLimit,
+ );
+
+ /// Generates like [generate] from a [prompt] that a chat template rendered
+ /// with [mediaMarker] where each part was. A placeholder string elsewhere
+ /// in it is message text.
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params,
+ int cancelTokenAddress, {
+ required String mediaMarker,
+ List? parts,
+ void Function(BackendGenerationLimit limit)? onLimit,
+ }) => _generate(
+ contextHandle,
+ prompt,
+ params,
+ cancelTokenAddress,
+ parts: parts,
+ chatMediaMarker: mediaMarker,
+ onLimit: onLimit,
+ );
+
+ Stream> _generate(
+ int contextHandle,
+ String prompt,
+ GenerationParams params,
+ int cancelTokenAddress, {
+ List? parts,
+ String? chatMediaMarker,
+ void Function(BackendGenerationLimit limit)? onLimit,
}) async* {
var ctx = _contexts[contextHandle];
if (ctx == null) throw Exception("Invalid context handle");
@@ -4876,6 +4917,7 @@ class LlamaCppService {
tokensPtr,
nCtx,
modelParams,
+ chatMediaMarker: chatMediaMarker,
allowTextPromptReuse:
speculativeConfig == null &&
!hasMediaParts &&
@@ -5673,6 +5715,7 @@ class LlamaCppService {
Pointer tokensPtr,
int nCtx,
llama_context_params modelParams, {
+ required String? chatMediaMarker,
required bool allowTextPromptReuse,
required Pointer speculativeSession,
required _SpeculativeApi? speculativeApi,
@@ -5696,6 +5739,7 @@ class LlamaCppService {
mediaParts,
modelParams,
cancelToken,
+ chatMediaMarker: chatMediaMarker,
);
return (nPast: nPast, promptTokenCount: 0);
} else {
@@ -5724,8 +5768,9 @@ class LlamaCppService {
String prompt,
List mediaParts,
llama_context_params modelParams,
- Pointer cancelToken,
- ) {
+ Pointer cancelToken, {
+ required String? chatMediaMarker,
+ }) {
_calls.failures.ensureUsable(mmCtx, 'This multimodal projector');
int initialTokens = 0;
// Zeroed, so the cleanup of a part that failed skips the slots after it.
@@ -5791,6 +5836,7 @@ class LlamaCppService {
final normalizedPrompt = _normalizeMtmdPromptMarkers(
prompt,
mediaParts.length,
+ chatMediaMarker: chatMediaMarker,
);
promptPtr = normalizedPrompt.toNativeUtf8();
inputText.ref.text = promptPtr.cast();
@@ -5895,13 +5941,27 @@ class LlamaCppService {
);
}
- String _normalizeMtmdPromptMarkers(String prompt, int mediaPartCount) {
+ String _normalizeMtmdPromptMarkers(
+ String prompt,
+ int mediaPartCount, {
+ required String? chatMediaMarker,
+ }) {
final markerPtr = _mtmdDefaultMarker();
final marker = markerPtr == nullptr
? '<__media__>'
: markerPtr.cast().toDartString();
- var normalized = normalizeMediaPlaceholders(prompt, marker: marker);
+ // The projector splits a prompt on its marker wherever it is. Its helper
+ // for speech output writes the default marker itself, so the projector
+ // cannot be given another one.
+ var normalized = chatMediaMarker == null
+ ? normalizeMediaPlaceholders(prompt, marker: marker)
+ : chatPromptForMarkerRuntime(
+ prompt,
+ chatMarker: chatMediaMarker,
+ marker: marker,
+ runtimePlaceholders: marker,
+ );
if (mediaPartCount <= 0) {
return normalized;
diff --git a/lib/src/backends/llama_cpp/worker.dart b/lib/src/backends/llama_cpp/worker.dart
index 9d63e6dfb..1979a037c 100644
--- a/lib/src/backends/llama_cpp/worker.dart
+++ b/lib/src/backends/llama_cpp/worker.dart
@@ -248,14 +248,25 @@ void runLlamaWorkerForTesting(
final stopwatch = Stopwatch()..start();
Duration? timeToFirstToken;
BackendGenerationLimit? limit;
- final stream = service.generate(
- message.contextHandle,
- message.prompt,
- message.params,
- message.cancelTokenAddress,
- parts: message.parts,
- onLimit: (reached) => limit = reached,
- );
+ final chatMediaMarker = message.chatMediaMarker;
+ final stream = chatMediaMarker == null
+ ? service.generate(
+ message.contextHandle,
+ message.prompt,
+ message.params,
+ message.cancelTokenAddress,
+ parts: message.parts,
+ onLimit: (reached) => limit = reached,
+ )
+ : service.generateChatPrompt(
+ message.contextHandle,
+ message.prompt,
+ message.params,
+ message.cancelTokenAddress,
+ mediaMarker: chatMediaMarker,
+ parts: message.parts,
+ onLimit: (reached) => limit = reached,
+ );
final batcher = NativeTokenStreamBatcher(
tokenThreshold: message.params.streamBatchTokenThreshold,
diff --git a/lib/src/backends/llama_cpp/worker_messages.dart b/lib/src/backends/llama_cpp/worker_messages.dart
index 98c3ee369..6fe06e1fa 100644
--- a/lib/src/backends/llama_cpp/worker_messages.dart
+++ b/lib/src/backends/llama_cpp/worker_messages.dart
@@ -83,6 +83,10 @@ class GenerateRequest extends WorkerRequest {
/// Multimodal content parts.
final List? parts;
+ /// The marker a chat template rendered [prompt] with, or null for a prompt
+ /// the caller wrote.
+ final String? chatMediaMarker;
+
/// Creates a new [GenerateRequest].
GenerateRequest(
this.contextHandle,
@@ -91,6 +95,7 @@ class GenerateRequest extends WorkerRequest {
this.cancelTokenAddress,
super.sendPort, {
this.parts,
+ this.chatMediaMarker,
});
}
diff --git a/lib/src/backends/native/native_backend.dart b/lib/src/backends/native/native_backend.dart
index 62f3bb318..3d2bfb33b 100644
--- a/lib/src/backends/native/native_backend.dart
+++ b/lib/src/backends/native/native_backend.dart
@@ -14,6 +14,7 @@ import '../../core/models/inference/tool_choice.dart';
import '../../core/models/model_format.dart';
import '../../core/models/tools/tool_definition.dart';
import '../../core/template/handlers/translate_gemma_handler.dart';
+import '../../core/template/media_placeholders.dart';
import '../backend.dart';
import '../litert_lm/litert_lm_backend.dart';
import '../llama_cpp/llama_cpp_backend.dart';
@@ -48,6 +49,7 @@ class NativeAutoBackend
BackendStatePersistenceSupport,
BackendGrammarConstraintsSupport,
BackendNativeChatGeneration,
+ BackendChatPromptGeneration,
BackendDeferredEngineCreation,
BackendTextToSpeech,
BackendDecision,
@@ -194,6 +196,32 @@ class NativeAutoBackend
);
}
+ @override
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ required String mediaMarker,
+ List? parts,
+ }) {
+ final delegate = _requireDelegate();
+ if (delegate is BackendChatPromptGeneration) {
+ return (delegate as BackendChatPromptGeneration).generateChatPrompt(
+ contextHandle,
+ prompt,
+ params,
+ mediaMarker: mediaMarker,
+ parts: parts,
+ );
+ }
+ return delegate.generate(
+ contextHandle,
+ prompt.replaceAll(mediaMarker, mtmdMediaMarker),
+ params,
+ parts: parts,
+ );
+ }
+
@override
BackendGenerationLimit? generationLimitOf(Stream> generation) {
final delegate = _delegate;
diff --git a/lib/src/backends/web/web_backend.dart b/lib/src/backends/web/web_backend.dart
index a24a16fd9..9dc0406b9 100644
--- a/lib/src/backends/web/web_backend.dart
+++ b/lib/src/backends/web/web_backend.dart
@@ -7,6 +7,7 @@ import '../../core/models/inference/generation_usage.dart';
import '../../core/models/inference/model_params.dart';
import '../../core/models/inference/next_token_scores.dart';
import '../../core/models/model_format.dart';
+import '../../core/template/media_placeholders.dart';
import '../backend.dart';
import '../litert_lm/litert_lm_backend_web.dart';
import '../webgpu/webgpu_backend.dart';
@@ -39,6 +40,7 @@ class WebAutoBackend
BackendGenerationUsageReporting,
BackendGenerationLimitReporting,
BackendGenerationLimitSupport,
+ BackendChatPromptGeneration,
BackendNextTokenScoring,
BackendNextTokenScoringSupport,
BackendStatePersistence,
@@ -277,6 +279,32 @@ class WebAutoBackend
);
}
+ @override
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ required String mediaMarker,
+ List? parts,
+ }) {
+ final delegate = _requireDelegate();
+ if (delegate is BackendChatPromptGeneration) {
+ return (delegate as BackendChatPromptGeneration).generateChatPrompt(
+ contextHandle,
+ prompt,
+ params,
+ mediaMarker: mediaMarker,
+ parts: parts,
+ );
+ }
+ return delegate.generate(
+ contextHandle,
+ prompt.replaceAll(mediaMarker, mtmdMediaMarker),
+ params,
+ parts: parts,
+ );
+ }
+
@override
void cancelGeneration() {
_delegate?.cancelGeneration();
diff --git a/lib/src/backends/webgpu/webgpu_backend.dart b/lib/src/backends/webgpu/webgpu_backend.dart
index ecd2fdca3..3d589167b 100644
--- a/lib/src/backends/webgpu/webgpu_backend.dart
+++ b/lib/src/backends/webgpu/webgpu_backend.dart
@@ -19,6 +19,7 @@ import '../../core/models/inference/generation_params.dart';
import '../../core/models/inference/generation_usage.dart';
import '../../core/models/inference/model_params.dart';
import '../../core/models/inference/next_token_scores.dart';
+import '../../core/template/media_placeholders.dart';
import '../backend.dart';
import '../model_params_loras.dart';
import '../web/webgpu_adapter_probe.dart';
@@ -54,12 +55,14 @@ class WebGpuLlamaBackend
BackendGenerationCapabilitiesSupport,
BackendGenerationUsageReporting,
BackendGenerationLimitReporting,
+ BackendChatPromptGeneration,
BackendNextTokenScoring,
BackendNextTokenScoringSupport,
BackendStatePersistence,
BackendStatePersistenceSupport,
BackendLazyGrammarSupport {
static const Duration _bridgeReadyTimeout = Duration(seconds: 12);
+
static const Duration _bridgePollInterval = Duration(milliseconds: 100);
static const int _defaultRemoteFetchChunkBytes = 4 * 1024 * 1024;
static const int _minRemoteFetchChunkBytes = minRemoteFetchChunkBytes;
@@ -1802,6 +1805,25 @@ class WebGpuLlamaBackend
}
}
+ @override
+ Stream> generateChatPrompt(
+ int contextHandle,
+ String prompt,
+ GenerationParams params, {
+ required String mediaMarker,
+ List? parts,
+ }) => generate(
+ contextHandle,
+ chatPromptForMarkerRuntime(
+ prompt,
+ chatMarker: mediaMarker,
+ marker: mtmdMediaMarker,
+ runtimePlaceholders: webGpuBridgeMediaPlaceholders,
+ ),
+ params,
+ parts: parts,
+ );
+
@override
Stream> generate(
int contextHandle,
diff --git a/lib/src/core/engine/chat_template_renderer.dart b/lib/src/core/engine/chat_template_renderer.dart
index 28d873ac2..3b1dbcd37 100644
--- a/lib/src/core/engine/chat_template_renderer.dart
+++ b/lib/src/core/engine/chat_template_renderer.dart
@@ -2,9 +2,11 @@ import '../exceptions.dart';
import '../llama_logger.dart';
import '../models/chat/chat_message.dart';
import '../models/chat/chat_template_result.dart';
+import '../models/chat/content_part.dart';
import '../models/inference/tool_choice.dart';
import '../models/tools/tool_definition.dart';
import '../template/chat_template_engine.dart';
+import '../template/media_placeholders.dart';
/// Loads model metadata for chat-template rendering.
typedef ChatTemplateMetadataLoader = Future> Function();
@@ -20,11 +22,28 @@ typedef ChatTemplateTokenizer =
class ChatTemplateRenderer {
const ChatTemplateRenderer._();
+ /// Whether [messages] carry an image, audio or video part.
+ static bool carriesMedia(List messages) => messages.any(
+ (message) => message.parts.any(
+ (part) =>
+ part is LlamaImageContent ||
+ part is LlamaAudioContent ||
+ part is LlamaVideoContent,
+ ),
+ );
+
/// Renders a chat template and optionally counts prompt tokens.
///
/// A non-empty [modelTemplate] replaces the model's `tokenizer.chat_template`
/// and its `tool_use` variant, as llama.cpp's `--chat-template` does;
/// [customTemplate] still takes precedence over both.
+ ///
+ /// A request that carries media is rendered with [chatPromptMediaMarker]
+ /// where each part was. With [keepChatMarker] the prompt keeps it, for a
+ /// backend that takes chat prompts. Otherwise the prompt is one that reads
+ /// the same through `generate`: `<__media__>` where each part was, and a
+ /// zero-width space in every other string `generate` would read as a part.
+ /// A request without media is rendered as it is.
static Future render({
required ChatTemplateMetadataLoader loadMetadata,
required ChatTemplateTokenizer tokenize,
@@ -41,6 +60,7 @@ class ChatTemplateRenderer {
bool includeTokenCount = true,
Map? chatTemplateKwargs,
DateTime? templateNow,
+ bool keepChatMarker = false,
}) async {
Map metadata = {};
try {
@@ -65,6 +85,7 @@ class ChatTemplateRenderer {
'json_schema': {'schema': jsonSchema},
});
+ final hasMedia = carriesMedia(messages);
final result = ChatTemplateEngine.render(
templateSource: templateSource,
messages: messages,
@@ -78,12 +99,19 @@ class ChatTemplateRenderer {
customTemplate: customTemplate,
chatTemplateKwargs: chatTemplateKwargs,
now: templateNow,
+ mediaMarker: hasMedia ? chatPromptMediaMarker : mtmdMediaMarker,
);
+ final prompt = hasMedia && !keepChatMarker
+ ? chatPromptAsCallerPrompt(
+ result.prompt,
+ chatMarker: chatPromptMediaMarker,
+ )
+ : result.prompt;
int? tokenCount;
if (includeTokenCount) {
try {
- final tokens = await tokenize(result.prompt, addSpecial: false);
+ final tokens = await tokenize(prompt, addSpecial: false);
tokenCount = tokens.length;
} on UnsupportedError catch (error) {
LlamaLogger.instance.debug(
@@ -99,7 +127,7 @@ class ChatTemplateRenderer {
}
return LlamaChatTemplateResult(
- prompt: result.prompt,
+ prompt: prompt,
format: result.format,
grammar: result.grammar,
grammarLazy: result.grammarLazy,
diff --git a/lib/src/core/engine/engine.dart b/lib/src/core/engine/engine.dart
index cc6b4a40e..9b9de4f93 100644
--- a/lib/src/core/engine/engine.dart
+++ b/lib/src/core/engine/engine.dart
@@ -39,6 +39,7 @@ import '../models/download/model_download_manager.dart';
import '../models/tools/tool_definition.dart';
import '../speech/speech_engine_lease.dart';
import '../template/handlers/translate_gemma_handler.dart';
+import '../template/media_placeholders.dart';
import '../url_redaction.dart';
/// Stateless chat completions engine (like OpenAI's Chat Completions API).
@@ -1625,7 +1626,8 @@ class LlamaEngine {
final effectiveToolChoice = toolChoice ?? ToolChoice.auto;
// Apply chat template with tools - returns grammar for constraining
- final result = await chatTemplate(
+ final chatMediaMarker = _chatPromptMediaMarkerFor(messages);
+ final result = await _renderChatTemplate(
messages,
tools: effectiveTools,
toolChoice: effectiveToolChoice,
@@ -1635,6 +1637,7 @@ class LlamaEngine {
chatTemplateKwargs: templateKwargs,
templateNow: templateNow,
includeTokenCount: false,
+ keepChatMarker: chatMediaMarker != null,
);
final plan = ChatCompletionRequestPlanner.build(
backend: backend,
@@ -1675,6 +1678,7 @@ class LlamaEngine {
result.prompt,
params: plan.generationParams,
parts: plan.mediaParts,
+ chatMediaMarker: chatMediaMarker,
onLimit: recordLimit,
onUsage: recordUsage,
request: request,
@@ -1783,6 +1787,13 @@ class LlamaEngine {
/// Use [LlamaStructuredOutput.responseFormat] to avoid hand-writing these
/// maps in application code.
///
+ /// For messages that carry image, audio or video parts the prompt has
+ /// `<__media__>` where each part was, and [generate] takes it with those
+ /// parts. A string in a message that [generate] would also read as a part
+ /// (`<__media__>`, ``, ` `, `[IMG]` and the like) has a
+ /// zero-width space (U+200B) after its first character in that prompt, so
+ /// it stays text. Messages without such parts render as they are.
+ ///
/// [jsonSchema] is a legacy shortcut for
/// `responseFormat: {'type': 'json_schema', 'json_schema': {'schema': ...}}`.
/// If both [responseFormat] and [jsonSchema] are provided, [responseFormat]
@@ -1818,6 +1829,41 @@ class LlamaEngine {
bool includeTokenCount = true,
Map? chatTemplateKwargs,
DateTime? templateNow,
+ }) {
+ return _renderChatTemplate(
+ messages,
+ addAssistant: addAssistant,
+ jsonSchema: jsonSchema,
+ tools: tools,
+ toolChoice: toolChoice,
+ parallelToolCalls: parallelToolCalls,
+ enableThinking: enableThinking,
+ responseFormat: responseFormat,
+ customTemplate: customTemplate,
+ includeTokenCount: includeTokenCount,
+ chatTemplateKwargs: chatTemplateKwargsWithLanguageCodes(
+ chatTemplateKwargs,
+ sourceLangCode: sourceLangCode,
+ targetLangCode: targetLangCode,
+ ),
+ templateNow: templateNow,
+ );
+ }
+
+ Future _renderChatTemplate(
+ List messages, {
+ bool addAssistant = true,
+ Map? jsonSchema,
+ List? tools,
+ ToolChoice toolChoice = ToolChoice.auto,
+ bool parallelToolCalls = false,
+ bool enableThinking = true,
+ Map? responseFormat,
+ String? customTemplate,
+ bool includeTokenCount = true,
+ Map? chatTemplateKwargs,
+ DateTime? templateNow,
+ bool keepChatMarker = false,
}) async {
_ensureReady(requireContext: false);
return ChatTemplateRenderer.render(
@@ -1834,15 +1880,21 @@ class LlamaEngine {
customTemplate: customTemplate,
modelTemplate: _modelChatTemplate,
includeTokenCount: includeTokenCount,
- chatTemplateKwargs: chatTemplateKwargsWithLanguageCodes(
- chatTemplateKwargs,
- sourceLangCode: sourceLangCode,
- targetLangCode: targetLangCode,
- ),
+ chatTemplateKwargs: chatTemplateKwargs,
templateNow: templateNow,
+ keepChatMarker: keepChatMarker,
);
}
+ /// The marker that stands for each part in the prompt [create] hands a
+ /// backend that takes chat prompts. `null` when the request has no media
+ /// or the backend takes every prompt through `generate`.
+ String? _chatPromptMediaMarkerFor(List messages) =>
+ backend is BackendChatPromptGeneration &&
+ ChatTemplateRenderer.carriesMedia(messages)
+ ? chatPromptMediaMarker
+ : null;
+
// ============================================================
// LOW-LEVEL GENERATION
// ============================================================
@@ -1923,10 +1975,13 @@ class LlamaEngine {
? LlamaOperationResult(cancelled: true, usage: usage)
: LlamaOperationResult(finishReason: finishReason, usage: usage);
+ /// With [chatMediaMarker], [prompt] is one a chat template rendered with
+ /// that marker, for a backend that takes it apart from a caller's prompt.
Stream _generate(
String prompt, {
GenerationParams params = const GenerationParams(),
List? parts,
+ String? chatMediaMarker,
void Function(BackendGenerationLimit limit)? onLimit,
void Function(LlamaGenerationUsage usage)? onUsage,
required GenerationRequest request,
@@ -1939,12 +1994,22 @@ class LlamaEngine {
_ensureReady();
try {
- final stream = backend.generate(
- _contextHandle!,
- prompt,
- resolvedParams,
- parts: parts,
- );
+ final candidate = backend;
+ final stream =
+ chatMediaMarker != null && candidate is BackendChatPromptGeneration
+ ? (candidate as BackendChatPromptGeneration).generateChatPrompt(
+ _contextHandle!,
+ prompt,
+ resolvedParams,
+ mediaMarker: chatMediaMarker,
+ parts: parts,
+ )
+ : backend.generate(
+ _contextHandle!,
+ prompt,
+ resolvedParams,
+ parts: parts,
+ );
await for (final token in _cancellableText(
stream,
diff --git a/lib/src/core/template/chat_template_engine.dart b/lib/src/core/template/chat_template_engine.dart
index 085e7bef0..7ea0bbe84 100644
--- a/lib/src/core/template/chat_template_engine.dart
+++ b/lib/src/core/template/chat_template_engine.dart
@@ -122,6 +122,10 @@ class ChatTemplateEngine {
/// If the template source is null/empty, uses the ChatML fallback.
/// [responseFormat] takes the shapes documented on `LlamaEngine.create`;
/// any other shape throws `LlamaUnsupportedException`.
+ ///
+ /// [mediaMarker] is written where each image, audio or video part was.
+ /// Pass one that message text cannot hold to tell the parts from a
+ /// placeholder string a message quotes.
static LlamaChatTemplateResult render({
required String? templateSource,
required List messages,
@@ -135,6 +139,7 @@ class ChatTemplateEngine {
String? customTemplate,
Map? chatTemplateKwargs,
DateTime? now,
+ String mediaMarker = mtmdMediaMarker,
}) {
final responseSchema = responseFormatSchema(responseFormat);
@@ -249,10 +254,11 @@ class ChatTemplateEngine {
);
}
- // Templates that also read string content get media as typed parts.
- // Templates that read only typed parts (e.g. SmolVLM's
- // `message['content'][0]['type']`) get the media marker in a text part, as
- // llama.cpp gives them.
+ // No template gets a media part: each becomes the media marker in the
+ // message text, as llama.cpp renders it. Templates that also read string
+ // content take it through renderWithMultimodalContent. Templates that
+ // read only typed parts (e.g. SmolVLM's `message['content'][0]['type']`)
+ // get it in a text part.
final hasMediaParts = effectiveMessages.any(
(message) => message.parts.any(
(part) => part is LlamaImageContent || part is LlamaAudioContent,
@@ -275,6 +281,7 @@ class ChatTemplateEngine {
addAssistant: addAssistant,
tools: effectiveTools,
enableThinking: enableThinking,
+ mediaMarker: mediaMarker,
);
if (effectiveFormat == ChatFormat.contentOnly) {
rendered = _withFormat(rendered, ChatFormat.contentOnly.index);
@@ -303,7 +310,7 @@ class ChatTemplateEngine {
parts: message.parts
.map((part) {
return isTransport(part)
- ? const LlamaTextContent(mtmdMediaMarker)
+ ? LlamaTextContent(mediaMarker)
: part;
})
.toList(growable: false),
diff --git a/lib/src/core/template/chat_template_handler.dart b/lib/src/core/template/chat_template_handler.dart
index 6422107df..9fb79893b 100644
--- a/lib/src/core/template/chat_template_handler.dart
+++ b/lib/src/core/template/chat_template_handler.dart
@@ -50,9 +50,12 @@ abstract class ChatTemplateHandler {
/// reads them as objects, and string content becomes a text part when it
/// reads content only as parts, as llama.cpp does. A handler that builds
/// typed parts itself passes `typedContent: false` to keep string content.
+ /// With [multimodal], each media part becomes [mediaMarker] in the message
+ /// text.
List> templateMessages(
List messages, {
bool multimodal = false,
+ String mediaMarker = mtmdMediaMarker,
String? templateSource,
bool typedContent = true,
}) {
@@ -64,6 +67,7 @@ abstract class ChatTemplateHandler {
messages,
toolCallSerialization: toolCallSerialization,
multimodal: multimodal,
+ mediaMarker: mediaMarker,
objectArguments: caps?.supportsObjectArguments ?? false,
typedContentOnly:
typedContent &&
@@ -159,14 +163,13 @@ abstract class ChatTemplateHandler {
});
}
- /// Re-renders with content always in list-of-parts format.
+ /// Renders a request that carries media for a template that reads both
+ /// string and typed content.
///
- /// Some templates (e.g. SmolVLM) expect `content` to be
- /// `[{type: 'text', text: '...'}, {type: 'image'}]` rather than a string.
- /// This method converts messages to multimodal format and re-renders.
- ///
- /// After rendering, replaces model-specific image placeholders with
- /// the mtmd marker `<__media__>` so the native tokenizer can find them.
+ /// Each image, audio or video part becomes [mediaMarker] in the message
+ /// text, where the part was, as llama.cpp renders it. The template's own
+ /// placeholder for a typed media part is not written, and a placeholder
+ /// string in message text stays text.
LlamaChatTemplateResult renderWithMultimodalContent({
required String templateSource,
required List messages,
@@ -174,6 +177,7 @@ abstract class ChatTemplateHandler {
bool addAssistant = true,
List? tools,
bool enableThinking = true,
+ String mediaMarker = mtmdMediaMarker,
}) {
final template = Template(templateSource);
var prompt = renderTemplate(
@@ -183,6 +187,7 @@ abstract class ChatTemplateHandler {
'messages': templateMessages(
messages,
multimodal: true,
+ mediaMarker: mediaMarker,
templateSource: templateSource,
),
'add_generation_prompt': addAssistant,
@@ -202,10 +207,6 @@ abstract class ChatTemplateHandler {
}
}
- // Post-process: replace model-specific image placeholders with
- // the mtmd marker so the native tokenizer can match bitmaps to markers.
- prompt = normalizeMediaPlaceholders(prompt);
-
final hasTools = tools != null && tools.isNotEmpty;
return LlamaChatTemplateResult(
diff --git a/lib/src/core/template/handlers/function_gemma_handler.dart b/lib/src/core/template/handlers/function_gemma_handler.dart
index f8bcea308..3ee2dde02 100644
--- a/lib/src/core/template/handlers/function_gemma_handler.dart
+++ b/lib/src/core/template/handlers/function_gemma_handler.dart
@@ -55,6 +55,7 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
bool addAssistant = true,
List? tools,
bool enableThinking = true,
+ String mediaMarker = mtmdMediaMarker,
}) {
return _renderInternal(
templateSource: templateSource,
@@ -64,6 +65,7 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
tools: tools,
enableThinking: enableThinking,
multimodalContent: true,
+ mediaMarker: mediaMarker,
);
}
@@ -75,6 +77,7 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
required List? tools,
required bool enableThinking,
required bool multimodalContent,
+ String mediaMarker = mtmdMediaMarker,
}) {
final template = Template(templateSource);
var prompt = renderTemplate(
@@ -85,6 +88,7 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
templateSource,
messages,
multimodalContent: multimodalContent,
+ mediaMarker: mediaMarker,
),
'add_generation_prompt': addAssistant,
'tools': tools?.map((t) => t.toJson()).toList(),
@@ -93,10 +97,6 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
},
);
- if (multimodalContent) {
- prompt = normalizeMediaPlaceholders(prompt);
- }
-
final hasTools = tools != null && tools.isNotEmpty;
return LlamaChatTemplateResult(
prompt: prompt,
@@ -117,11 +117,13 @@ class FunctionGemmaHandler extends ChatTemplateHandler {
String templateSource,
List messages, {
required bool multimodalContent,
+ required String mediaMarker,
}) {
final split = TemplateRenderContext.splitToolResults(messages);
final rendered = templateMessages(
split,
multimodal: multimodalContent,
+ mediaMarker: mediaMarker,
templateSource: templateSource,
);
return [
diff --git a/lib/src/core/template/handlers/gemma4_handler.dart b/lib/src/core/template/handlers/gemma4_handler.dart
index 5f17240a2..363779396 100644
--- a/lib/src/core/template/handlers/gemma4_handler.dart
+++ b/lib/src/core/template/handlers/gemma4_handler.dart
@@ -11,6 +11,7 @@ import '../../models/tools/tool_definition.dart';
import '../chat_format.dart';
import '../chat_parse_result.dart';
import '../chat_template_handler.dart';
+import '../media_placeholders.dart';
import '../template_internal_metadata.dart';
import '../thinking_utils.dart';
import '../tool_call_fallback_parser.dart';
@@ -93,6 +94,7 @@ class Gemma4Handler extends ChatTemplateHandler
bool addAssistant = true,
List? tools,
bool enableThinking = true,
+ String mediaMarker = mtmdMediaMarker,
}) {
return _renderInternal(
templateSource: templateSource,
@@ -102,6 +104,7 @@ class Gemma4Handler extends ChatTemplateHandler
tools: tools,
enableThinking: enableThinking,
multimodalContent: true,
+ mediaMarker: mediaMarker,
);
}
@@ -113,6 +116,7 @@ class Gemma4Handler extends ChatTemplateHandler
required List? tools,
required bool enableThinking,
required bool multimodalContent,
+ String mediaMarker = mtmdMediaMarker,
}) {
final template = Template(templateSource);
var prompt = renderTemplate(
@@ -123,6 +127,7 @@ class Gemma4Handler extends ChatTemplateHandler
templateSource,
messages,
multimodalContent: multimodalContent,
+ mediaMarker: mediaMarker,
),
'add_generation_prompt': addAssistant,
'tools': tools?.map((t) => t.toJson()).toList(),
@@ -164,10 +169,12 @@ class Gemma4Handler extends ChatTemplateHandler
String templateSource,
List messages, {
required bool multimodalContent,
+ required String mediaMarker,
}) {
final rendered = templateMessages(
messages,
multimodal: multimodalContent,
+ mediaMarker: mediaMarker,
templateSource: templateSource,
);
return templateSource.contains(_openAiToolMessagesMarker)
diff --git a/lib/src/core/template/jinja/jinja_analyzer.dart b/lib/src/core/template/jinja/jinja_analyzer.dart
index 11c0d5a26..4b0838d92 100644
--- a/lib/src/core/template/jinja/jinja_analyzer.dart
+++ b/lib/src/core/template/jinja/jinja_analyzer.dart
@@ -24,8 +24,9 @@ class JinjaAnalyzer {
///
/// The media-part probe is not llama.cpp's: a template that reads both
/// strings and part lists is rendered with an image part and with an audio
- /// part, and `supportsTypedContent` is cleared when it rejects both. The
- /// only part lists `ChatTemplateEngine` gives such a template carry media.
+ /// part, and `supportsTypedContent` is cleared when it rejects both.
+ /// `ChatTemplateEngine` gives no template a media part; the probe only
+ /// selects the handler method that renders a request carrying media.
///
/// A probe render that throws is one of llama.cpp's outcomes, not a
/// failure: it is logged at debug level and read as llama.cpp reads it.
@@ -105,9 +106,9 @@ class JinjaAnalyzer {
}
}
- // A template that reads strings too is given a part list only to carry
- // media. One that reads text part lists but rejects both media kinds is
- // given strings, with the media marker in the text.
+ // A template that reads strings too and rejects both media kinds as
+ // typed parts renders a request carrying media as every string template
+ // does. Either way it gets the media marker in the message text.
if (supportsTypedContent && supportsStringContent) {
bool rejects(String type) => !_render(
probe,
diff --git a/lib/src/core/template/media_placeholders.dart b/lib/src/core/template/media_placeholders.dart
index 5f22dcfc4..f0fefc03d 100644
--- a/lib/src/core/template/media_placeholders.dart
+++ b/lib/src/core/template/media_placeholders.dart
@@ -1,15 +1,26 @@
-/// Shared media-placeholder normalization for multimodal prompts.
-///
-/// Both the chat-template handlers and the llama.cpp service normalize, so the
-/// table lives here to keep them in step.
+/// Media markers and the placeholders a caller may write in its own prompt.
library;
-/// The mtmd marker the native tokenizer matches media parts against.
-///
-/// The llama.cpp service prefers the runtime-reported marker and falls back to
-/// this when the symbol is unavailable.
+import 'dart:math';
+
+/// The marker a chat template renders where a media part was, and one of the
+/// placeholders a caller may write in a prompt it passes to `generate`.
const String mtmdMediaMarker = '<__media__>';
+/// The marker `LlamaEngine` renders a chat request with for a backend that
+/// takes it through `BackendChatPromptGeneration`: one that message text
+/// cannot hold by accident, as llama.cpp's server draws one for each process.
+final String chatPromptMediaMarker = () {
+ const alphabet =
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+ final random = Random.secure();
+ final id = String.fromCharCodes([
+ for (var i = 0; i < 32; i++)
+ alphabet.codeUnitAt(random.nextInt(alphabet.length)),
+ ]);
+ return '<__media_${id}__>';
+}();
+
/// Model-specific media placeholders rewritten to [mtmdMediaMarker].
const List mtmdMediaPlaceholders = [
'', // SmolVLM, InternVL, etc.
@@ -28,7 +39,31 @@ const List mtmdMediaPlaceholders = [
/// Indexed image placeholders such as `<|image_1|>`, used by some VLM templates.
final RegExp mtmdIndexedImagePlaceholder = RegExp(r'<\|image_\d+\|>');
-/// Rewrites every known media placeholder in [prompt] to [marker].
+/// What the WebGPU bridge reads as a media part wherever it is in a prompt
+/// that comes with parts: its marker and the placeholders the pinned assets
+/// rewrite to it. It has no option that turns this off.
+final RegExp webGpuBridgeMediaPlaceholders = RegExp(
+ r'<__media__>||\[IMG\]|<\|image\|>| |<\|img\|>'
+ r'|<\|vision_start\|><\|(?:image|video)_pad\|><\|vision_end\|>'
+ r'||<\|audio\|>|<\|(?:image|audio)_\d+\|>',
+);
+
+/// Every string that a backend's `generate` reads as a media part in a
+/// prompt its caller wrote: what [normalizeMediaPlaceholders] rewrites and
+/// what [webGpuBridgeMediaPlaceholders] matches, [mtmdMediaMarker] among it.
+final RegExp callerPromptMediaPlaceholders = RegExp(
+ [
+ ...mtmdMediaPlaceholders.map(RegExp.escape),
+ mtmdIndexedImagePlaceholder.pattern,
+ webGpuBridgeMediaPlaceholders.pattern,
+ ].join('|'),
+);
+
+/// Rewrites every media placeholder a caller wrote in its [prompt] to
+/// [marker].
+///
+/// Not for a prompt a chat template rendered: there a placeholder string is
+/// message text, and [chatPromptForMarkerRuntime] keeps it so.
String normalizeMediaPlaceholders(
String prompt, {
String marker = mtmdMediaMarker,
@@ -39,3 +74,38 @@ String normalizeMediaPlaceholders(
}
return normalized.replaceAll(mtmdIndexedImagePlaceholder, marker);
}
+
+/// Turns a chat-rendered [prompt] into the one a runtime reads that finds
+/// media by substring: [marker] where [chatMarker] stood for a media part.
+///
+/// Such a runtime has no way to take a string it matches as text, so each
+/// match of [runtimePlaceholders] in the text between the parts gets a
+/// zero-width space after its first character. llama.cpp's server leaves
+/// that text as it is, having a marker of its own for each process.
+String chatPromptForMarkerRuntime(
+ String prompt, {
+ required String chatMarker,
+ required String marker,
+ required Pattern runtimePlaceholders,
+}) {
+ return prompt
+ .split(chatMarker)
+ .map(
+ (text) => text.replaceAllMapped(runtimePlaceholders, (match) {
+ final placeholder = match[0]!;
+ return '${placeholder[0]}\u200B${placeholder.substring(1)}';
+ }),
+ )
+ .join(marker);
+}
+
+/// Turns a [prompt] that a chat template rendered with [chatMarker] into one
+/// that reads the same as a caller's prompt: [mtmdMediaMarker] where each
+/// part was, and no other string that `generate` would read as a part.
+String chatPromptAsCallerPrompt(String prompt, {required String chatMarker}) =>
+ chatPromptForMarkerRuntime(
+ prompt,
+ chatMarker: chatMarker,
+ marker: mtmdMediaMarker,
+ runtimePlaceholders: callerPromptMediaPlaceholders,
+ );
diff --git a/lib/src/core/template/template_render_context.dart b/lib/src/core/template/template_render_context.dart
index 9a34b8e70..a21b3b888 100644
--- a/lib/src/core/template/template_render_context.dart
+++ b/lib/src/core/template/template_render_context.dart
@@ -3,6 +3,7 @@ import 'dart:convert';
import '../models/chat/chat_message.dart';
import '../models/chat/chat_role.dart';
import '../models/chat/content_part.dart';
+import 'media_placeholders.dart';
import 'tool_call_parsing_utils.dart';
/// Tool-call serialization policy for template render contexts.
@@ -81,6 +82,12 @@ class TemplateRenderContext {
/// unchanged. A message with several tool results becomes one message per
/// result, as [splitToolResults] describes.
///
+ /// With [multimodal], the text of a message holds [mediaMarker] where each
+ /// image, audio or video part was. llama.cpp also gives a template the
+ /// marker and never the media part: the placeholder a template writes for a
+ /// typed image part is not the marker mtmd matches, and mtmd adds the image
+ /// begin and end tokens itself.
+ ///
/// When [typedContentOnly] marks a template that reads content only as a
/// list of parts, every string `content` becomes a list holding one text
/// part, as llama.cpp's `messages_inp_normalizer` does.
@@ -93,15 +100,16 @@ class TemplateRenderContext {
TemplateToolCallSerialization toolCallSerialization =
TemplateToolCallSerialization.none,
bool multimodal = false,
+ String mediaMarker = mtmdMediaMarker,
bool objectArguments = false,
bool typedContentOnly = false,
}) {
final renderedMessages = >[];
var hasToolCalls = false;
for (final message in splitToolResults(messages)) {
- final rendered = multimodal
- ? message.toJsonMultimodal()
- : message.toJson();
+ final rendered =
+ (multimodal ? _withMediaMarkers(message, mediaMarker) : message)
+ .toJson();
rendered['content'] ??= '';
final toolResults = message.parts.whereType();
if (toolResults.isNotEmpty) {
@@ -145,6 +153,23 @@ class TemplateRenderContext {
return renderedMessages;
}
+ static LlamaChatMessage _withMediaMarkers(
+ LlamaChatMessage message,
+ String mediaMarker,
+ ) {
+ bool isMedia(LlamaContentPart part) =>
+ part is LlamaImageContent ||
+ part is LlamaAudioContent ||
+ part is LlamaVideoContent;
+ if (!message.parts.any(isMedia)) return message;
+ return message.copyWith(
+ parts: [
+ for (final part in message.parts)
+ isMedia(part) ? LlamaTextContent(mediaMarker) : part,
+ ],
+ );
+ }
+
static void _decodeObjectArguments(List> messages) {
for (final message in messages) {
final toolCalls = message['tool_calls'];
diff --git a/test/fixtures/media_marker_render_upstream.json b/test/fixtures/media_marker_render_upstream.json
new file mode 100644
index 000000000..5b4d43fc5
--- /dev/null
+++ b/test/fixtures/media_marker_render_upstream.json
@@ -0,0 +1,1483 @@
+{
+ "upstream_commit": "d81235049",
+ "endpoint": "POST /apply-template",
+ "vision_model": "LFM2-VL-450M-Q4_0.gguf",
+ "vision_model_sha256": "1fbf4797e8669cdeabd97fa1d31ab046907cb1fc78b1c3d4bda1ba879574e5d7",
+ "vision_mmproj": "mmproj-LFM2-VL-450M-Q8_0.gguf",
+ "vision_mmproj_sha256": "a6a813fae4ba3f90852a990fdd4786a017dba0e80e599a366853ba539ee2b5ef",
+ "audio_model": "Llama-3.2-1B-Instruct-Q4_K_M.gguf",
+ "audio_model_sha256": "6f85a640a97cf2bf5b8e764087b1e83da0fdb51d7c9fab7d0fece9385611df83",
+ "audio_mmproj": "mmproj-ultravox-v0_5-llama-3_2-1b-f16.gguf",
+ "audio_mmproj_sha256": "b34dde1835752949d6b960528269af93c92fec91c61ea0534fcc73f96c1ed8b2",
+ "image_png_base64": "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAEklEQVR4nGP4z8CAFWEXHbQSACj/P8Fu7N9hAAAAAElFTkSuQmCC",
+ "audio_wav_base64": "UklGRqQMAABXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YYAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
+ "conversations": {
+ "image_then_text": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "text_then_image": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "text": "What color is this image? Answer with one word."
+ },
+ {
+ "image": true
+ }
+ ]
+ }
+ ],
+ "two_images_then_text": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "image": true
+ },
+ {
+ "text": "What are the colors of the first and second image? Answer with two words."
+ }
+ ]
+ }
+ ],
+ "interleaved_two_images": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "text": "First:"
+ },
+ {
+ "image": true
+ },
+ {
+ "text": "Second:"
+ },
+ {
+ "image": true
+ },
+ {
+ "text": "What are the colors of the first and second image? Answer with two words."
+ }
+ ]
+ }
+ ],
+ "image_only": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ }
+ ]
+ }
+ ],
+ "image_in_later_turn": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "text": "Hello."
+ }
+ ]
+ },
+ {
+ "role": "assistant",
+ "parts": [
+ {
+ "text": "Hi! How can I help?"
+ }
+ ]
+ },
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "system_and_image": [
+ {
+ "role": "system",
+ "parts": [
+ {
+ "text": "You are a concise assistant."
+ }
+ ]
+ },
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "literal_img_in_user_text": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "Why is my tag not rendering? Also, what color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "literal_image_in_system": [
+ {
+ "role": "system",
+ "parts": [
+ {
+ "text": "You are a concise assistant. Never write an tag."
+ }
+ ]
+ },
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "literal_img_in_assistant_turn": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "text": "How do I mark an image in Mistral prompts?"
+ }
+ ]
+ },
+ {
+ "role": "assistant",
+ "parts": [
+ {
+ "text": "Write [IMG] where the image goes."
+ }
+ ]
+ },
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "literal_marker_in_user_text": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "literal_img_with_two_images": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "image": true
+ },
+ {
+ "text": "Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words."
+ }
+ ]
+ }
+ ],
+ "two_literals_one_image": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "image": true
+ },
+ {
+ "text": "Is or the HTML tag? Also, what color is this image? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "audio_then_text": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "audio": true
+ },
+ {
+ "text": "What do you hear? Answer with one word."
+ }
+ ]
+ }
+ ],
+ "text_then_audio": [
+ {
+ "role": "user",
+ "parts": [
+ {
+ "text": "What do you hear? Answer with one word."
+ },
+ {
+ "audio": true
+ }
+ ]
+ }
+ ]
+ },
+ "cases": [
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nWhat color is this image? Answer with one word.<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__><|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__><__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nFirst:<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>Second:<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__><|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nHello.<|im_end|>\n<|im_start|>assistant\nHi! How can I help?<|im_end|>\n<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant.<|im_end|>\n<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>Why is my tag not rendering? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant. Never write an tag.<|im_end|>\n<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nHow do I mark an image in Mistral prompts?<|im_end|>\n<|im_start|>assistant\nWrite [IMG] where the image goes.<|im_end|>\n<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__><__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/Qwen3_5-0_8B.jinja",
+ "template_sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_vlEIh6FOGVDCQUzWJqsxNXWQsxik36BC__>Is or the HTML tag? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nWhat color is this image? Answer with one word.<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__><__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nFirst:<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>Second:<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nHello.\nmodel\nHi! How can I help?\nuser\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nYou are a concise assistant.\n\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>Why is my tag not rendering? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nYou are a concise assistant. Never write an tag.\n\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nHow do I mark an image in Mistral prompts?\nmodel\nWrite [IMG] where the image goes.\nuser\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__><__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3-4b-it.jinja",
+ "template_sha256": "7de1c58e208eda46e9c7f86397df37ec49883aeece39fb961e0a6b24088dd3c4",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_mmHhHzFN5Ge6iDWBIYUbmSLtTIjmHo0F__>Is or the HTML tag? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nWhat color is this image? Answer with one word.<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__><__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nFirst:<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>Second:<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nHello.\nmodel\nHi! How can I help?\nuser\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nYou are a concise assistant.\n\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>Why is my tag not rendering? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nYou are a concise assistant. Never write an tag.\n\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nHow do I mark an image in Mistral prompts?\nmodel\nWrite [IMG] where the image goes.\nuser\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__><__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_pcwz90MoX2aHi3LKrU7Pgn5hN3xGrjUr__>Is or the HTML tag? Also, what color is this image? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "audio_then_text",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_MKiuWuSMv50i2icx1uQGUwCl5wQaq1z2__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\n<__media_MKiuWuSMv50i2icx1uQGUwCl5wQaq1z2__>What do you hear? Answer with one word.\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-3n-E4B-it.jinja",
+ "template_sha256": "ac03dcb3b09726f1e50ac55ae58fc8d5930eadc3b3a12cb04286dc1d82ac8001",
+ "conversation": "text_then_audio",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_MKiuWuSMv50i2icx1uQGUwCl5wQaq1z2__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "user\nWhat do you hear? Answer with one word.<__media_MKiuWuSMv50i2icx1uQGUwCl5wQaq1z2__>\nmodel\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\nWhat color is this image? Answer with one word.<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__><__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What are the colors of the first and second image? Answer with two words.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\nFirst:<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>Second:<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What are the colors of the first and second image? Answer with two words.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\nHello.\n<|turn>model\nHi! How can I help?\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\nYou are a concise assistant.\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>Why is my tag not rendering? Also, what color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\nYou are a concise assistant. Never write an tag.\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\nHow do I mark an image in Mistral prompts?\n<|turn>model\nWrite [IMG] where the image goes.\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__><__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_qgpo3V5KpIRdbjrBMkEYQPUQgPH4X14y__>Is or the HTML tag? Also, what color is this image? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "audio_then_text",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_mmEOZ61tze1uhFeBl7CMphOz0j3pRol5__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\n<__media_mmEOZ61tze1uhFeBl7CMphOz0j3pRol5__>What do you hear? Answer with one word.\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/gemma-4-E2B-it.jinja",
+ "template_sha256": "33204f1acb5bd0002713e16a593847f24ceeafe711ed88bda2a352dc996a3373",
+ "conversation": "text_then_audio",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_mmEOZ61tze1uhFeBl7CMphOz0j3pRol5__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|turn>system\n<|think|>\n\n<|turn>user\nWhat do you hear? Answer with one word.<__media_mmEOZ61tze1uhFeBl7CMphOz0j3pRol5__>\n<|turn>model\n"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: What color is this image? Answer with one word.<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__><__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What are the colors of the first and second image? Answer with two words.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: First:<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>Second:<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What are the colors of the first and second image? Answer with two words.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: Hello.\nAssistant: Hi! How can I help?\nUser: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>System: You are a concise assistant.\nUser: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>Why is my tag not rendering? Also, what color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>System: You are a concise assistant. Never write an tag.\nUser: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: How do I mark an image in Mistral prompts?\nAssistant: Write [IMG] where the image goes.\nUser: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__><__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/templates/SmolVLM-500M-Instruct.jinja",
+ "template_sha256": "830005085ddd94cec605b6e21b885b28ffad6e3f82ee6a212c523533e8f04f01",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>",
+ "supports_string_content": false,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>User: <__media_zrDogH3YQzwVfAgcEDwCR8qABgr60Pd1__>Is or the HTML tag? Also, what color is this image? Answer with one word.\nAssistant:"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nWhat color is this image? Answer with one word.<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__><|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__><__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nFirst:<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>Second:<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__><|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nHello.<|im_end|>\n<|im_start|>assistant\nHi! How can I help?<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>Why is my tag not rendering? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant. Never write an tag.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nHow do I mark an image in Mistral prompts?<|im_end|>\n<|im_start|>assistant\nWrite [IMG] where the image goes.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__><__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>Why is my tag not rendering? Also, what are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "two_literals_one_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_YknxKhWsBl8CLTzn0QNUr8UMKOhlqieL__>Is or the HTML tag? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "audio_then_text",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_taLuD1uu7FpL29l92RS9e6yLxO8SjFpB__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\n<__media_taLuD1uu7FpL29l92RS9e6yLxO8SjFpB__>What do you hear? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/Qwen2_5-Omni-3B.jinja",
+ "template_sha256": "d027e14db2e64eb2c23597240d42ea747b4fd5efd6e6a7604a990949c610f79c",
+ "conversation": "text_then_audio",
+ "media_model": "audio",
+ "eos_token": "<|eot_id|>",
+ "media_marker": "<__media_taLuD1uu7FpL29l92RS9e6yLxO8SjFpB__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nWhat do you hear? Answer with one word.<__media_taLuD1uu7FpL29l92RS9e6yLxO8SjFpB__><|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "image_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "text_then_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nWhat color is this image? Answer with one word.<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__><|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "two_images_then_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__><__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "interleaved_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nFirst:<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>Second:<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What are the colors of the first and second image? Answer with two words.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "image_only",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__><|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "image_in_later_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nHello.<|im_end|>\n<|im_start|>assistant\nHi! How can I help?<|im_end|>\n<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "system_and_image",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant.<|im_end|>\n<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "literal_img_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>Why is my tag not rendering? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "literal_image_in_system",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>system\nYou are a concise assistant. Never write an tag.<|im_end|>\n<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "literal_img_in_assistant_turn",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\nHow do I mark an image in Mistral prompts?<|im_end|>\n<|im_start|>assistant\nWrite [IMG] where the image goes.<|im_end|>\n<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "literal_marker_in_user_text",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>What does <__media__> mean in llama.cpp? Also, what color is this image? Answer with one word.<|im_end|>\n<|im_start|>assistant\n"
+ },
+ {
+ "template": "test/fixtures/media_templates/LFM2-VL-450M.jinja",
+ "template_sha256": "cf0af741b36248dfe460af825b0b3acb3c651cf7dd40a74c29447f60b75d2b9b",
+ "conversation": "literal_img_with_two_images",
+ "media_model": "vision",
+ "eos_token": "<|im_end|>",
+ "media_marker": "<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>",
+ "supports_string_content": true,
+ "supports_typed_content": true,
+ "prompt": "<|im_start|>user\n<__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__><__media_F6NriYkwKe1HbIdawbxLr2dIVbCl5uSr__>Why is my