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

Commit 2578833

Browse files
committed
fix ci windows
Signed-off-by: James <[email protected]>
1 parent 3ee1e2b commit 2578833

File tree

6 files changed

+136
-21
lines changed

6 files changed

+136
-21
lines changed

engine/common/message.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ namespace ThreadMessage {
2121

2222
// Represents a message within a thread.
2323
struct Message : JsonSerializable {
24+
Message() = default;
25+
26+
Message(Message&&) = default;
27+
28+
Message& operator=(Message&&) = default;
29+
30+
Message(const Message&) = delete;
31+
32+
Message& operator=(const Message&) = delete;
2433

2534
// The identifier, which can be referenced in API endpoints.
2635
std::string id;
@@ -82,19 +91,19 @@ struct Message : JsonSerializable {
8291
if (message.created_at == 0 && root["created"].asUInt64() != 0) {
8392
message.created_at = root["created"].asUInt64() / 1000;
8493
}
85-
message.thread_id = root["thread_id"].asString();
86-
message.status = StatusFromString(root["status"].asString());
94+
message.thread_id = std::move(root["thread_id"].asString());
95+
message.status = StatusFromString(std::move(root["status"].asString()));
8796

8897
message.incomplete_details =
8998
IncompleteDetail::FromJson(std::move(root["incomplete_details"]))
9099
.value();
91100
message.completed_at = root["completed_at"].asUInt();
92101
message.incomplete_at = root["incomplete_at"].asUInt();
93-
message.role = RoleFromString(root["role"].asString());
102+
message.role = RoleFromString(std::move(root["role"].asString()));
94103
message.content = ParseContents(std::move(root["content"])).value();
95104

96-
message.assistant_id = root["assistant_id"].asString();
97-
message.run_id = root["run_id"].asString();
105+
message.assistant_id = std::move(root["assistant_id"].asString());
106+
message.run_id = std::move(root["run_id"].asString());
98107
message.attachments =
99108
ParseAttachments(std::move(root["attachments"])).value();
100109

engine/common/message_content.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ struct Content : JsonSerializable {
1010

1111
Content(const std::string& type) : type{type} {}
1212

13+
Content(const Content&) = delete;
14+
15+
Content& operator=(const Content&) = delete;
16+
17+
Content(Content&&) noexcept = default;
18+
19+
Content& operator=(Content&&) noexcept = default;
20+
1321
virtual ~Content() = default;
1422
};
1523
}; // namespace ThreadMessage

engine/common/message_content_image_file.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,31 @@ struct ImageFile {
99

1010
// Specifies the detail level of the image if specified by the user. low uses fewer tokens, you can opt in to high resolution using high.
1111
std::string detail;
12+
13+
ImageFile() = default;
14+
15+
ImageFile(ImageFile&&) noexcept = default;
16+
17+
ImageFile& operator=(ImageFile&&) noexcept = default;
18+
19+
ImageFile(const ImageFile&) = delete;
20+
21+
ImageFile& operator=(const ImageFile&) = delete;
1222
};
1323

1424
// References an image File in the content of a message.
1525
struct ImageFileContent : Content {
1626

1727
ImageFileContent() : Content("image_file") {}
1828

29+
ImageFileContent(ImageFileContent&&) noexcept = default;
30+
31+
ImageFileContent& operator=(ImageFileContent&&) noexcept = default;
32+
33+
ImageFileContent(const ImageFileContent&) = delete;
34+
35+
ImageFileContent& operator=(const ImageFileContent&) = delete;
36+
1937
ImageFile image_file;
2038

2139
static cpp::result<ImageFileContent, std::string> FromJson(
@@ -27,9 +45,9 @@ struct ImageFileContent : Content {
2745
try {
2846
ImageFileContent content;
2947
ImageFile image_file;
30-
image_file.detail = json["image_file"]["detail"].asString();
31-
image_file.file_id = json["image_file"]["file_id"].asString();
32-
content.image_file = image_file;
48+
image_file.detail = std::move(json["image_file"]["detail"].asString());
49+
image_file.file_id = std::move(json["image_file"]["file_id"].asString());
50+
content.image_file = std::move(image_file);
3351
return content;
3452
} catch (const std::exception& e) {
3553
return cpp::fail(std::string("FromJson failed: ") + e.what());

engine/common/message_content_image_url.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ struct ImageUrl {
1010

1111
// Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto
1212
std::string detail;
13+
14+
ImageUrl() = default;
15+
16+
ImageUrl(ImageUrl&&) noexcept = default;
17+
18+
ImageUrl& operator=(ImageUrl&&) noexcept = default;
19+
20+
ImageUrl(const ImageUrl&) = delete;
21+
22+
ImageUrl& operator=(const ImageUrl&) = delete;
1323
};
1424

1525
// References an image URL in the content of a message.
@@ -18,6 +28,14 @@ struct ImageUrlContent : Content {
1828
// The type of the content part.
1929
ImageUrlContent(const std::string& type) : Content(type) {}
2030

31+
ImageUrlContent(ImageUrlContent&&) noexcept = default;
32+
33+
ImageUrlContent& operator=(ImageUrlContent&&) noexcept = default;
34+
35+
ImageUrlContent(const ImageUrlContent&) = delete;
36+
37+
ImageUrlContent& operator=(const ImageUrlContent&) = delete;
38+
2139
ImageUrl image_url;
2240

2341
static cpp::result<ImageUrlContent, std::string> FromJson(
@@ -29,9 +47,9 @@ struct ImageUrlContent : Content {
2947
try {
3048
ImageUrlContent content{"image_url"};
3149
ImageUrl image_url;
32-
image_url.url = json["image_url"]["url"].asString();
33-
image_url.detail = json["image_url"]["detail"].asString();
34-
content.image_url = image_url;
50+
image_url.url = std::move(json["image_url"]["url"].asString());
51+
image_url.detail = std::move(json["image_url"]["detail"].asString());
52+
content.image_url = std::move(image_url);
3553
return content;
3654
} catch (const std::exception& e) {
3755
return cpp::fail(std::string("FromJson failed: ") + e.what());

engine/common/message_content_refusal.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ namespace ThreadMessage {
77
struct Refusal : Content {
88

99
// Always refusal.
10-
Refusal() : Content("refusal") {}
10+
Refusal(const std::string& refusal) : Content("refusal"), refusal{refusal} {}
11+
12+
Refusal(Refusal&&) noexcept = default;
13+
14+
Refusal& operator=(Refusal&&) noexcept = default;
15+
16+
Refusal(const Refusal&) = delete;
17+
18+
Refusal& operator=(const Refusal&) = delete;
1119

1220
std::string refusal;
1321

@@ -17,8 +25,7 @@ struct Refusal : Content {
1725
}
1826

1927
try {
20-
Refusal content;
21-
content.refusal = json["refusal"].asString();
28+
Refusal content{std::move(json["refusal"].asString())};
2229
return content;
2330
} catch (const std::exception& e) {
2431
return cpp::fail(std::string("FromJson failed: ") + e.what());

engine/common/message_content_text.h

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,27 @@ struct FileCitationWrapper : Annotation {
3333
uint32_t end_index)
3434
: Annotation("file_citation", text, start_index, end_index) {}
3535

36+
FileCitationWrapper(FileCitationWrapper&&) noexcept = default;
37+
38+
FileCitationWrapper& operator=(FileCitationWrapper&&) noexcept = default;
39+
40+
FileCitationWrapper(const FileCitationWrapper&) = delete;
41+
42+
FileCitationWrapper& operator=(const FileCitationWrapper&) = delete;
43+
3644
struct FileCitation {
3745
// The ID of the specific File the citation is from.
3846
std::string file_id;
47+
48+
FileCitation() = default;
49+
50+
FileCitation(FileCitation&&) noexcept = default;
51+
52+
FileCitation& operator=(FileCitation&&) noexcept = default;
53+
54+
FileCitation(const FileCitation&) = delete;
55+
56+
FileCitation& operator=(const FileCitation&) = delete;
3957
};
4058

4159
FileCitation file_citation;
@@ -62,9 +80,27 @@ struct FilePathWrapper : Annotation {
6280
uint32_t end_index)
6381
: Annotation("file_path", text, start_index, end_index) {}
6482

83+
FilePathWrapper(FilePathWrapper&&) noexcept = default;
84+
85+
FilePathWrapper& operator=(FilePathWrapper&&) noexcept = default;
86+
87+
FilePathWrapper(const FilePathWrapper&) = delete;
88+
89+
FilePathWrapper& operator=(const FilePathWrapper&) = delete;
90+
6591
struct FilePath {
6692
// The ID of the file that was generated.
6793
std::string file_id;
94+
95+
FilePath() = default;
96+
97+
FilePath(FilePath&&) noexcept = default;
98+
99+
FilePath& operator=(FilePath&&) noexcept = default;
100+
101+
FilePath(const FilePath&) = delete;
102+
103+
FilePath& operator=(const FilePath&) = delete;
68104
};
69105

70106
FilePath file_path;
@@ -86,6 +122,17 @@ struct FilePathWrapper : Annotation {
86122

87123
struct Text : JsonSerializable {
88124
// The data that makes up the text.
125+
126+
Text() = default;
127+
128+
Text(Text&&) noexcept = default;
129+
130+
Text& operator=(Text&&) noexcept = default;
131+
132+
Text(const Text&) = delete;
133+
134+
Text& operator=(const Text&) = delete;
135+
89136
std::string value;
90137

91138
std::vector<std::unique_ptr<Annotation>> annotations;
@@ -102,22 +149,23 @@ struct Text : JsonSerializable {
102149
// Parse annotations array
103150
if (json.isMember("annotations") && json["annotations"].isArray()) {
104151
for (const auto& annotation_json : json["annotations"]) {
105-
std::string type = annotation_json["type"].asString();
106-
std::string annotation_text = annotation_json["text"].asString();
152+
std::string type = std::move(annotation_json["type"].asString());
153+
std::string annotation_text =
154+
std::move(annotation_json["text"].asString());
107155
uint32_t start_index = annotation_json["start_index"].asUInt();
108156
uint32_t end_index = annotation_json["end_index"].asUInt();
109157

110158
if (type == "file_citation") {
111159
auto citation = std::make_unique<FileCitationWrapper>(
112160
annotation_text, start_index, end_index);
113-
citation->file_citation.file_id =
114-
annotation_json["file_citation"]["file_id"].asString();
161+
citation->file_citation.file_id = std::move(
162+
annotation_json["file_citation"]["file_id"].asString());
115163
text.annotations.push_back(std::move(citation));
116164
} else if (type == "file_path") {
117165
auto file_path = std::make_unique<FilePathWrapper>(
118166
annotation_text, start_index, end_index);
119167
file_path->file_path.file_id =
120-
annotation_json["file_path"]["file_id"].asString();
168+
std::move(annotation_json["file_path"]["file_id"].asString());
121169
text.annotations.push_back(std::move(file_path));
122170
} else {
123171
CTL_WRN("Unknown annotation type: " + type);
@@ -156,6 +204,14 @@ struct TextContent : Content {
156204
// Always text.
157205
TextContent() : Content("text") {}
158206

207+
TextContent(TextContent&&) noexcept = default;
208+
209+
TextContent& operator=(TextContent&&) noexcept = default;
210+
211+
TextContent(const TextContent&) = delete;
212+
213+
TextContent& operator=(const TextContent&) = delete;
214+
159215
Text text;
160216

161217
static cpp::result<TextContent, std::string> FromJson(Json::Value&& json) {
@@ -165,8 +221,7 @@ struct TextContent : Content {
165221

166222
try {
167223
TextContent content;
168-
content.type = json["type"].asString();
169-
content.text = Text::FromJson(std::move(json["text"])).value();
224+
content.text = std::move(Text::FromJson(std::move(json["text"])).value());
170225
return content;
171226
} catch (const std::exception& e) {
172227
return cpp::fail(std::string("FromJson failed: ") + e.what());

0 commit comments

Comments
 (0)