diff options
author | SoftwareRenderer <138734813+SoftwareRenderer@users.noreply.github.com> | 2023-11-19 11:54:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-19 18:54:10 +0200 |
commit | 936c79b2275a8f15f3512e63de615c676904d650 (patch) | |
tree | 2c7f4f9c2c17b61ed1b3a69a80e8c3fc4367e8d0 /examples/server | |
parent | 262005ad9ded375e9c544a02c18ef6254fe185a2 (diff) |
server : relay error messages (#4131)
Diffstat (limited to 'examples/server')
-rw-r--r-- | examples/server/public/completion.js | 4 | ||||
-rw-r--r-- | examples/server/server.cpp | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/server/public/completion.js b/examples/server/public/completion.js index 0c9bd5f1..b9c44250 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 bb87b532..1f2c55f2 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; } } |