- |
-
- {t('account:model.function_call')}
-
-
- |
@@ -720,12 +715,13 @@ export const ModelEditModal = ({
value={JSON.stringify(getValues('defaultConfig'), null, 2)}
resize
onChange={(e) => {
+ console.log(e, '===');
if (!e) {
- setValue('defaultConfig', {});
+ setValue('defaultConfig', undefined);
return;
}
try {
- setValue('defaultConfig', JSON.parse(e));
+ setValue('defaultConfig', JSON.parse(e.trim()));
} catch (error) {
console.error(error);
}
diff --git a/projects/app/src/pages/api/core/chat/quote/getQuote.ts b/projects/app/src/pages/api/core/chat/quote/getQuote.ts
index e2dcf7a29..654592272 100644
--- a/projects/app/src/pages/api/core/chat/quote/getQuote.ts
+++ b/projects/app/src/pages/api/core/chat/quote/getQuote.ts
@@ -36,7 +36,7 @@ async function handler(req: ApiRequestProps): Promise): Promise {
- const { id: dataId } = req.query as {
- id: string;
- };
+export type GetQuoteDataProps =
+ | {
+ id: string;
+ }
+ | ({
+ id: string;
+ appId: string;
+ chatId: string;
+ chatItemDataId: string;
+ } & OutLinkChatAuthProps);
- // 凭证校验
- const { datasetData, collection } = await authDatasetData({
- req,
- authToken: true,
- authApiKey: true,
- dataId,
- per: ReadPermissionVal
- });
+async function handler(req: ApiRequestProps): Promise {
+ const { id: dataId } = req.body;
+
+ // Auth
+ const { collection, q, a } = await (async () => {
+ if ('chatId' in req.body) {
+ const { appId, chatId, shareId, outLinkUid, teamId, teamToken, chatItemDataId } = req.body;
+ await authChatCrud({
+ req,
+ authToken: true,
+ appId,
+ chatId,
+ shareId,
+ outLinkUid,
+ teamId,
+ teamToken
+ });
+
+ const datasetData = await MongoDatasetData.findById(dataId);
+ if (!datasetData) {
+ return Promise.reject('Can not find the data');
+ }
+
+ const [collection, { responseDetail }] = await Promise.all([
+ MongoDatasetCollection.findById(datasetData.collectionId).lean(),
+ authChatCrud({
+ req,
+ authToken: true,
+ appId,
+ chatId,
+ shareId,
+ outLinkUid,
+ teamId,
+ teamToken
+ }),
+ authCollectionInChat({
+ appId,
+ chatId,
+ chatItemDataId,
+ collectionIds: [String(datasetData.collectionId)]
+ })
+ ]);
+ if (!collection) {
+ return Promise.reject('Can not find the collection');
+ }
+ if (!responseDetail) {
+ return Promise.reject(ChatErrEnum.unAuthChat);
+ }
+
+ return {
+ collection,
+ q: datasetData.q,
+ a: datasetData.a
+ };
+ } else {
+ const { datasetData, collection } = await authDatasetData({
+ req,
+ authToken: true,
+ authApiKey: true,
+ dataId,
+ per: ReadPermissionVal
+ });
+ return {
+ collection,
+ q: datasetData.q,
+ a: datasetData.a
+ };
+ }
+ })();
return {
collection,
- q: datasetData.q,
- a: datasetData.a
+ q,
+ a
};
}
diff --git a/projects/app/src/service/support/permission/auth/chat.ts b/projects/app/src/service/support/permission/auth/chat.ts
index 5308e5cfc..e42b862e2 100644
--- a/projects/app/src/service/support/permission/auth/chat.ts
+++ b/projects/app/src/service/support/permission/auth/chat.ts
@@ -236,7 +236,7 @@ export const authCollectionInChat = async ({
.flat()
);
- if (collectionIds.every((id) => quoteListSet.has(id))) {
+ if (collectionIds.every((id) => quoteListSet.has(String(id)))) {
return {
chatItem
};
diff --git a/projects/app/src/web/core/dataset/api.ts b/projects/app/src/web/core/dataset/api.ts
index ce2b9e9f9..77a6633aa 100644
--- a/projects/app/src/web/core/dataset/api.ts
+++ b/projects/app/src/web/core/dataset/api.ts
@@ -72,6 +72,7 @@ import type {
getTrainingErrorResponse
} from '@/pages/api/core/dataset/training/getTrainingError';
import type { APIFileItem } from '@fastgpt/global/core/dataset/apiDataset';
+import { GetQuoteDataProps } from '@/pages/api/core/chat/quote/getQuote';
/* ======================== dataset ======================= */
export const getDatasets = (data: GetDatasetListBody) =>
@@ -216,8 +217,8 @@ export const delOneDatasetDataById = (id: string) =>
DELETE(`/core/dataset/data/delete`, { id });
// Get quote data
-export const getQuoteData = (id: string) =>
- GET(`/core/dataset/data/getQuoteData`, { id });
+export const getQuoteData = (data: GetQuoteDataProps) =>
+ POST(`/core/dataset/data/getQuoteData`, data);
/* ================ training ==================== */
export const postRebuildEmbedding = (data: rebuildEmbeddingBody) =>
|