mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
Context extract support value type (#1620)
* perf: chat box components * perf: chatbox context * feat: extract support value type * workflow performance * update doc * feat: error response * feat: error response * oauth sort * perf: logo * fix: update laf account * perf: team permission api * update type
This commit is contained in:
@@ -183,7 +183,7 @@ ${description ? `- ${description}` : ''}
|
||||
> = {};
|
||||
extractKeys.forEach((item) => {
|
||||
properties[item.key] = {
|
||||
type: 'string',
|
||||
type: item.valueType || 'string',
|
||||
description: item.desc,
|
||||
...(item.enum ? { enum: item.enum.split('\n') } : {})
|
||||
};
|
||||
@@ -198,7 +198,7 @@ ${description ? `- ${description}` : ''}
|
||||
required: []
|
||||
}
|
||||
};
|
||||
|
||||
console.log(properties);
|
||||
return {
|
||||
filterMessages,
|
||||
agentFunction
|
||||
@@ -319,12 +319,16 @@ const completions = async ({
|
||||
content: replaceVariable(extractModel.customExtractPrompt || Prompt_ExtractJson, {
|
||||
description,
|
||||
json: extractKeys
|
||||
.map(
|
||||
(item) =>
|
||||
`{"key":"${item.key}", "description":"${item.desc}"${
|
||||
item.enum ? `, "enum":"[${item.enum.split('\n')}]"` : ''
|
||||
}}`
|
||||
)
|
||||
.map((item) => {
|
||||
const valueType = item.valueType || 'string';
|
||||
if (valueType !== 'string' && valueType !== 'number') {
|
||||
item.enum = undefined;
|
||||
}
|
||||
|
||||
return `{"type":${item.valueType || 'string'}, "key":"${item.key}", "description":"${item.desc}" ${
|
||||
item.enum ? `, "enum":"[${item.enum.split('\n')}]"` : ''
|
||||
}}`;
|
||||
})
|
||||
.join('\n'),
|
||||
text: `${histories.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`).join('\n')}
|
||||
Human: ${content}`
|
||||
@@ -365,6 +369,7 @@ Human: ${content}`
|
||||
arg: json5.parse(jsonStr) as Record<string, any>
|
||||
};
|
||||
} catch (error) {
|
||||
console.log('Extract error, ai answer:', answer);
|
||||
console.log(error);
|
||||
return {
|
||||
rawResponse: answer,
|
||||
|
@@ -45,7 +45,11 @@ export const dispatchRunCode = async (props: RunCodeType): Promise<RunCodeRespon
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
[NodeOutputKeyEnum.error]: formatHttpError(error)
|
||||
[NodeOutputKeyEnum.error]: formatHttpError(error),
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
customInputs: customVariables,
|
||||
error: formatHttpError(error)
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@@ -5,6 +5,7 @@ import { TeamMemberRoleEnum } from '@fastgpt/global/support/user/team/constant';
|
||||
import { parseHeaderCert } from '../controller';
|
||||
import { getTmbInfoByTmbId } from '../../user/team/controller';
|
||||
import { UserErrEnum } from '../../../../global/common/error/code/user';
|
||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
|
||||
export async function authUserNotVisitor(props: AuthModeType): Promise<
|
||||
AuthResponseType & {
|
||||
@@ -47,3 +48,19 @@ export async function authUserRole(props: AuthModeType): Promise<
|
||||
canWrite
|
||||
};
|
||||
}
|
||||
|
||||
/* auth teamMember in team role */
|
||||
export async function authTeamOwner(props: AuthModeType): Promise<
|
||||
AuthResponseType & {
|
||||
role: `${TeamMemberRoleEnum}`;
|
||||
teamOwner: boolean;
|
||||
}
|
||||
> {
|
||||
const authRes = await authUserRole(props);
|
||||
|
||||
if (authRes.role !== TeamMemberRoleEnum.owner) {
|
||||
return Promise.reject(TeamErrEnum.unAuthTeam);
|
||||
}
|
||||
|
||||
return authRes;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import {
|
||||
} from '@fastgpt/global/support/user/team/constant';
|
||||
import { MongoTeamMember } from './teamMemberSchema';
|
||||
import { MongoTeam } from './teamSchema';
|
||||
import { UpdateTeamProps } from '@fastgpt/global/support/user/team/controller';
|
||||
|
||||
async function getTeamMember(match: Record<string, any>): Promise<TeamItemType> {
|
||||
const tmb = (await MongoTeamMember.findOne(match).populate('teamId')) as TeamMemberWithTeamSchema;
|
||||
@@ -108,3 +109,18 @@ export async function createDefaultTeam({
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateTeam({
|
||||
teamId,
|
||||
name,
|
||||
avatar,
|
||||
teamDomain,
|
||||
lafAccount
|
||||
}: UpdateTeamProps & { teamId: string }) {
|
||||
await MongoTeam.findByIdAndUpdate(teamId, {
|
||||
name,
|
||||
avatar,
|
||||
teamDomain,
|
||||
lafAccount
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user