Files
FastGPT/src/service/models/chat.ts
Textcat 7fe39c2515 feat:自定义历史聊天标题 (#41)
* feat:自定义历史聊天标题

* Update chat.ts

* perf:自定义聊天标题

* feat: google auth

* perf:将修改标题移入右键菜单

* perf:updatetitle

---------

Co-authored-by: archer <545436317@qq.com>
2023-05-29 20:36:28 +08:00

76 lines
1.4 KiB
TypeScript

import { Schema, model, models, Model } from 'mongoose';
import { ChatSchema as ChatType } from '@/types/mongoSchema';
import { ChatRoleMap } from '@/constants/chat';
const ChatSchema = new Schema({
userId: {
type: Schema.Types.ObjectId,
ref: 'user',
required: true
},
modelId: {
type: Schema.Types.ObjectId,
ref: 'model',
required: true
},
expiredTime: {
// 过期时间
type: Number,
default: () => new Date()
},
loadAmount: {
// 剩余加载次数
type: Number,
default: -1
},
updateTime: {
type: Date,
default: () => new Date()
},
title: {
type: String,
default: '历史记录'
},
customTitle: {
type: Boolean,
default: false
},
latestChat: {
type: String,
default: ''
},
content: {
type: [
{
obj: {
type: String,
required: true,
enum: Object.keys(ChatRoleMap)
},
value: {
type: String,
required: true
},
quote: {
type: [
{
id: String,
q: String,
a: String,
isEdit: Boolean
}
],
default: []
},
systemPrompt: {
type: String,
default: ''
}
}
],
default: []
}
});
export const Chat: Model<ChatType> = models['chat'] || model('chat', ChatSchema);