Skip to content

Commit

Permalink
refactor web demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzhaode committed Dec 15, 2023
1 parent fcfe28a commit 68dee0e
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions demo/web_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
int main(int argc, const char* argv[]) {
if (argc < 3) {
std::cout << "Usage: " << argv[0] << " model_dir web_dir" << std::endl;
std::cout << "Example: " << argv[0] << " ../qwen-1.8b-int4 ../resource/web" << std::endl;
std::cout << "Example: " << argv[0] << " ../qwen-1.8b-int4 ../web" << std::endl;
return 0;
}
std::string model_dir = argv[1];
Expand All @@ -29,9 +29,8 @@ int main(int argc, const char* argv[]) {
std::string last_request = "";
auto chat = [&](std::string str) {
waiting = true;
llm->response(str, &ss);
llm->response(str, &ss, "<eop>");
std::cout << "### response : " << ss.str() << std::endl;
ss << "<eop>";
waiting = false;
};
svr.Post("/chat", [&](const httplib::Request &req, httplib::Response &res) {
Expand All @@ -50,9 +49,9 @@ int main(int argc, const char* argv[]) {
}
});
svr.set_mount_point("/", web_dir);
printf(">>> please open http://0.0.0.0:5088\n");
printf(">>> please open http://0.0.0.0:8080 or http://localhost:8080\n");
fflush(stdout);
svr.listen("0.0.0.0", 5088);
svr.listen("0.0.0.0", 8080);
printf(">>> end\n");
return 0;
}
Binary file removed resource/web/web_demo.png
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion resource/web/index.html → web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@
<div class="button minimize"></div>
<div class="button maximize"></div>
</div>
<div class="title">ChatGLM-MNN</div>
<div class="title">mnn-llm</div>
</div>
<div class="messages">
<div id="chatlog"></div>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 68dee0e

Please sign in to comment.