Skip to content

Commit

Permalink
Merge pull request #476 from fluxlinkage/master
Browse files Browse the repository at this point in the history
修复Windows上MSVC无法成功编译的Bug。
  • Loading branch information
ztxz16 authored Jul 11, 2024
2 parents 55902fd + 1b504b3 commit 0b1c514
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/apiserver/apiserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ using socket_t = int;
#include <thread>
#include "model.h"

long long GetCurrentTime() {
long long _GetCurrentTime() {
auto now = std::chrono::high_resolution_clock::now();
auto duration = now.time_since_epoch();
return std::chrono::duration_cast<std::chrono::seconds>(duration).count();
Expand Down Expand Up @@ -430,7 +430,7 @@ struct WorkQueue {
}

std::string curId = "fastllm-" + GenerateRandomID();
auto createTime = GetCurrentTime();
auto createTime = _GetCurrentTime();

if (isStream) {
message = "";
Expand Down
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 0b1c514

Please sign in to comment.