This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 2
2
#include < cstdint>
3
3
#include < cstring>
4
4
#include < ctime>
5
+ #include < filesystem>
5
6
#include < iostream>
6
7
#include < regex>
7
8
#include < stdexcept>
8
9
#include < string>
9
10
#include < vector>
10
- #include < filesystem>
11
11
12
12
#ifdef _WIN32
13
13
#include < io.h>
@@ -70,7 +70,7 @@ void GGUFHandler::OpenFile(const std::string& file_path) {
70
70
71
71
#else
72
72
file_size_ = std::filesystem::file_size (file_path);
73
-
73
+
74
74
int file_descriptor = open (file_path.c_str (), O_RDONLY);
75
75
// Memory-map the file
76
76
data_ = static_cast <uint8_t *>(
@@ -105,7 +105,8 @@ std::pair<std::size_t, std::string> GGUFHandler::ReadString(
105
105
std::memcpy (&length, data_ + offset, sizeof (uint64_t ));
106
106
107
107
if (offset + 8 + length > file_size_) {
108
- throw std::runtime_error (" GGUF metadata string length exceeds file size.\n " );
108
+ throw std::runtime_error (
109
+ " GGUF metadata string length exceeds file size.\n " );
109
110
}
110
111
111
112
std::string value (reinterpret_cast <const char *>(data_ + offset + 8 ), length);
@@ -578,9 +579,8 @@ void GGUFHandler::ModelConfigFromMetadata() {
578
579
model_config_.model = name;
579
580
model_config_.id = name;
580
581
model_config_.version = std::to_string (version);
581
- model_config_.max_tokens =
582
- std::min<int >(kDefaultMaxContextLength , max_tokens);
583
- model_config_.ctx_len = std::min<int >(kDefaultMaxContextLength , max_tokens);
582
+ model_config_.max_tokens = max_tokens;
583
+ model_config_.ctx_len = max_tokens;
584
584
model_config_.ngl = ngl;
585
585
}
586
586
Original file line number Diff line number Diff line change @@ -951,6 +951,7 @@ cpp::result<StartModelResult, std::string> ModelService::StartModel(
951
951
json_data[" user_prompt" ] = mc.user_template ;
952
952
json_data[" ai_prompt" ] = mc.ai_template ;
953
953
json_data[" ctx_len" ] = std::min (kDefautlContextLength , mc.ctx_len );
954
+ json_data[" max_tokens" ] = std::min (kDefautlContextLength , mc.ctx_len );
954
955
max_model_context_length = mc.ctx_len ;
955
956
} else {
956
957
bypass_stop_check_set_.insert (model_handle);
@@ -975,6 +976,8 @@ cpp::result<StartModelResult, std::string> ModelService::StartModel(
975
976
if (ctx_len) {
976
977
json_data[" ctx_len" ] =
977
978
std::min (ctx_len.value (), max_model_context_length);
979
+ json_data[" max_tokens" ] =
980
+ std::min (ctx_len.value (), max_model_context_length);
978
981
}
979
982
CTL_INF (json_data.toStyledString ());
980
983
auto may_fallback_res = MayFallbackToCpu (json_data[" model_path" ].asString (),
You can’t perform that action at this time.
0 commit comments