Skip to content

Commit d970d77

Browse files
committed
chore(chat): Filter system message in conversation dto
1 parent 0b4cd8e commit d970d77

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/conversations/conversations.service.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,11 @@ export class ConversationsService {
220220
return detail;
221221
}
222222

223-
const system_message: Message = messages[0];
224-
if (system_message.message.role !== OpenAIMessageRole.SYSTEM) {
225-
const message = this.i18n.t('system.errors.firstMessageNotSystem');
226-
throw new AppException(
227-
message,
228-
'FIRST_MESSAGE_NOT_SYSTEM',
229-
HttpStatus.INTERNAL_SERVER_ERROR,
230-
);
231-
}
232223
const childrenMap: Record<string, string[]> = {};
233224
for (const msg of messages) {
234-
if (msg.id === system_message.id) {
225+
if (msg.message.role === OpenAIMessageRole.SYSTEM) {
235226
continue;
236227
}
237-
if (msg.parentId === system_message.id) {
238-
msg.parentId = null;
239-
}
240228
if (msg.parentId) {
241229
if (!childrenMap[msg.parentId]) {
242230
childrenMap[msg.parentId] = [];
@@ -245,7 +233,7 @@ export class ConversationsService {
245233
}
246234
}
247235
for (const msg of messages) {
248-
if (msg.id === system_message.id) {
236+
if (msg.message.role === OpenAIMessageRole.SYSTEM) {
249237
continue;
250238
}
251239
detail.mapping[msg.id] = {

0 commit comments

Comments
 (0)