mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 12:20:34 +00:00

* rebuild embedding queue * dataset menu * feat: rebuild data api * feat: ui change embedding model * dataset ui * feat: rebuild index ui * rename collection
34 lines
816 B
TypeScript
34 lines
816 B
TypeScript
import { connectionMongo, type Model } from '../../mongo';
|
|
const { Schema, model, models } = connectionMongo;
|
|
import { RawTextBufferSchemaType } from './type';
|
|
|
|
export const collectionName = 'buffer_rawtexts';
|
|
|
|
const RawTextBufferSchema = new Schema({
|
|
sourceId: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
rawText: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
createTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
metadata: Object
|
|
});
|
|
|
|
try {
|
|
RawTextBufferSchema.index({ sourceId: 1 });
|
|
// 20 minutes
|
|
RawTextBufferSchema.index({ createTime: 1 }, { expireAfterSeconds: 20 * 60 });
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoRawTextBuffer: Model<RawTextBufferSchemaType> =
|
|
models[collectionName] || model(collectionName, RawTextBufferSchema);
|
|
MongoRawTextBuffer.syncIndexes();
|