mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-05 23:41:45 +00:00
server: use random media marker (#21962)
* server: use random media marker * nits * remove legacy <__image__> token * revert special char in random
This commit is contained in:
parent
b3d758750a
commit
408225bb1a
5 changed files with 17 additions and 11 deletions
|
|
@ -84,6 +84,14 @@ 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();
|
||||
}
|
||||
|
||||
//
|
||||
// lora utils
|
||||
//
|
||||
|
|
@ -975,7 +983,7 @@ json oaicompat_chat_params_parse(
|
|||
handle_media(out_files, image_url, opt.media_path);
|
||||
|
||||
p["type"] = "media_marker";
|
||||
p["text"] = mtmd_default_marker();
|
||||
p["text"] = get_media_marker();
|
||||
p.erase("image_url");
|
||||
|
||||
} else if (type == "input_audio") {
|
||||
|
|
@ -996,7 +1004,7 @@ json oaicompat_chat_params_parse(
|
|||
// TODO: add audio_url support by reusing handle_media()
|
||||
|
||||
p["type"] = "media_marker";
|
||||
p["text"] = mtmd_default_marker();
|
||||
p["text"] = get_media_marker();
|
||||
p.erase("input_audio");
|
||||
|
||||
} else if (type != "text") {
|
||||
|
|
@ -1460,7 +1468,7 @@ json convert_transcriptions_to_chatcmpl(
|
|||
if (!language.empty()) {
|
||||
prompt += string_format(" (language: %s)", language.c_str());
|
||||
}
|
||||
prompt += mtmd_default_marker();
|
||||
prompt += get_media_marker();
|
||||
|
||||
json chatcmpl_body = inp_body; // copy all fields
|
||||
chatcmpl_body["messages"] = json::array({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue