Skip to content

Commit

Permalink
feat: add more parameters to /v1/models/start (#1545)
Browse files Browse the repository at this point in the history
  • Loading branch information
vansangpfiev authored Oct 24, 2024
1 parent 22e344b commit 9fe0c6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions engine/controllers/models.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,20 @@ void Models::StartModel(
params_override.cache_type = o.asString();
}

if (auto& o = (*(req->getJsonObject()))["mmproj"]; !o.isNull()) {
params_override.mmproj = o.asString();
}

// Support both llama_model_path and model_path for backward compatible
// model_path has higher priority
if (auto& o = (*(req->getJsonObject()))["llama_model_path"]; !o.isNull()) {
params_override.model_path = o.asString();
}

if (auto& o = (*(req->getJsonObject()))["model_path"]; !o.isNull()) {
params_override.model_path = o.asString();
}

auto model_entry = model_service_->GetDownloadedModel(model_handle);
if (!model_entry.has_value()) {
Json::Value ret;
Expand Down
2 changes: 2 additions & 0 deletions engine/services/model_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ cpp::result<bool, std::string> ModelService::StartModel(
ASSIGN_IF_PRESENT(json_data, params_override, n_parallel);
ASSIGN_IF_PRESENT(json_data, params_override, ctx_len);
ASSIGN_IF_PRESENT(json_data, params_override, cache_type);
ASSIGN_IF_PRESENT(json_data, params_override, mmproj);
ASSIGN_IF_PRESENT(json_data, params_override, model_path);
#undef ASSIGN_IF_PRESENT;

CTL_INF(json_data.toStyledString());
Expand Down
2 changes: 2 additions & 0 deletions engine/services/model_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ std::optional<int> n_parallel;
std::optional<int> ctx_len;
std::optional<std::string> custom_prompt_template;
std::optional<std::string> cache_type;
std::optional<std::string> mmproj;
std::optional<std::string> model_path;
};
class ModelService {
public:
Expand Down

0 comments on commit 9fe0c6f

Please sign in to comment.