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

Commit 4700f8d

Browse files
authored
fix: create assistant (#1773)
* fix: create assistant * fix ci
1 parent 97e5636 commit 4700f8d

File tree

10 files changed

+38
-18
lines changed

10 files changed

+38
-18
lines changed

engine/common/thread.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ struct Thread : JsonSerializable {
156156
}
157157
json["metadata"] = metadata_json;
158158

159+
if (assistants.has_value()) {
160+
Json::Value assistants_json(Json::arrayValue);
161+
for (auto& assistant : assistants.value()) {
162+
auto assistant_result = assistant.ToJson();
163+
if (assistant_result.has_error()) {
164+
return cpp::fail("Failed to serialize assistant: " +
165+
assistant_result.error());
166+
}
167+
assistants_json.append(assistant_result.value());
168+
}
169+
json["assistants"] = assistants_json;
170+
}
171+
159172
return json;
160173
} catch (const std::exception& e) {
161174
return cpp::fail(std::string("ToJson failed: ") + e.what());

engine/controllers/hardware.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "hardware.h"
2-
#include "common/hardware_config.h"
32
#include "utils/cortex_utils.h"
4-
#include "utils/file_manager_utils.h"
5-
#include "utils/scope_exit.h"
3+
#include "utils/logging_utils.h"
64

75
void Hardware::GetHardwareInfo(
86
const HttpRequestPtr& req,
@@ -73,4 +71,4 @@ void Hardware::Activate(
7371
callback(resp);
7472
app().quit();
7573
#endif
76-
}
74+
}

engine/controllers/threads.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void Threads::ListThreads(
2525
Json::Value msg_arr(Json::arrayValue);
2626
for (auto& msg : res.value()) {
2727
if (auto it = msg.ToJson(); it.has_value()) {
28+
it->removeMember("assistants");
2829
msg_arr.append(it.value());
2930
} else {
3031
CTL_WRN("Failed to convert message to json: " + it.error());
@@ -114,8 +115,9 @@ void Threads::RetrieveThread(
114115
resp->setStatusCode(k400BadRequest);
115116
callback(resp);
116117
} else {
118+
thread_to_json->removeMember("assistants");
117119
auto resp =
118-
cortex_utils::CreateCortexHttpJsonResponse(res->ToJson().value());
120+
cortex_utils::CreateCortexHttpJsonResponse(thread_to_json.value());
119121
resp->setStatusCode(k200OK);
120122
callback(resp);
121123
}

engine/database/hardware.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "hardware.h"
22
#include "database.h"
3+
#include "utils/logging_utils.h"
34
#include "utils/scope_exit.h"
45

56
namespace cortex::db {
67

7-
Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) {
8-
}
8+
Hardwares::Hardwares() : db_(cortex::db::Database::GetInstance().db()) {}
99

10-
Hardwares::Hardwares(SQLite::Database& db) : db_(db) {
11-
}
10+
Hardwares::Hardwares(SQLite::Database& db) : db_(db) {}
1211

1312
Hardwares::~Hardwares() {}
1413

@@ -94,4 +93,4 @@ cpp::result<bool, std::string> Hardwares::DeleteHardwareEntry(
9493
return cpp::fail(e.what());
9594
}
9695
}
97-
} // namespace cortex::db
96+
} // namespace cortex::db

engine/database/models.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <algorithm>
33
#include <sstream>
44
#include "database.h"
5+
#include "utils/logging_utils.h"
56
#include "utils/result.hpp"
67
#include "utils/scope_exit.h"
78

@@ -339,4 +340,4 @@ bool Models::HasModel(const std::string& identifier) const {
339340
}
340341
}
341342

342-
} // namespace cortex::db
343+
} // namespace cortex::db

engine/test/components/test_cortex_config.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#include <yaml-cpp/node/node.h>
2+
#include <yaml-cpp/node/parse.h>
3+
#include <filesystem>
4+
#include <fstream>
15
#include "gtest/gtest.h"
26
#include "utils/config_yaml_utils.h"
37

engine/test/components/test_cortex_upd_cmd.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "cli/commands/cortex_upd_cmd.h"
1+
#include <filesystem>
2+
#include <fstream>
23
#include "gtest/gtest.h"
34

45
namespace {

engine/test/components/test_file_manager_config_yaml_utils.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <gmock/gmock.h>
22
#include <gtest/gtest.h>
33
#include <filesystem>
4+
#include <fstream>
45
#include "utils/config_yaml_utils.h"
56
#include "utils/file_manager_utils.h"
67

engine/utils/config_yaml_utils.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#include "config_yaml_utils.h"
2+
#include <filesystem>
3+
#include <fstream>
4+
#include <iostream>
5+
#include "utils/logging_utils.h"
6+
#include "yaml-cpp/yaml.h"
27

38
namespace config_yaml_utils {
49
cpp::result<void, std::string> CortexConfigMgr::DumpYamlConfig(
@@ -174,4 +179,4 @@ CortexConfig CortexConfigMgr::FromYaml(const std::string& path,
174179
}
175180
}
176181

177-
} // namespace config_yaml_utils
182+
} // namespace config_yaml_utils

engine/utils/config_yaml_utils.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#pragma once
22

3-
#include <filesystem>
4-
#include <fstream>
5-
#include <iostream>
63
#include <mutex>
74
#include <string>
8-
#include "utils/logging_utils.h"
5+
#include <vector>
96
#include "utils/result.hpp"
10-
#include "yaml-cpp/yaml.h"
117

128
namespace config_yaml_utils {
139

0 commit comments

Comments
 (0)