Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tools/server/server-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ std::string gen_tool_call_id() {
return random_string();
}

static std::string media_marker = "";
const char * get_media_marker() {
if (media_marker.empty()) {
media_marker = "<__media_" + random_string() + "__>";
}
return media_marker.c_str();
static const std::string marker = []() {
// allow user to pin a reproducible marker via env var
const char * env = getenv("LLAMA_MEDIA_MARKER");
if (env && env[0] != '\0') {
return std::string(env);
}
return std::string("<__media_") + random_string() + "__>";
}();
return marker.c_str();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
}


//
Expand Down
1 change: 1 addition & 0 deletions tools/server/tests/unit/test_vision_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def get_img_url(id: str) -> str:
@pytest.fixture(autouse=True)
def create_server():
global server
os.environ['LLAMA_MEDIA_MARKER'] = '<__media__>'
server = ServerPreset.tinygemma3()

def test_models_supports_multimodal_capability():
Expand Down
Loading