Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/max context length #1370

Merged
merged 15 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions engine/config/gguf_parser.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <ctime>
Expand All @@ -12,6 +13,7 @@
#ifdef _WIN32
#include <io.h>
#include <windows.h>
#include <limits>
#else
#include <sys/mman.h> // For memory-mapped file
#include <unistd.h> // For file descriptors
Expand All @@ -25,6 +27,7 @@
#include "trantor/utils/Logger.h"

namespace config {
#define MIN(a, b) ((a) < (b) ? (a) : (b))
void GGUFHandler::OpenFile(const std::string& file_path) {
#ifdef _WIN32
HANDLE file_handle_ = INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -582,8 +585,8 @@ void GGUFHandler::ModelConfigFromMetadata() {
model_config_.model = name;
model_config_.id = name;
model_config_.version = std::to_string(version);
model_config_.max_tokens = max_tokens;
model_config_.ctx_len = max_tokens;
model_config_.max_tokens = MIN(8192, max_tokens);
nguyenhoangthuan99 marked this conversation as resolved.
Show resolved Hide resolved
model_config_.ctx_len = MIN(8192, max_tokens);
model_config_.ngl = ngl;
}

Expand Down
10 changes: 6 additions & 4 deletions engine/services/download_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cpp::result<void, std::string> DownloadService::AddDownloadTask(
std::optional<std::string> dl_err_msg = std::nullopt;
for (const auto& item : task.items) {
CLI_LOG("Start downloading: " + item.localPath.filename().string());
auto result = Download(task.id, item, true);
auto result = Download(task.id, item, true, task.type);
if (result.has_error()) {
dl_err_msg = result.error();
break;
Expand Down Expand Up @@ -121,7 +121,7 @@ cpp::result<void, std::string> DownloadService::AddAsyncDownloadTask(
std::optional<std::string> dl_err_msg = std::nullopt;
for (const auto& item : task.items) {
CTL_INF("Start downloading: " + item.localPath.filename().string());
auto result = Download(task.id, item, false);
auto result = Download(task.id, item, false, task.type);
if (result.has_error()) {
dl_err_msg = result.error();
break;
Expand All @@ -147,7 +147,7 @@ cpp::result<void, std::string> DownloadService::AddAsyncDownloadTask(

cpp::result<void, std::string> DownloadService::Download(
const std::string& download_id, const DownloadItem& download_item,
bool allow_resume) noexcept {
bool allow_resume, std::optional<DownloadType> download_type) noexcept {
CTL_INF("Absolute file output: " << download_item.localPath.string());

CURL* curl;
Expand Down Expand Up @@ -232,7 +232,9 @@ cpp::result<void, std::string> DownloadService::Download(

fclose(file);
curl_easy_cleanup(curl);
CLI_LOG("Model " << download_id << " downloaded successfully!")
if (download_type.has_value() && download_type == DownloadType::Model) {
CLI_LOG("Model " << download_id << " downloaded successfully!")
}
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion engine/services/download_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class DownloadService {

cpp::result<void, std::string> Download(const std::string& download_id,
const DownloadItem& download_item,
bool allow_resume) noexcept;
bool allow_resume,std::optional<DownloadType> download_type) noexcept;

curl_off_t GetLocalFileSize(const std::filesystem::path& path) const;
};
Loading