Revert "sub plan page (#885)" (#886)

This reverts commit 443ad37b6a.
This commit is contained in:
Archer
2024-02-23 17:48:15 +08:00
committed by GitHub
parent 443ad37b6a
commit fd9b6291af
246 changed files with 4281 additions and 6286 deletions

View File

@@ -5,7 +5,6 @@ import { MongoChatItem } from '@fastgpt/service/core/chat/chatItemSchema';
import { MongoChat } from '@fastgpt/service/core/chat/chatSchema';
import { addLog } from '@fastgpt/service/common/system/log';
import { chatContentReplaceBlock } from '@fastgpt/global/core/chat/utils';
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
type Props = {
chatId: string;
@@ -47,54 +46,61 @@ export async function saveChat({
...chat?.metadata,
...metadata
};
const title =
chatContentReplaceBlock(content[0].value).slice(0, 20) ||
content[1]?.value?.slice(0, 20) ||
'Chat';
await mongoSessionRun(async (session) => {
await MongoChatItem.insertMany(
const promise: any[] = [
MongoChatItem.insertMany(
content.map((item) => ({
chatId,
teamId,
tmbId,
appId,
...item
})),
{ session }
);
}))
)
];
if (chat) {
chat.title = title;
chat.updateTime = new Date();
chat.metadata = metadataUpdate;
await chat.save({ session });
} else {
MongoChat.create(
[
{
chatId,
teamId,
tmbId,
appId,
variables,
title,
source,
shareId,
outLinkUid,
metadata: metadataUpdate
}
],
{ session }
);
}
});
const title =
chatContentReplaceBlock(content[0].value).slice(0, 20) ||
content[1]?.value?.slice(0, 20) ||
'Chat';
if (chat) {
promise.push(
MongoChat.updateOne(
{ appId, chatId },
{
title,
updateTime: new Date(),
metadata: metadataUpdate
}
)
);
} else {
promise.push(
MongoChat.create({
chatId,
teamId,
tmbId,
appId,
variables,
title,
source,
shareId,
outLinkUid,
metadata: metadataUpdate
})
);
}
if (updateUseTime && source === ChatSourceEnum.online) {
MongoApp.findByIdAndUpdate(appId, {
updateTime: new Date()
});
promise.push(
MongoApp.findByIdAndUpdate(appId, {
updateTime: new Date()
})
);
}
await Promise.all(promise);
} catch (error) {
addLog.error(`update chat history error`, error);
}