4.6.4-alpha (#569)

This commit is contained in:
Archer
2023-12-07 13:43:08 +08:00
committed by GitHub
parent 71afe71192
commit e01c38efe0
80 changed files with 1401 additions and 1109 deletions

View File

@@ -50,10 +50,6 @@ const ChatSchema = new Schema({
top: {
type: Boolean
},
variables: {
type: Object,
default: {}
},
source: {
type: String,
enum: Object.keys(ChatSourceMap),
@@ -62,9 +58,17 @@ const ChatSchema = new Schema({
shareId: {
type: String
},
isInit: {
type: Boolean,
default: false
outLinkUid: {
type: String
},
variables: {
type: Object,
default: {}
},
metadata: {
//For special storage
type: Object,
default: {}
},
content: {
type: [
@@ -89,9 +93,10 @@ const ChatSchema = new Schema({
});
try {
ChatSchema.index({ tmbId: 1 });
ChatSchema.index({ updateTime: -1 });
ChatSchema.index({ appId: 1 });
ChatSchema.index({ tmbId: 1 });
ChatSchema.index({ shareId: 1 });
ChatSchema.index({ updateTime: -1 });
} catch (error) {
console.log(error);
}

View File

@@ -0,0 +1,22 @@
import type { ChatItemType } from '@fastgpt/global/core/chat/type';
import { MongoChatItem } from './chatItemSchema';
export async function getChatItems({
chatId,
limit = 30,
field
}: {
chatId?: string;
limit?: number;
field: string;
}): Promise<{ history: ChatItemType[] }> {
if (!chatId) {
return { history: [] };
}
const history = await MongoChatItem.find({ chatId }, field).sort({ _id: -1 }).limit(limit);
history.reverse();
return { history };
}