fix:agent eval and doc file (#6158)

* agent eval

* eval auth

* html transofrm size

* fix: test

---------

Co-authored-by: xxyyh <2289112474@qq>
Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
YeYuheng
2025-12-30 11:20:55 +08:00
committed by GitHub
parent 5ff4cc11b0
commit 84570bda6f
7 changed files with 54 additions and 22 deletions
@@ -7,6 +7,7 @@ import type { EvaluationSchemaType } from '@fastgpt/global/core/app/evaluation/t
import type { AuthModeType } from '../type';
import { MongoEvaluation } from '../../../core/app/evaluation/evalSchema';
import { parseHeaderCert } from '../auth/common';
import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
export const authEval = async ({
evalId,
@@ -21,7 +22,13 @@ export const authEval = async ({
}> => {
const { teamId, tmbId, isRoot } = await parseHeaderCert(props);
const evaluation = await MongoEvaluation.findById(evalId, 'tmbId').lean();
const evaluation = await MongoEvaluation.findOne(
{
_id: evalId,
teamId
},
'tmbId appId'
).lean();
if (!evaluation) {
return Promise.reject('Evaluation not found');
}
@@ -34,28 +41,37 @@ export const authEval = async ({
};
}
// App read per
if (per === ReadPermissionVal) {
try {
// App read per
if (per === ReadPermissionVal) {
await authAppByTmbId({
tmbId,
appId: evaluation.appId,
per: ReadPermissionVal,
isRoot
});
return {
teamId,
tmbId,
evaluation
};
}
// Write per
await authAppByTmbId({
tmbId,
appId: evaluation.appId,
per: ReadPermissionVal,
per: ManagePermissionVal,
isRoot
});
return {
teamId,
tmbId,
evaluation
};
} catch (error) {
// If app does not exist, allow operation (app was deleted, allow eval cleanup)
if (error !== AppErrEnum.unExist) {
throw error;
}
}
// Write per
await authAppByTmbId({
tmbId,
appId: evaluation.appId,
per: ManagePermissionVal,
isRoot
});
return {
teamId,
tmbId,