Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions src/cpp/server/ollama_api.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "lemon/ollama_api.h"
#include "lemon/model_types.h"
#include "lemon/runtime_config.h"
#include <iostream>
#include <lemon/utils/aixlog.hpp>
#include <sstream>
Expand Down Expand Up @@ -1181,6 +1182,13 @@ void OllamaApi::handle_pull(const httplib::Request& req, httplib::Response& res)
res.set_content(error.dump(), "application/json");
return;
}
auto* cfg = RuntimeConfig::global();
if (cfg && cfg->offline()) {
res.status = 400;
json error = {{"error", "Lemond is in offline mode, models not downloaded"}, {"code", "lemond_offline"}};
res.set_content(error.dump(), "application/json");
return;
}

LOG(INFO, "OllamaApi") << "POST /api/pull - Pulling model: " << name << std::endl;

Expand Down
7 changes: 7 additions & 0 deletions src/cpp/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,13 @@ void Server::handle_pull(const httplib::Request& req, httplib::Response& res) {
return;
}

if (config_->offline()) {
res.status = 400;
nlohmann::json error = {{"error", "Lemond is in offline mode, models not downloaded"}, {"code", "lemond_offline"}};
res.set_content(error.dump(), "application/json");
return;
}

if (stream) {
auto operation = [this, model_name, request_json, do_not_upgrade](DownloadProgressCallback progress_cb) {
model_manager_->download_model(model_name, request_json, do_not_upgrade, progress_cb);
Expand Down