mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
Some checks are pending
Document deploy / sync-images (push) Waiting to run
Document deploy / generate-timestamp (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.cn suffix:cn]) (push) Blocked by required conditions
Document deploy / build-images (map[domain:https://fastgpt.io suffix:io]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.cn kube_config:KUBE_CONFIG_CN suffix:cn]) (push) Blocked by required conditions
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.io kube_config:KUBE_CONFIG_IO suffix:io]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / get-vars (push) Waiting to run
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Blocked by required conditions
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Blocked by required conditions
* perf: html2md * perf: index * Add model log * update next version * log index
103 lines
2.4 KiB
TypeScript
103 lines
2.4 KiB
TypeScript
import { connectionMongo, getMongoModel } from '../../common/mongo';
|
|
const { Schema } = connectionMongo;
|
|
import { type ChatItemSchema as ChatItemType } from '@fastgpt/global/core/chat/type';
|
|
import { ChatRoleMap } from '@fastgpt/global/core/chat/constants';
|
|
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
|
import {
|
|
TeamCollectionName,
|
|
TeamMemberCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
import { AppCollectionName } from '../app/schema';
|
|
import { userCollectionName } from '../../support/user/schema';
|
|
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
|
import { ChatItemCollectionName } from './constants';
|
|
|
|
const ChatItemSchema = new Schema({
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
tmbId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamMemberCollectionName,
|
|
required: true
|
|
},
|
|
userId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: userCollectionName
|
|
},
|
|
chatId: {
|
|
type: String,
|
|
require: true
|
|
},
|
|
dataId: {
|
|
type: String,
|
|
require: true,
|
|
default: () => getNanoid(24)
|
|
},
|
|
appId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: AppCollectionName,
|
|
required: true
|
|
},
|
|
time: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
hideInUI: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
obj: {
|
|
// chat role
|
|
type: String,
|
|
required: true,
|
|
enum: Object.keys(ChatRoleMap)
|
|
},
|
|
value: {
|
|
// chat content
|
|
type: Array,
|
|
default: []
|
|
},
|
|
|
|
// Field memory
|
|
memories: Object,
|
|
errorMsg: String,
|
|
durationSeconds: Number,
|
|
citeCollectionIds: [String],
|
|
|
|
// Feedback
|
|
userGoodFeedback: String,
|
|
userBadFeedback: String,
|
|
customFeedbacks: [String],
|
|
adminFeedback: {
|
|
type: {
|
|
datasetId: String,
|
|
collectionId: String,
|
|
dataId: String,
|
|
q: String,
|
|
a: String
|
|
}
|
|
},
|
|
isFeedbackRead: Boolean,
|
|
|
|
// @deprecated
|
|
[DispatchNodeResponseKeyEnum.nodeResponse]: Array
|
|
});
|
|
|
|
/*
|
|
delete by app;
|
|
delete by chat id;
|
|
get chat list;
|
|
get chat logs;
|
|
close custom feedback;
|
|
*/
|
|
ChatItemSchema.index({ appId: 1, chatId: 1, dataId: 1 });
|
|
// Anchor filter
|
|
ChatItemSchema.index({ appId: 1, chatId: 1, _id: -1 });
|
|
// timer, clear history
|
|
ChatItemSchema.index({ teamId: 1, time: -1 });
|
|
|
|
export const MongoChatItem = getMongoModel<ChatItemType>(ChatItemCollectionName, ChatItemSchema);
|