From 936c79b2275a8f15f3512e63de615c676904d650 Mon Sep 17 00:00:00 2001 From: SoftwareRenderer <138734813+SoftwareRenderer@users.noreply.github.com> Date: Sun, 19 Nov 2023 11:54:10 -0500 Subject: [PATCH] server : relay error messages (#4131) --- examples/server/public/completion.js | 4 ++++ examples/server/server.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/examples/server/public/completion.js b/examples/server/public/completion.js index 0c9bd5f10..b9c442509 100644 --- a/examples/server/public/completion.js +++ b/examples/server/public/completion.js @@ -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}`); + } } } } diff --git a/examples/server/server.cpp b/examples/server/server.cpp index bb87b532b..1f2c55f2d 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -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; } }