From 1b504b34ee5d42b5c2f72a4a4c36bf6f9ea905c0 Mon Sep 17 00:00:00 2001 From: fluxlinkage Date: Thu, 11 Jul 2024 14:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86Windows=E4=B8=8B?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8Cdemo=E7=A8=8B=E5=BA=8F=EF=BC=88main.?= =?UTF-8?q?exe=EF=BC=89=E4=B9=B1=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index a0bfa5d8..eb6aefdd 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,7 @@ -#include "model.h" +#include "model.h" +#ifdef _WIN32 +#include +#endif std::map dataTypeDict = { {"float32", fastllm::DataType::FLOAT32}, @@ -89,6 +92,9 @@ void ParseArgs(int argc, char **argv, RunConfig &config, fastllm::GenerationConf } int main(int argc, char **argv) { +#ifdef _WIN32 + system("chcp 65001"); +#endif RunConfig config; fastllm::GenerationConfig generationConfig; ParseArgs(argc, argv, config, generationConfig); @@ -97,7 +103,7 @@ int main(int argc, char **argv) { fastllm::SetThreads(config.threads); fastllm::SetLowMemMode(config.lowMemMode); if (!fastllm::FileExists(config.path)) { - printf("模型文件 %s 不存在!\n", config.path.c_str()); + printf(u8"模型文件 %s 不存在!\n", config.path.c_str()); exit(0); } bool isHFDir = fastllm::FileExists(config.path + "/config.json") || fastllm::FileExists(config.path + "config.json"); @@ -114,10 +120,10 @@ int main(int argc, char **argv) { fastllm::ChatMessages messages = {{"system", systemConfig}}; static std::string modelType = model->model_type; - printf("欢迎使用 %s 模型. 输入内容对话,reset清空历史记录,stop退出程序.\n", model->model_type.c_str()); + printf(u8"欢迎使用 %s 模型. 输入内容对话,reset清空历史记录,stop退出程序.\n", model->model_type.c_str()); while (true) { - printf("用户: "); + printf(u8"用户: "); std::string input; std::getline(std::cin, input); if (input == "reset") { @@ -145,4 +151,4 @@ int main(int argc, char **argv) { } return 0; -} \ No newline at end of file +}