File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Expand file tree Collapse file tree 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) {
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 ;
Original file line number Diff line number Diff 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+
8286mtmd_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
Original file line number Diff line number Diff line change 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+
9090MTMD_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."
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments