return raw content if parse failed
This commit is contained in:
parent
9bd7dbb17b
commit
155eeed9ae
1 changed files with 15 additions and 4 deletions
|
@ -572,14 +572,25 @@ static json format_final_response_oaicompat(const json & request, json result, c
|
||||||
finish_reason = "stop";
|
finish_reason = "stop";
|
||||||
}
|
}
|
||||||
|
|
||||||
json choices =
|
json choices;
|
||||||
streaming ? json::array({json{{"finish_reason", finish_reason},
|
|
||||||
|
if (streaming) {
|
||||||
|
choices = json::array({json{{"finish_reason", finish_reason},
|
||||||
|
{"index", 0},
|
||||||
|
{"delta", json::object()}}});
|
||||||
|
} else {
|
||||||
|
if (parsed_content.empty()) {
|
||||||
|
choices = json::array({json{{"finish_reason", finish_reason},
|
||||||
{"index", 0},
|
{"index", 0},
|
||||||
{"delta", json::object()}}})
|
{"message", json{{"content", content},
|
||||||
: json::array({json{{"finish_reason", finish_reason},
|
{"role", "assistant"}}}}});
|
||||||
|
} else {
|
||||||
|
choices = json::array({json{{"finish_reason", finish_reason},
|
||||||
{"index", 0},
|
{"index", 0},
|
||||||
{"message", json{{"content", parsed_content},
|
{"message", json{{"content", parsed_content},
|
||||||
{"role", "assistant"}}}}});
|
{"role", "assistant"}}}}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::time_t t = std::time(0);
|
std::time_t t = std::time(0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue