Skip to content

Commit

Permalink
fix: return false if error during loading model (#52)
Browse files Browse the repository at this point in the history
Co-authored-by: vansangpfiev <[email protected]>
  • Loading branch information
vansangpfiev and sangjanai authored May 23, 2024
1 parent cbec376 commit 6560112
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/llama_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr<Json::Value> jsonBody) {
std::ifstream file(grammar_file);
if (!file) {
LOG_ERROR << "Grammar file not found";
return false;
} else {
std::stringstream grammarBuf;
grammarBuf << file.rdbuf();
Expand All @@ -312,7 +313,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr<Json::Value> 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()))) {
Expand All @@ -334,6 +335,7 @@ bool LlamaEngine::LoadModelImpl(std::shared_ptr<Json::Value> 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();
Expand Down

0 comments on commit 6560112

Please sign in to comment.