File tree 4 files changed +13
-9
lines changed 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -283,8 +283,8 @@ int main(int argc, char ** argv) {
283
283
284
284
if (is_single_turn) {
285
285
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 () ;
288
288
}
289
289
common_chat_msg msg;
290
290
msg.role = " user" ;
@@ -348,7 +348,7 @@ int main(int argc, char ** argv) {
348
348
std::string media_path = line.substr (7 );
349
349
if (ctx.load_media (media_path)) {
350
350
LOG (" %s %s loaded\n " , media_path.c_str (), is_image ? " image" : " audio" );
351
- content += MTMD_DEFAULT_MEDIA_MARKER ;
351
+ content += mtmd_default_marker () ;
352
352
}
353
353
// else, error is already printed by libmtmd
354
354
continue ;
Original file line number Diff line number Diff line change @@ -79,14 +79,18 @@ enum mtmd_slice_tmpl {
79
79
// TODO @ngxson : add support for idefics (SmolVLM)
80
80
};
81
81
82
+ const char * mtmd_default_marker () {
83
+ return " <__media__>" ;
84
+ }
85
+
82
86
mtmd_context_params mtmd_context_params_default () {
83
87
mtmd_context_params params;
84
88
params.use_gpu = true ;
85
89
params.print_timings = true ;
86
90
params.n_threads = 4 ;
87
91
params.verbosity = GGML_LOG_LEVEL_INFO;
88
92
params.image_marker = MTMD_DEFAULT_IMAGE_MARKER;
89
- params.media_marker = MTMD_DEFAULT_MEDIA_MARKER ;
93
+ params.media_marker = mtmd_default_marker () ;
90
94
return params;
91
95
}
92
96
Original file line number Diff line number Diff line change 39
39
# define MTMD_API
40
40
#endif
41
41
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
45
43
#define MTMD_DEFAULT_IMAGE_MARKER " <__image__>"
46
44
47
45
#ifdef __cplusplus
@@ -87,6 +85,8 @@ struct mtmd_context_params {
87
85
const char * media_marker;
88
86
};
89
87
88
+ MTMD_API const char * mtmd_default_marker (void );
89
+
90
90
MTMD_API struct mtmd_context_params mtmd_context_params_default (void );
91
91
92
92
// initialize the mtmd context
@@ -172,7 +172,7 @@ MTMD_API llama_pos mtmd_image_tokens_get_n_pos (const mtmd_image_tokens * i
172
172
173
173
// tokenize an input text prompt and a list of bitmaps (images/audio)
174
174
// 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()
176
176
// the marker will be replaced with the image/audio chunk
177
177
// for example:
178
178
// "here is an image: <__media__>\ndescribe it in detail."
Original file line number Diff line number Diff line change @@ -710,7 +710,7 @@ static json oaicompat_completion_params_parse(
710
710
711
711
// replace this chunk with a marker
712
712
p[" type" ] = " text" ;
713
- p[" text" ] = MTMD_DEFAULT_MEDIA_MARKER ;
713
+ p[" text" ] = mtmd_default_marker () ;
714
714
p.erase (" image_url" );
715
715
}
716
716
}
You can’t perform that action at this time.
0 commit comments