Skip to content

Commit

Permalink
server : relay error messages (#4131)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftwareRenderer authored Nov 19, 2023
1 parent 262005a commit 936c79b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/server/public/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export async function* llama(prompt, params = {}, config = {}) {
break;
}
}
if (result.error) {
result.error = JSON.parse(result.error);
console.error(`llama.cpp error: ${result.error.content}`);
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,17 @@ int main(int argc, char **argv)
break;
}
} else {
const std::string str =
"error: " +
result.result_json.dump(-1, ' ', false, json::error_handler_t::replace) +
"\n\n";
LOG_VERBOSE("data stream", {
{ "to_send", str }
});
if (!sink.write(str.c_str(), str.size()))
{
return false;
}
break;
}
}
Expand Down

0 comments on commit 936c79b

Please sign in to comment.