Skip to content

Commit

Permalink
修正了Windows下命令行demo程序(main.exe)乱码的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxlinkage committed Jul 11, 2024
1 parent a9b6236 commit 1b504b3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "model.h"
#include "model.h"
#ifdef _WIN32
#include <stdlib.h>
#endif

std::map <std::string, fastllm::DataType> dataTypeDict = {
{"float32", fastllm::DataType::FLOAT32},
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand All @@ -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") {
Expand Down Expand Up @@ -145,4 +151,4 @@ int main(int argc, char **argv) {
}

return 0;
}
}

0 comments on commit 1b504b3

Please sign in to comment.