Skip to content

Commit 107790a

Browse files
committed
mtmd_default_marker()
1 parent 9afb3af commit 107790a

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

tools/mtmd/mtmd-cli.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ int main(int argc, char ** argv) {
283283

284284
if (is_single_turn) {
285285
g_is_generating = true;
286-
if (params.prompt.find(MTMD_DEFAULT_MEDIA_MARKER) == std::string::npos) {
287-
params.prompt += MTMD_DEFAULT_MEDIA_MARKER;
286+
if (params.prompt.find(mtmd_default_marker()) == std::string::npos) {
287+
params.prompt += mtmd_default_marker();
288288
}
289289
common_chat_msg msg;
290290
msg.role = "user";
@@ -348,7 +348,7 @@ int main(int argc, char ** argv) {
348348
std::string media_path = line.substr(7);
349349
if (ctx.load_media(media_path)) {
350350
LOG("%s %s loaded\n", media_path.c_str(), is_image ? "image" : "audio");
351-
content += MTMD_DEFAULT_MEDIA_MARKER;
351+
content += mtmd_default_marker();
352352
}
353353
// else, error is already printed by libmtmd
354354
continue;

tools/mtmd/mtmd.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ enum mtmd_slice_tmpl {
7979
// TODO @ngxson : add support for idefics (SmolVLM)
8080
};
8181

82+
const char * mtmd_default_marker() {
83+
return "<__media__>";
84+
}
85+
8286
mtmd_context_params mtmd_context_params_default() {
8387
mtmd_context_params params;
8488
params.use_gpu = true;
8589
params.print_timings = true;
8690
params.n_threads = 4;
8791
params.verbosity = GGML_LOG_LEVEL_INFO;
8892
params.image_marker = MTMD_DEFAULT_IMAGE_MARKER;
89-
params.media_marker = MTMD_DEFAULT_MEDIA_MARKER;
93+
params.media_marker = mtmd_default_marker();
9094
return params;
9195
}
9296

tools/mtmd/mtmd.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
# define MTMD_API
4040
#endif
4141

42-
#define MTMD_DEFAULT_MEDIA_MARKER "<__media__>"
43-
44-
// deprecated marker, use MTMD_DEFAULT_MEDIA_MARKER instead
42+
// deprecated marker, use mtmd_default_marker() instead
4543
#define MTMD_DEFAULT_IMAGE_MARKER "<__image__>"
4644

4745
#ifdef __cplusplus
@@ -87,6 +85,8 @@ struct mtmd_context_params {
8785
const char * media_marker;
8886
};
8987

88+
MTMD_API const char * mtmd_default_marker(void);
89+
9090
MTMD_API struct mtmd_context_params mtmd_context_params_default(void);
9191

9292
// initialize the mtmd context
@@ -172,7 +172,7 @@ MTMD_API llama_pos mtmd_image_tokens_get_n_pos (const mtmd_image_tokens * i
172172

173173
// tokenize an input text prompt and a list of bitmaps (images/audio)
174174
// the prompt must have the input image marker (default: "<__media__>") in it
175-
// the default marker is defined by MTMD_DEFAULT_MEDIA_MARKER
175+
// the default marker is defined by mtmd_default_marker()
176176
// the marker will be replaced with the image/audio chunk
177177
// for example:
178178
// "here is an image: <__media__>\ndescribe it in detail."

tools/server/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ static json oaicompat_completion_params_parse(
710710

711711
// replace this chunk with a marker
712712
p["type"] = "text";
713-
p["text"] = MTMD_DEFAULT_MEDIA_MARKER;
713+
p["text"] = mtmd_default_marker();
714714
p.erase("image_url");
715715
}
716716
}

0 commit comments

Comments
 (0)