perf: variabel replace;Feat: prompt optimizer code (#5453)

* feat: add prompt optimizer (#5444)

* feat: add prompt optimizer

* fix

* perf: variabel replace

* perf: prompt optimizer code

* feat: init charts shell

* perf: user error remove

---------

Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
Archer
2025-08-14 15:48:22 +08:00
committed by GitHub
parent 6a02d2a2e5
commit 9fbfabac61
35 changed files with 1968 additions and 202 deletions

View File

@@ -1,6 +1,6 @@
import { connectionMongo, getMongoModel } from '../../common/mongo';
const { Schema } = connectionMongo;
import { type ChatSchema as ChatType } from '@fastgpt/global/core/chat/type.d';
import { type ChatSchemaType } from '@fastgpt/global/core/chat/type.d';
import { ChatSourceEnum } from '@fastgpt/global/core/chat/constants';
import {
TeamCollectionName,
@@ -83,10 +83,13 @@ const ChatSchema = new Schema({
//For special storage
type: Object,
default: {}
}
},
initStatistics: Boolean
});
try {
ChatSchema.index({ initCharts: 1 });
ChatSchema.index({ chatId: 1 });
// get user history
ChatSchema.index({ tmbId: 1, appId: 1, top: -1, updateTime: -1 });
@@ -104,4 +107,4 @@ try {
console.log(error);
}
export const MongoChat = getMongoModel<ChatType>(chatCollectionName, ChatSchema);
export const MongoChat = getMongoModel<ChatSchemaType>(chatCollectionName, ChatSchema);

View File

@@ -165,7 +165,7 @@ export async function saveChat({
});
try {
const userId = outLinkUid || tmbId;
const userId = String(outLinkUid || tmbId);
const now = new Date();
const fifteenMinutesAgo = new Date(now.getTime() - 15 * 60 * 1000);