MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / format_oai_sse

Function format_oai_sse

tools/server/server-common.cpp:1347–1364  ·  view source on GitHub ↗

format server-sent event (SSE), return the formatted string to send note: if data is a json array, it will be sent as multiple events, one per item

Source from the content-addressed store, hash-verified

1345// format server-sent event (SSE), return the formatted string to send
1346// note: if data is a json array, it will be sent as multiple events, one per item
1347std::string format_oai_sse(const json & data) {
1348 std::ostringstream ss;
1349 auto send_single = [&ss](const json & data) {
1350 ss << "data: " <<
1351 safe_json_to_str(data) <<
1352 "\n\n"; // required by RFC 8895 - A message is terminated by a blank line (two line terminators in a row).
1353 };
1354
1355 if (data.is_array()) {
1356 for (const auto & item : data) {
1357 send_single(item);
1358 }
1359 } else {
1360 send_single(data);
1361 }
1362
1363 return ss.str();
1364}
1365
1366std::string format_oai_resp_sse(const json & data) {
1367 std::ostringstream ss;

Callers 1

Calls 2

safe_json_to_strFunction · 0.85
strMethod · 0.45

Tested by

no test coverage detected