common/chat : preserve media markers for typed-content templates (#22634)
This commit is contained in:
+1
-1
@@ -80,7 +80,7 @@ json common_chat_msg::to_json_oaicompat(bool concat_typed_text) const {
|
|||||||
if (!content.empty()) {
|
if (!content.empty()) {
|
||||||
jmsg["content"] = content;
|
jmsg["content"] = content;
|
||||||
} else if (!content_parts.empty()) {
|
} else if (!content_parts.empty()) {
|
||||||
if (concat_typed_text) {
|
if (concat_typed_text || contains_media()) {
|
||||||
std::string text;
|
std::string text;
|
||||||
bool last_was_media_marker = false;
|
bool last_was_media_marker = false;
|
||||||
// join parts with newline, do not add newline before or after media markers
|
// join parts with newline, do not add newline before or after media markers
|
||||||
|
|||||||
@@ -94,6 +94,15 @@ struct common_chat_msg {
|
|||||||
tool_name.empty() && tool_call_id.empty();
|
tool_name.empty() && tool_call_id.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool contains_media() const {
|
||||||
|
for (const auto & part : content_parts) {
|
||||||
|
if (part.type == "media_marker") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void set_tool_call_ids(std::vector<std::string> & ids_cache,
|
void set_tool_call_ids(std::vector<std::string> & ids_cache,
|
||||||
const std::function<std::string()> & gen_tool_call_id) {
|
const std::function<std::string()> & gen_tool_call_id) {
|
||||||
for (auto i = 0u; i < tool_calls.size(); i++) {
|
for (auto i = 0u; i < tool_calls.size(); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user