Skip to content

Commit

Permalink
server : relay error messages (ggml-org#4131)
Browse files Browse the repository at this point in the history
SoftwareRenderer authored and olexiyb committed Nov 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ffa4543 commit 357923e
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
@@ -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}`);
}
}
}
}
11 changes: 11 additions & 0 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
@@ -2371,6 +2371,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;
}
}

0 comments on commit 357923e

Please sign in to comment.