v4.6.6-fix (#676)

This commit is contained in:
Archer
2024-01-02 14:18:51 +08:00
committed by GitHub
parent d645a7406b
commit 2e75851b02
179 changed files with 279 additions and 5964 deletions

View File

@@ -26,6 +26,7 @@ export type CreateDatasetCollectionParams = {
fileId?: string;
rawLink?: string;
qaPrompt?: string;
rawTextLength?: number;
hashRawText?: string;
metadata?: Record<string, any>;
};

View File

@@ -47,6 +47,7 @@ export type DatasetCollectionSchemaType = {
fileId?: string;
rawLink?: string;
qaPrompt?: string;
rawTextLength?: number;
hashRawText?: string;
metadata?: Record<string, any>;
};

View File

@@ -3,6 +3,7 @@ import { customAlphabet } from 'nanoid';
import multer from 'multer';
import path from 'path';
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
import fs from 'fs';
const nanoid = customAlphabet('1234567890abcdef', 12);
@@ -69,3 +70,13 @@ export function getUploadModel({ maxSize = 500 }: { maxSize?: number }) {
return new UploadModel();
}
export const removeFilesByPaths = (paths: string[]) => {
paths.forEach((path) => {
fs.unlink(path, (err) => {
if (err) {
console.error(err);
}
});
});
};

View File

@@ -18,6 +18,7 @@ export async function createOneCollection({
rawLink,
qaPrompt,
hashRawText,
rawTextLength,
metadata = {}
}: CreateDatasetCollectionParams & { teamId: string; tmbId: string }) {
const { _id } = await MongoDatasetCollection.create({
@@ -32,6 +33,7 @@ export async function createOneCollection({
fileId,
rawLink,
qaPrompt,
rawTextLength,
hashRawText,
metadata
});

View File

@@ -75,6 +75,9 @@ const DatasetCollectionSchema = new Schema({
qaPrompt: {
type: String
},
rawTextLength: {
type: Number
},
hashRawText: {
type: String
},

View File

@@ -11,7 +11,7 @@ export async function authOpenApiKey({ apikey }: { apikey: string }) {
return Promise.reject(ERROR_ENUM.unAuthApiKey);
}
try {
const openApi = await MongoOpenApi.findOne({ apiKey: apikey });
const openApi = await MongoOpenApi.findOne({ apiKey: apikey.trim() });
if (!openApi) {
return Promise.reject(ERROR_ENUM.unAuthApiKey);
}

View File

@@ -116,8 +116,7 @@ export async function authDatasetCollection({
return Promise.reject(DatasetErrEnum.unAuthDatasetCollection);
}
const isOwner =
String(collection.datasetId.tmbId) === tmbId || role === TeamMemberRoleEnum.owner;
const isOwner = String(collection.tmbId) === tmbId || role === TeamMemberRoleEnum.owner;
const canWrite =
isOwner ||
(role !== TeamMemberRoleEnum.visitor &&