DeepSeek R1: parse thoughts / return in separate field in API (non streamed mode)

This commit is contained in:
ochafik 2025-02-03 01:19:15 +00:00
parent 87de852b7f
commit 130ca222c9
4 changed files with 47 additions and 9 deletions

View file

@ -18,18 +18,17 @@
using json = nlohmann::ordered_json;
static common_chat_msg msg_from_json(const json & message) {
common_chat_msg ret{
"assistant",
"",
{},
/* .tool_plan = */ "",
};
common_chat_msg ret;
ret.role = "assistant";
if (message.contains("content") && !message.at("content").is_null()) {
ret.content = message.at("content");
}
if (message.contains("tool_plan")) {
ret.tool_plan = message.at("tool_plan");
}
if (message.contains("thoughts")) {
ret.thoughts = message.at("thoughts");
}
auto has_tool_calls = message.contains("tool_calls");
if (has_tool_calls) {
for (const auto & tc : message.at("tool_calls")) {