Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 994ed98

Browse files
fix: filter out imported models for model sources (#2055)
* fix: filter out imported model for model sources * fix: improve error handling for remote engine --------- Co-authored-by: sangjanai <[email protected]>
1 parent ce1fbe0 commit 994ed98

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

engine/database/models.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ cpp::result<std::vector<ModelEntry>, std::string> Models::GetModelSources()
310310
"SELECT model_id, author_repo_id, branch_name, "
311311
"path_to_model_yaml, model_alias, model_format, "
312312
"model_source, status, engine, metadata FROM models "
313-
"WHERE model_source != \"\" AND (status = \"downloaded\" OR status = "
313+
"WHERE model_source != \"\" AND model_source != \"imported\" AND "
314+
"(status = \"downloaded\" OR status = "
314315
"\"downloadable\")");
315316
while (query.executeStep()) {
316317
ModelEntry entry;

engine/extensions/remote-engine/remote_engine.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ size_t StreamWriteCallback(char* ptr, size_t size, size_t nmemb,
3030
Json::Value check_error;
3131
Json::Reader reader;
3232
context->chunks += chunk;
33-
if (reader.parse(context->chunks, check_error) ||
34-
(reader.parse(chunk, check_error) &&
35-
chunk.find("error") != std::string::npos)) {
33+
34+
long http_code = k200OK;
35+
if (context->curl) {
36+
curl_easy_getinfo(context->curl, CURLINFO_RESPONSE_CODE, &http_code);
37+
}
38+
if (http_code != k200OK && (reader.parse(context->chunks, check_error) ||
39+
(chunk.find("error") != std::string::npos &&
40+
reader.parse(chunk, check_error)))) {
3641
CTL_WRN(context->chunks);
37-
CTL_WRN(chunk);
42+
CTL_WRN("http code: " << http_code << " - " << chunk);
3843
CTL_INF("Request: " << context->last_request);
3944
Json::Value status;
4045
status["is_done"] = true;
@@ -139,7 +144,9 @@ CurlResponse RemoteEngine::MakeStreamingChatCompletionRequest(
139144
renderer_,
140145
stream_template,
141146
true,
142-
body};
147+
body,
148+
"",
149+
curl};
143150

144151
curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str());
145152
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

engine/extensions/remote-engine/remote_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct StreamContext {
2727
bool need_stop = true;
2828
std::string last_request;
2929
std::string chunks;
30+
CURL* curl;
3031
};
3132
struct CurlResponse {
3233
std::string body;

engine/services/model_service.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ ModelService::ModelService(std::shared_ptr<DatabaseService> db_service,
155155
inference_svc_(inference_service),
156156
engine_svc_(engine_svc),
157157
task_queue_(task_queue) {
158-
ProcessBgrTasks();
158+
// ProcessBgrTasks();
159159
};
160160

161161
void ModelService::ForceIndexingModelList() {

0 commit comments

Comments
 (0)