Skip to content

Commit 5fb4c9f

Browse files
authored
Merge pull request #225 from import-ai/chore/chat
feat(chat): Support message branch
2 parents 252eea4 + d970d77 commit 5fb4c9f

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
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] = {

src/wizard/stream.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ export class StreamService {
137137
chunk.userId = userId || undefined;
138138
chunk.namespaceId = namespaceId;
139139

140-
if (context.message?.role === OpenAIMessageRole.SYSTEM) {
141-
chunk.parentId = undefined;
142-
}
143-
144140
context.messageId = message.id;
145141
context.message = message.message;
146142
} else if (chunk.response_type === 'delta') {

0 commit comments

Comments
 (0)