server: error handling: rename error fields to match OpenAI API
This commit is contained in:
parent
8a8aaee714
commit
444f32e370
2 changed files with 11 additions and 11 deletions
|
@ -7,18 +7,18 @@
|
|||
class llama_error : public std::exception
|
||||
{
|
||||
private:
|
||||
std::string _id;
|
||||
std::string _description;
|
||||
std::string _type;
|
||||
std::string _message;
|
||||
|
||||
public:
|
||||
llama_error(const std::string & id, const std::string & description)
|
||||
llama_error(const std::string & type, const std::string & message)
|
||||
:
|
||||
_id(id),
|
||||
_description(description)
|
||||
_type(type),
|
||||
_message(message)
|
||||
{
|
||||
fprintf(stderr, "ERROR [%s]: %s\n", id.c_str(), description.c_str());
|
||||
fprintf(stderr, "ERROR [%s]: %s\n", type.c_str(), message.c_str());
|
||||
}
|
||||
|
||||
inline const std::string & id() const { return _id; }
|
||||
inline const std::string & description() const { return _description; }
|
||||
inline const std::string & type() const { return _type; }
|
||||
inline const std::string & message() const { return _message; }
|
||||
};
|
||||
|
|
|
@ -1215,15 +1215,15 @@ struct server_context {
|
|||
{
|
||||
return {
|
||||
{ "error", {
|
||||
{ "id", error.id() },
|
||||
{ "description", error.description() }
|
||||
{ "type", error.type() },
|
||||
{ "message", error.message() }
|
||||
} }
|
||||
};
|
||||
}
|
||||
|
||||
void send_error(const server_task & task, const llama_error& error)
|
||||
{
|
||||
LOG_TEE("task %i - error: %s - %s\n", task.id, error.id().c_str(), error.description().c_str());
|
||||
LOG_TEE("task %i - error: %s - %s\n", task.id, error.type().c_str(), error.message().c_str());
|
||||
server_task_result res;
|
||||
res.id = task.id;
|
||||
res.id_multi = task.id_multi;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue