server: tests: fetch random media marker via /apply-template (#21962)#21980
Merged
ggerganov merged 5 commits intoggml-org:masterfrom Apr 16, 2026
Merged
server: tests: fetch random media marker via /apply-template (#21962)#21980ggerganov merged 5 commits intoggml-org:masterfrom
ggerganov merged 5 commits intoggml-org:masterfrom
Conversation
Contributor
Author
|
cc @ngxson if you prefer a separate helper let me know |
CISC
approved these changes
Apr 16, 2026
Contributor
|
Actually I think allowing user to set the marker would be a more flexible approach. Maybe we can add a logic in |
get_media_marker() checks LLAMA_MEDIA_MARKER at first call and uses it as-is if set, falling back to the random marker otherwise. Tests no longer need to fetch the marker dynamically via /apply-template: the fixture sets LLAMA_MEDIA_MARKER=<__media__> so the hardcoded prompts work as before. Address review feedback from ngxson
ggerganov
approved these changes
Apr 16, 2026
| } | ||
| } | ||
| return media_marker.c_str(); | ||
| } |
Member
There was a problem hiding this comment.
Make get_media_marker() thread-safe like this:
const char * get_media_marker() {
static const std::string media_marker = []() {
// allow user to pin a reproducible marker via env var (useful for tests and external pipelines)
const char * env = getenv("LLAMA_MEDIA_MARKER");
if (env && env[0] != '\0') {
return std::string(env);
} else {
return std::string("<__media_") + random_string() + "__>";
}
}();
return media_marker.c_str();
}Use a C++11 static local with a lambda initializer instead of a global static with an empty-check. The runtime guarantees initialization exactly once without explicit locking. Address review feedback from ggerganov
ngxson
approved these changes
Apr 16, 2026
cnsiva
pushed a commit
to saas-home/llama.cpp
that referenced
this pull request
Apr 17, 2026
…g#21962) (ggml-org#21980) * server: tests: fetch random media marker via /apply-template (ggml-org#21962 fix) * server: allow pinning media marker via LLAMA_MEDIA_MARKER env var get_media_marker() checks LLAMA_MEDIA_MARKER at first call and uses it as-is if set, falling back to the random marker otherwise. Tests no longer need to fetch the marker dynamically via /apply-template: the fixture sets LLAMA_MEDIA_MARKER=<__media__> so the hardcoded prompts work as before. Address review feedback from ngxson * server: make get_media_marker() thread-safe via magic statics Use a C++11 static local with a lambda initializer instead of a global static with an empty-check. The runtime guarantees initialization exactly once without explicit locking. Address review feedback from ggerganov * nits * nits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fix CI
Requirements