From 26a4768895e55485c9e254f252c0ae384a5c97c9 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 18 Jul 2024 11:06:32 +0700 Subject: [PATCH] fix: append models to list --- cortex-cpp/controllers/server.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cortex-cpp/controllers/server.cc b/cortex-cpp/controllers/server.cc index 8429923b1..485695b66 100644 --- a/cortex-cpp/controllers/server.cc +++ b/cortex-cpp/controllers/server.cc @@ -32,7 +32,7 @@ server::~server() {} void server::ChatCompletion( const HttpRequestPtr& req, std::function&& callback) { - if(!HasFieldInReq(req, callback, "engine")) { + if (!HasFieldInReq(req, callback, "engine")) { return; } @@ -95,7 +95,7 @@ void server::Embedding(const HttpRequestPtr& req, void server::UnloadModel( const HttpRequestPtr& req, std::function&& callback) { - if(!HasFieldInReq(req, callback, "engine")) { + if (!HasFieldInReq(req, callback, "engine")) { return; } @@ -126,7 +126,7 @@ void server::UnloadModel( void server::ModelStatus( const HttpRequestPtr& req, std::function&& callback) { - if(!HasFieldInReq(req, callback, "engine")) { + if (!HasFieldInReq(req, callback, "engine")) { return; } @@ -174,7 +174,9 @@ void server::GetModels(const HttpRequestPtr& req, if (e->IsSupported("GetModels")) { e->GetModels(req->getJsonObject(), [&resp_data](Json::Value status, Json::Value res) { - resp_data.append(res); + for (auto r : res["data"]) { + resp_data.append(r); + } }); } } @@ -354,7 +356,7 @@ void server::ProcessStreamRes(std::function cb, }; auto resp = cortex_utils::CreateCortexStreamResponse(chunked_content_provider, - "chat_completions.txt"); + "chat_completions.txt"); cb(resp); }