Make instruction(system) as first message
This commit is contained in:
parent
1df28c4053
commit
e4571a79a6
|
|
@ -1081,18 +1081,7 @@ json convert_responses_to_chatcmpl(const json & body) {
|
|||
const json input_value = body.at("input");
|
||||
json chatcmpl_messages = json::array();
|
||||
|
||||
if (input_value.is_array()) {
|
||||
chatcmpl_messages = input_value;
|
||||
} else if (input_value.is_string()) {
|
||||
chatcmpl_messages.push_back({
|
||||
{"role", "user"},
|
||||
{"content", input_value},
|
||||
});
|
||||
} else {
|
||||
std::invalid_argument("'input' must be a string or array of objects");
|
||||
}
|
||||
|
||||
const std::string instructions = json_value(body, "instructions", std::string{});
|
||||
const std::string instructions = json_value(body, "instructions", std::string());
|
||||
if (instructions != "") {
|
||||
chatcmpl_messages.push_back({
|
||||
{"role", "system"},
|
||||
|
|
@ -1100,6 +1089,17 @@ json convert_responses_to_chatcmpl(const json & body) {
|
|||
});
|
||||
}
|
||||
|
||||
if (input_value.is_string()) {
|
||||
chatcmpl_messages.push_back({
|
||||
{"role", "user"},
|
||||
{"content", input_value},
|
||||
});
|
||||
} else if (input_value.is_array()) {
|
||||
chatcmpl_messages = input_value;
|
||||
} else {
|
||||
throw std::invalid_argument("'input' must be a string or array of objects");
|
||||
}
|
||||
|
||||
json chatcmpl_body = body;
|
||||
chatcmpl_body.erase("input");
|
||||
chatcmpl_body["messages"] = chatcmpl_messages;
|
||||
|
|
|
|||
Loading…
Reference in New Issue