Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions engine/common/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ struct Thread : JsonSerializable {
}
json["metadata"] = metadata_json;

if (assistants.has_value()) {
Json::Value assistants_json(Json::arrayValue);
for (auto& assistant : assistants.value()) {
auto assistant_result = assistant.ToJson();
if (assistant_result.has_error()) {
return cpp::fail("Failed to serialize assistant: " +
assistant_result.error());
}
assistants_json.append(assistant_result.value());
}
json["assistants"] = assistants_json;
}

return json;
} catch (const std::exception& e) {
return cpp::fail(std::string("ToJson failed: ") + e.what());
Expand Down
6 changes: 2 additions & 4 deletions engine/controllers/hardware.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "hardware.h"
#include "common/hardware_config.h"
#include "utils/cortex_utils.h"
#include "utils/file_manager_utils.h"
#include "utils/scope_exit.h"
#include "utils/logging_utils.h"

void Hardware::GetHardwareInfo(
const HttpRequestPtr& req,
Expand Down Expand Up @@ -73,4 +71,4 @@ void Hardware::Activate(
callback(resp);
app().quit();
#endif
}
}
4 changes: 3 additions & 1 deletion engine/controllers/threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void Threads::ListThreads(
Json::Value msg_arr(Json::arrayValue);
for (auto& msg : res.value()) {
if (auto it = msg.ToJson(); it.has_value()) {
it->removeMember("assistants");
msg_arr.append(it.value());
} else {
CTL_WRN("Failed to convert message to json: " + it.error());
Expand Down Expand Up @@ -114,8 +115,9 @@ void Threads::RetrieveThread(
resp->setStatusCode(k400BadRequest);
callback(resp);
} else {
thread_to_json->removeMember("assistants");
auto resp =
cortex_utils::CreateCortexHttpJsonResponse(res->ToJson().value());
cortex_utils::CreateCortexHttpJsonResponse(thread_to_json.value());
resp->setStatusCode(k200OK);
callback(resp);
}
Expand Down
9 changes: 4 additions & 5 deletions engine/database/hardware.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include "hardware.h"
#include "database.h"
#include "utils/logging_utils.h"
#include "utils/scope_exit.h"

namespace cortex::db {

Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) {
}
Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) {}

Hardwares::Hardwares(SQLite::Database& db) : db_(db) {
}
Hardwares::Hardwares(SQLite::Database& db) : db_(db) {}

Hardwares::~Hardwares() {}

Expand Down Expand Up @@ -94,4 +93,4 @@ cpp::result<bool, std::string> Hardwares::DeleteHardwareEntry(
return cpp::fail(e.what());
}
}
} // namespace cortex::db
} // namespace cortex::db
3 changes: 2 additions & 1 deletion engine/database/models.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <algorithm>
#include <sstream>
#include "database.h"
#include "utils/logging_utils.h"
#include "utils/result.hpp"
#include "utils/scope_exit.h"

Expand Down Expand Up @@ -339,4 +340,4 @@ bool Models::HasModel(const std::string& identifier) const {
}
}

} // namespace cortex::db
} // namespace cortex::db
4 changes: 4 additions & 0 deletions engine/test/components/test_cortex_config.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include <yaml-cpp/node/node.h>
#include <yaml-cpp/node/parse.h>
#include <filesystem>
#include <fstream>
#include "gtest/gtest.h"
#include "utils/config_yaml_utils.h"

Expand Down
3 changes: 2 additions & 1 deletion engine/test/components/test_cortex_upd_cmd.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "cli/commands/cortex_upd_cmd.h"
#include <filesystem>
#include <fstream>
#include "gtest/gtest.h"

namespace {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <filesystem>
#include <fstream>
#include "utils/config_yaml_utils.h"
#include "utils/file_manager_utils.h"

Expand Down
7 changes: 6 additions & 1 deletion engine/utils/config_yaml_utils.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "config_yaml_utils.h"
#include <filesystem>
#include <fstream>
#include <iostream>
#include "utils/logging_utils.h"
#include "yaml-cpp/yaml.h"

namespace config_yaml_utils {
cpp::result<void, std::string> CortexConfigMgr::DumpYamlConfig(
Expand Down Expand Up @@ -174,4 +179,4 @@ CortexConfig CortexConfigMgr::FromYaml(const std::string& path,
}
}

} // namespace config_yaml_utils
} // namespace config_yaml_utils
6 changes: 1 addition & 5 deletions engine/utils/config_yaml_utils.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#pragma once

#include <filesystem>
#include <fstream>
#include <iostream>
#include <mutex>
#include <string>
#include "utils/logging_utils.h"
#include <vector>
#include "utils/result.hpp"
#include "yaml-cpp/yaml.h"

namespace config_yaml_utils {

Expand Down