mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
Change embedding (#1463)
* rebuild embedding queue * dataset menu * feat: rebuild data api * feat: ui change embedding model * dataset ui * feat: rebuild index ui * rename collection
This commit is contained in:
@@ -2,7 +2,7 @@ import { connectionMongo, type Model } from '../../mongo';
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
import { RawTextBufferSchemaType } from './type';
|
||||
|
||||
export const collectionName = 'buffer.rawText';
|
||||
export const collectionName = 'buffer_rawtexts';
|
||||
|
||||
const RawTextBufferSchema = new Schema({
|
||||
sourceId: {
|
||||
|
@@ -2,7 +2,7 @@ import { connectionMongo, type Model } from '../../../common/mongo';
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
import { TTSBufferSchemaType } from './type.d';
|
||||
|
||||
export const collectionName = 'buffer.tts';
|
||||
export const collectionName = 'buffer_tts';
|
||||
|
||||
const TTSBufferSchema = new Schema({
|
||||
bufferId: {
|
||||
|
@@ -12,8 +12,6 @@ export const mongoSessionRun = async <T = unknown>(fn: (session: ClientSession)
|
||||
|
||||
return result as T;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
await session.abortTransaction();
|
||||
await session.endSession();
|
||||
return Promise.reject(error);
|
||||
|
@@ -98,12 +98,15 @@ export const deleteDatasetDataVector = async (
|
||||
return `${teamIdWhere} ${datasetIdWhere}`;
|
||||
}
|
||||
|
||||
if ('idList' in props && props.idList) {
|
||||
if ('idList' in props && Array.isArray(props.idList)) {
|
||||
if (props.idList.length === 0) return;
|
||||
return `${teamIdWhere} id IN (${props.idList.map((id) => `'${String(id)}'`).join(',')})`;
|
||||
}
|
||||
return Promise.reject('deleteDatasetData: no where');
|
||||
})();
|
||||
|
||||
if (!where) return;
|
||||
|
||||
try {
|
||||
await PgClient.delete(PgDatasetTableName, {
|
||||
where: [where]
|
||||
|
@@ -2,7 +2,7 @@ import { connectionMongo, type Model } from '../../common/mongo';
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
import { AppVersionSchemaType } from '@fastgpt/global/core/app/version';
|
||||
|
||||
export const AppVersionCollectionName = 'app.versions';
|
||||
export const AppVersionCollectionName = 'app_versions';
|
||||
|
||||
const AppVersionSchema = new Schema({
|
||||
appId: {
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
TeamMemberCollectionName
|
||||
} from '@fastgpt/global/support/user/team/constant';
|
||||
|
||||
export const DatasetColCollectionName = 'dataset.collections';
|
||||
export const DatasetColCollectionName = 'dataset_collections';
|
||||
|
||||
const DatasetCollectionSchema = new Schema({
|
||||
parentId: {
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
import { DatasetCollectionName } from '../schema';
|
||||
import { DatasetColCollectionName } from '../collection/schema';
|
||||
|
||||
export const DatasetDataCollectionName = 'dataset.datas';
|
||||
export const DatasetDataCollectionName = 'dataset_datas';
|
||||
|
||||
const DatasetDataSchema = new Schema({
|
||||
teamId: {
|
||||
@@ -73,7 +73,8 @@ const DatasetDataSchema = new Schema({
|
||||
},
|
||||
inited: {
|
||||
type: Boolean
|
||||
}
|
||||
},
|
||||
rebuilding: Boolean
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -90,10 +91,13 @@ try {
|
||||
{ background: true }
|
||||
);
|
||||
DatasetDataSchema.index({ updateTime: 1 }, { background: true });
|
||||
// rebuild data
|
||||
DatasetDataSchema.index({ rebuilding: 1, teamId: 1, datasetId: 1 }, { background: true });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
export const MongoDatasetData: Model<DatasetDataSchemaType> =
|
||||
models[DatasetDataCollectionName] || model(DatasetDataCollectionName, DatasetDataSchema);
|
||||
|
||||
MongoDatasetData.syncIndexes();
|
||||
|
@@ -10,7 +10,7 @@ import {
|
||||
TeamMemberCollectionName
|
||||
} from '@fastgpt/global/support/user/team/constant';
|
||||
|
||||
export const DatasetTrainingCollectionName = 'dataset.trainings';
|
||||
export const DatasetTrainingCollectionName = 'dataset_trainings';
|
||||
|
||||
const TrainingDataSchema = new Schema({
|
||||
teamId: {
|
||||
@@ -35,8 +35,7 @@ const TrainingDataSchema = new Schema({
|
||||
},
|
||||
billId: {
|
||||
// concat bill
|
||||
type: String,
|
||||
default: ''
|
||||
type: Schema.Types.ObjectId
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
@@ -78,6 +77,9 @@ const TrainingDataSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
dataId: {
|
||||
type: Schema.Types.ObjectId
|
||||
},
|
||||
indexes: {
|
||||
type: [
|
||||
{
|
||||
|
8
packages/service/type/next.d.ts
vendored
Normal file
8
packages/service/type/next.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
export type ApiRequestProps<Body = any, Query = any> = Omit<NextApiRequest, 'query' | 'body'> & {
|
||||
query: Query;
|
||||
body: Body;
|
||||
};
|
||||
|
||||
export type { NextApiResponse as ApiResponseType } from 'next';
|
Reference in New Issue
Block a user