Simple single-line server log for requests
This commit is contained in:
parent
96fa480147
commit
7332b41f9f
1 changed files with 9 additions and 2 deletions
|
@ -750,8 +750,11 @@ int main(int argc, char **argv)
|
|||
|
||||
Server svr;
|
||||
|
||||
svr.Get("/", [](const Request &, Response &res)
|
||||
{ res.set_content("<h1>llama.cpp server works</h1>", "text/html"); });
|
||||
svr.Get("/", [](const Request &req, Response &res)
|
||||
{
|
||||
fprintf(stderr, "request: GET / [remote_addr: %s]", req.remote_addr.c_str());
|
||||
res.set_content("<h1>llama.cpp server works</h1>", "text/html");
|
||||
});
|
||||
|
||||
svr.Post("/completion", [&llama](const Request &req, Response &res) {
|
||||
if (llama.params.embedding) {
|
||||
|
@ -772,6 +775,8 @@ int main(int argc, char **argv)
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "request: POST /completion [remote_addr: %s, stream: %s]", req.remote_addr.c_str(), llama.stream ? "true" : "false");
|
||||
|
||||
if (!llama.loadPrompt()) {
|
||||
json data = {{"status", "error"}, {"reason", "Context too long."}};
|
||||
res.set_content(
|
||||
|
@ -885,6 +890,7 @@ int main(int argc, char **argv)
|
|||
|
||||
svr.Post("/tokenize", [&llama](const Request &req, Response &res)
|
||||
{
|
||||
fprintf(stderr, "request: POST /tokenize [remote_addr: %s]", req.remote_addr.c_str());
|
||||
json body = json::parse(req.body);
|
||||
json data = {
|
||||
{"tokens", ::llama_tokenize(llama.ctx, body["content"].get<std::string>(), false) } };
|
||||
|
@ -893,6 +899,7 @@ int main(int argc, char **argv)
|
|||
|
||||
svr.Post("/embedding", [&llama](const Request &req, Response &res)
|
||||
{
|
||||
fprintf(stderr, "request: POST /embedding [remote_addr: %s]", req.remote_addr.c_str());
|
||||
if(!llama.params.embedding) {
|
||||
std::vector<float> empty;
|
||||
json data = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue