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

Method to_json_oaicompat_resp

tools/server/server-task.cpp:930–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928}
929
930json server_task_result_cmpl_final::to_json_oaicompat_resp() {
931 common_chat_msg msg;
932 if (!oaicompat_msg.empty()) {
933 msg = oaicompat_msg;
934 } else {
935 msg.role = "assistant";
936 msg.content = content;
937 }
938
939 std::vector<json> output;
940
941 if (msg.reasoning_content != "") {
942 output.push_back(json {
943 {"id", "rs_" + random_string()},
944 {"summary", json::array()},
945 {"type", "reasoning"},
946 {"content", json::array({ json {
947 {"text", msg.reasoning_content},
948 {"type", "reasoning_text"},
949 }})},
950 {"encrypted_content", ""},
951 {"status", "completed"},
952 });
953 }
954
955 if (msg.content != "") {
956 output.push_back(json {
957 {"content", json::array({ json {
958 {"type", "output_text"},
959 {"annotations", json::array()},
960 {"logprobs", json::array()},
961 {"text", msg.content},
962 }})},
963 {"id", "msg_" + random_string()},
964 {"role", msg.role},
965 {"status", "completed"},
966 {"type", "message"},
967 });
968 }
969
970 for (const common_chat_tool_call & tool_call : oaicompat_msg.tool_calls) {
971 output.push_back(json {
972 {"type", "function_call"},
973 {"status", "completed"},
974 {"arguments", tool_call.arguments},
975 {"call_id", "fc_" + tool_call.id},
976 {"name", tool_call.name},
977 });
978 }
979
980 std::time_t t = std::time(0);
981 json res = {
982 {"completed_at", t},
983 {"created_at", t},
984 {"id", oai_resp_id},
985 {"model", oaicompat_model},
986 {"object", "response"},
987 {"output", output},

Callers

nothing calls this directly

Calls 3

random_stringFunction · 0.70
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected