From 6560112e1d38a7e6ebe27405ca08ac1b7ceb3647 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 23 May 2024 11:07:08 +0700 Subject: [PATCH] fix: return false if error during loading model (#52) Co-authored-by: vansangpfiev --- src/llama_engine.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/llama_engine.cc b/src/llama_engine.cc index f04859b4..b66a86a4 100644 --- a/src/llama_engine.cc +++ b/src/llama_engine.cc @@ -302,6 +302,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr jsonBody) { std::ifstream file(grammar_file); if (!file) { LOG_ERROR << "Grammar file not found"; + return false; } else { std::stringstream grammarBuf; grammarBuf << file.rdbuf(); @@ -312,7 +313,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr jsonBody) { Json::Value model_path = jsonBody->operator[]("llama_model_path"); if (model_path.isNull()) { LOG_ERROR << "Missing model path in request"; - //TODO return? + return false; } else { if (std::filesystem::exists( std::filesystem::path(model_path.asString()))) { @@ -334,6 +335,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr jsonBody) { jsonBody->get("cpu_threads", std::thread::hardware_concurrency()) .asInt(); params.cont_batching = jsonBody->get("cont_batching", false).asBool(); + // Check for backward compatible auto fa0 = jsonBody->get("flash-attn", false).asBool(); auto fa1 = jsonBody->get("flash_attn", false).asBool();