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

Commit ade0aa0

Browse files
Merge branch 'dev' into chore/lint-api-reference
2 parents 362f8f7 + 0528553 commit ade0aa0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4323
-1234
lines changed

docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ echo "enableCors: true" >> /root/.cortexrc
77

88
# Install the engine
99
cortex engines install llama-cpp -s /opt/cortex.llamacpp
10-
cortex engines list
1110

1211
# Start the cortex server
1312
cortex start
13+
cortex engines list
1414

1515
# Keep the container running by tailing the log files
1616
tail -f /root/cortexcpp/logs/cortex.log &

engine/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,19 @@ else()
169169
endif()
170170

171171
aux_source_directory(controllers CTL_SRC)
172+
aux_source_directory(repositories REPO_SRC)
172173
aux_source_directory(services SERVICES_SRC)
173174
aux_source_directory(common COMMON_SRC)
174175
aux_source_directory(models MODEL_SRC)
175176
aux_source_directory(cortex-common CORTEX_COMMON)
176177
aux_source_directory(config CONFIG_SRC)
177178
aux_source_directory(database DB_SRC)
178179
aux_source_directory(migrations MIGR_SRC)
180+
aux_source_directory(utils UTILS_SRC)
179181

180182
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
181183

182-
target_sources(${TARGET_NAME} PRIVATE ${CONFIG_SRC} ${CTL_SRC} ${COMMON_SRC} ${SERVICES_SRC} ${DB_SRC} ${MIGR_SRC})
184+
target_sources(${TARGET_NAME} PRIVATE ${UTILS_SRC} ${CONFIG_SRC} ${CTL_SRC} ${COMMON_SRC} ${SERVICES_SRC} ${DB_SRC} ${MIGR_SRC} ${REPO_SRC})
183185

184186
set_target_properties(${TARGET_NAME} PROPERTIES
185187
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}

engine/cli/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ add_executable(${TARGET_NAME} main.cc
8484
${CMAKE_CURRENT_SOURCE_DIR}/../services/hardware_service.cc
8585
${CMAKE_CURRENT_SOURCE_DIR}/utils/easywsclient.cc
8686
${CMAKE_CURRENT_SOURCE_DIR}/utils/download_progress.cc
87+
${CMAKE_CURRENT_SOURCE_DIR}/../utils/config_yaml_utils.cc
88+
${CMAKE_CURRENT_SOURCE_DIR}/../utils/file_manager_utils.cc
89+
${CMAKE_CURRENT_SOURCE_DIR}/../utils/curl_utils.cc
90+
${CMAKE_CURRENT_SOURCE_DIR}/../utils/system_info_utils.cc
8791
)
8892

8993
target_link_libraries(${TARGET_NAME} PRIVATE CLI11::CLI11)

engine/cli/commands/engine_install_cmd.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ bool EngineInstallCmd::Exec(const std::string& engine,
179179
auto response = curl_utils::SimplePostJson(install_url.ToFullPath(),
180180
body.toStyledString());
181181
if (response.has_error()) {
182-
// TODO: namh refactor later
183182
Json::Value root;
184183
Json::Reader reader;
185184
if (!reader.parse(response.error(), root)) {

engine/cli/commands/engine_list_cmd.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "common/engine_servicei.h"
55
#include "server_start_cmd.h"
66
#include "utils/curl_utils.h"
7+
#include "utils/engine_constants.h"
78
#include "utils/logging_utils.h"
89
#include "utils/url_parser.h"
910
// clang-format off

engine/cli/commands/ps_cmd.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string>
33
#include <tabulate/table.hpp>
44
#include "utils/curl_utils.h"
5+
#include "utils/engine_constants.h"
56
#include "utils/format_utils.h"
67
#include "utils/logging_utils.h"
78
#include "utils/string_utils.h"

engine/cli/commands/server_start_cmd.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "server_start_cmd.h"
22
#include "commands/cortex_upd_cmd.h"
33
#include "utils/cortex_utils.h"
4+
#include "utils/engine_constants.h"
45
#include "utils/file_manager_utils.h"
56
#include "utils/widechar_conv.h"
67

@@ -27,6 +28,10 @@ bool TryConnectToServer(const std::string& host, int port) {
2728

2829
bool ServerStartCmd::Exec(const std::string& host, int port,
2930
const std::optional<std::string>& log_level) {
31+
if (IsServerAlive(host, port)) {
32+
CLI_LOG("The server has already started");
33+
return true;
34+
}
3035
std::string log_level_;
3136
if (!log_level.has_value()) {
3237
log_level_ = "INFO";

engine/cli/main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ int main(int argc, char* argv[]) {
148148

149149
if (should_check_for_latest_llamacpp_version) {
150150
std::thread t1([]() {
151-
auto config = file_manager_utils::GetCortexConfig();
152151
// TODO: namh current we only check for llamacpp. Need to add support for other engine
153152
auto get_latest_version = []() -> cpp::result<std::string, std::string> {
154153
try {
@@ -176,6 +175,7 @@ int main(int argc, char* argv[]) {
176175

177176
auto now = std::chrono::system_clock::now();
178177
CTL_DBG("latest llama.cpp version: " << res.value());
178+
auto config = file_manager_utils::GetCortexConfig();
179179
config.checkedForLlamacppUpdateAt =
180180
std::chrono::duration_cast<std::chrono::milliseconds>(
181181
now.time_since_epoch())
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include "common/json_serializable.h"
4+
5+
namespace api_response {
6+
struct DeleteMessageResponse : JsonSerializable {
7+
std::string id;
8+
std::string object;
9+
bool deleted;
10+
11+
cpp::result<Json::Value, std::string> ToJson() override {
12+
Json::Value json;
13+
json["id"] = id;
14+
json["object"] = object;
15+
json["deleted"] = deleted;
16+
return json;
17+
}
18+
};
19+
} // namespace api_response

engine/common/json_serializable.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include <json/value.h>
4+
#include "utils/result.hpp"
5+
6+
struct JsonSerializable {
7+
8+
virtual cpp::result<Json::Value, std::string> ToJson() = 0;
9+
10+
virtual ~JsonSerializable() = default;
11+
};

0 commit comments

Comments
 (0)