perf: agent editform

This commit is contained in:
archer 2025-12-02 10:21:40 +08:00
parent 13e6ff9bf4
commit 9ed3a350a4
No known key found for this signature in database
GPG Key ID: 4446499B846D4A9E
10 changed files with 70 additions and 89 deletions

View File

@ -105,6 +105,9 @@ export type AppFormEditFormType = {
aiSettings: {
[NodeInputKeyEnum.aiModel]: string;
[NodeInputKeyEnum.aiSystemPrompt]?: string | undefined;
[NodeInputKeyEnum.aiRole]?: string | undefined;
[NodeInputKeyEnum.aiTaskObject]?: string | undefined;
[NodeInputKeyEnum.aiChatTemperature]?: number;
[NodeInputKeyEnum.aiChatMaxToken]?: number;
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;

View File

@ -167,6 +167,8 @@ export enum NodeInputKeyEnum {
aiChatStopSign = 'aiChatStopSign',
aiChatResponseFormat = 'aiChatResponseFormat',
aiChatJsonSchema = 'aiChatJsonSchema',
aiRole = 'aiRole',
aiTaskObject = 'aiTaskObject',
// agent
subApps = 'subApps',

View File

@ -179,14 +179,15 @@ export const MultipleRowSelect = ({
_active={{
transform: 'none'
}}
{...ButtonProps}
{...(isOpen
? {
boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)',
borderColor: 'primary.600',
color: 'primary.700'
color: 'primary.700',
bg: 'white !important'
}
: {})}
{...ButtonProps}
>
<Flex alignItems={'center'}>
<Box flex="1" overflow="hidden" textOverflow="ellipsis" whiteSpace="nowrap">
@ -364,17 +365,18 @@ export const MultipleRowArraySelect = ({
_hover={{
borderColor: 'primary.500'
}}
{...ButtonProps}
{...(isOpen
? {
borderColor: 'primary.600',
color: 'primary.700',
boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)'
boxShadow: '0px 0px 0px 2.4px rgba(51, 112, 255, 0.15)',
bg: 'white !important'
}
: {
borderColor: 'myGray.200',
boxShadow: 'none'
})}
{...ButtonProps}
onClick={() => (isOpen ? onClose() : onOpenSelect())}
className="nowheel"
>

View File

@ -38,8 +38,7 @@
"Team_Tags": "Team tags",
"Tool_name": "Tool name",
"ai_point_price": "Billing",
"ai_role": "AI role description",
"ai_role_placeholder": "Refer to the following template:\n## Role\n## Response style\n## Response rule",
"ai_role": "AI Role",
"ai_settings": "AI Configuration",
"all_apps": "All Applications",
"app.Version name": "Version Name",
@ -323,6 +322,7 @@
"sync_team_app_log_keys": "Restore to team configuration",
"system_secret": "System secret",
"systemval_conflict_globalval": "The variable name conflicts with the system variable, please use other variable names",
"task_object": "mission objectives",
"team_tags_set": "Team tags",
"temperature": "Temperature",
"temperature_tip": "Range 0~10. \nThe larger the value, the more divergent the models answer is; the smaller the value, the more rigorous the answer.",

View File

@ -40,8 +40,7 @@
"Tool_description": "工具描述",
"Tool_name": "工具名称",
"ai_point_price": "AI积分计费",
"ai_role": "AI 角色描述",
"ai_role_placeholder": "参考以下模板:\n## 角色\n## 回答风格\n## 回答要求",
"ai_role": "AI 角色",
"ai_settings": "AI 配置",
"all_apps": "全部应用",
"app.Version name": "版本名称",
@ -337,6 +336,7 @@
"sync_team_app_log_keys": "还原成团队配置",
"system_secret": "系统密钥",
"systemval_conflict_globalval": "变量名与系统变量有冲突,请使用其他变量名",
"task_object": "任务目标",
"team_tags_set": "团队标签",
"temperature": "温度",
"temperature_tip": "范围 010。值越大代表模型回答越发散值越小代表回答越严谨。",

View File

@ -38,8 +38,7 @@
"Tool_description": "工具描述",
"Tool_name": "工具名稱",
"ai_point_price": "AI 積分計費",
"ai_role": "AI 角色描述",
"ai_role_placeholder": "參考以下模板:\n## 角色\n## 回答风格\n## 回答要求",
"ai_role": "AI 角色",
"ai_settings": "AI 設定",
"all_apps": "所有應用程式",
"app.Version name": "版本名稱",
@ -322,6 +321,7 @@
"sync_team_app_log_keys": "還原成團隊配置",
"system_secret": "系統密鑰",
"systemval_conflict_globalval": "變量名與系統變量有衝突,請使用其他變量名",
"task_object": "任務目標",
"team_tags_set": "團隊標籤",
"temperature": "溫度",
"temperature_tip": "範圍 010。\n值越大代表模型回答越發散值越小代表回答越嚴謹。",

View File

@ -71,6 +71,7 @@ const SettingLLMModel = ({
<HStack spacing={1}>
<Box flex={'1 0 0'}>
<AIModelSelector
{...props}
w={'100%'}
value={model}
list={llmModelList.map((item) => ({

View File

@ -46,7 +46,7 @@ const Edit = ({
<AppCard appForm={appForm} setPast={setPast} form2WorkflowFn={agentForm2AppWorkflow} />
</Box>
<Box mt={4} {...cardStyles} boxShadow={'3.5'}>
<Box pb={4}>
<EditForm appForm={appForm} setAppForm={setAppForm} />
</Box>
</Box>

View File

@ -7,7 +7,8 @@ import {
useTheme,
useDisclosure,
Button,
HStack
HStack,
Input
} from '@chakra-ui/react';
import type { AppFormEditFormType } from '@fastgpt/global/core/app/type.d';
import { useRouter } from 'next/router';
@ -35,6 +36,7 @@ import OptimizerPopover from '@/components/common/PromptEditor/OptimizerPopover'
import type { FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node';
import { type SelectedToolItemType, useSkillManager } from './hooks/useSkillManager';
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
import { cardStyles } from '../../constants';
const DatasetSelectModal = dynamic(() => import('@/components/core/app/DatasetSelectModal'));
const DatasetParamsModal = dynamic(() => import('@/components/core/app/DatasetParamsModal'));
@ -67,42 +69,6 @@ const EditForm = ({
const selectDatasets = useMemo(() => appForm?.dataset?.datasets, [appForm]);
const [, startTst] = useTransition();
// Skill picker
// const selectedTools = useMemoEnhance(() => appForm.selectedTools, [appForm.selectedTools]);
// const onUpdateOrAddTool = useCallback(
// (tool: SelectedToolItemType) => {
// setAppForm((state) => {
// if (state.selectedTools.some((t) => t.id === tool.id)) {
// return {
// ...state,
// selectedTools: state.selectedTools.map((t) => (t.id === tool.id ? tool : t))
// };
// }
// return {
// ...state,
// selectedTools: [tool, ...state.selectedTools]
// };
// });
// },
// [setAppForm]
// );
// const onDeleteTool = useCallback(
// (id: string) => {
// setAppForm((state) => ({
// ...state,
// selectedTools: state.selectedTools.filter((t) => t.id !== id)
// }));
// },
// [setAppForm]
// );
// const { SkillModal, skillOption, selectedSkills, onClickSkill, onRemoveSkill } = useSkillManager({
// selectedTools,
// onUpdateOrAddTool,
// onDeleteTool,
// canSelectFile: appForm.chatConfig?.fileSelectConfig?.canSelectFile,
// canSelectImg: appForm.chatConfig?.fileSelectConfig?.canSelectImg
// });
const {
isOpen: isOpenDatasetSelect,
onOpen: onOpenKbSelect,
@ -159,30 +125,9 @@ const EditForm = ({
}
}, [selectedModel, setAppForm]);
const OptimizerPromptPopverComponent = useCallback(
({ iconButtonStyle }: { iconButtonStyle: Record<string, any> }) => {
return (
<OptimizerPopover
iconButtonStyle={iconButtonStyle}
defaultPrompt={appForm.aiSettings.systemPrompt}
onChangeText={(e) => {
setAppForm((state) => ({
...state,
aiSettings: {
...state.aiSettings,
systemPrompt: e
}
}));
}}
/>
);
},
[appForm.aiSettings.systemPrompt, setAppForm]
);
return (
<>
<Box>
<Box mt={4} {...cardStyles} boxShadow={'3.5'}>
{/* ai */}
<Box {...BoxStyles}>
<Flex alignItems={'center'}>
@ -228,15 +173,12 @@ const EditForm = ({
<Box mt={4}>
<HStack w={'100%'}>
<FormLabel>{t('app:ai_role')}</FormLabel>
<QuestionTip label={t('app:ai_role_placeholder')} />
<Box flex={1} />
{/* <VariableTip color={'myGray.500'} /> */}
</HStack>
<Box mt={1}>
<PromptEditor
minH={120}
value={appForm.aiSettings.systemPrompt}
minH={36}
maxH={100}
value={appForm.aiSettings.aiRole}
bg={'myGray.50'}
onChange={(text) => {
startTst(() => {
@ -244,16 +186,41 @@ const EditForm = ({
...state,
aiSettings: {
...state.aiSettings,
systemPrompt: text
aiRole: text
}
}));
});
}}
// variableLabels={formatVariables}
placeholder={t('app:ai_role_placeholder')}
title={t('common:core.ai.Prompt')}
ExtensionPopover={[OptimizerPromptPopverComponent]}
isRichText={true}
title={t('app:ai_role')}
isRichText={false}
/>
</Box>
</Box>
<Box mt={2}>
<HStack w={'100%'}>
<FormLabel>{t('app:task_object')}</FormLabel>
</HStack>
<Box mt={1}>
<PromptEditor
minH={36}
maxH={100}
value={appForm.aiSettings.aiTaskObject}
bg={'myGray.50'}
onChange={(text) => {
startTst(() => {
setAppForm((state) => ({
...state,
aiSettings: {
...state.aiSettings,
aiTaskObject: text
}
}));
});
}}
// variableLabels={formatVariables}
title={t('app:task_object')}
isRichText={false}
/>
</Box>
</Box>
@ -374,7 +341,8 @@ const EditForm = ({
}}
/>
</Box> */}
</Box>
<Box mt={4} {...cardStyles} boxShadow={'3.5'}>
{/* welcome */}
<Box {...BoxStyles}>
<WelcomeTextConfig

View File

@ -44,7 +44,8 @@ export const appWorkflow2AgentForm = ({
const inputMap = new Map(node.inputs.map((input) => [input.key, input.value]));
if (node.flowNodeType === FlowNodeTypeEnum.agent) {
defaultAppForm.aiSettings.model = findInputValueByKey(node.inputs, NodeInputKeyEnum.aiModel);
defaultAppForm.aiSettings.systemPrompt = inputMap.get(NodeInputKeyEnum.aiSystemPrompt);
defaultAppForm.aiSettings.aiRole = inputMap.get(NodeInputKeyEnum.aiRole);
defaultAppForm.aiSettings.aiTaskObject = inputMap.get(NodeInputKeyEnum.aiTaskObject);
defaultAppForm.aiSettings.temperature = inputMap.get(NodeInputKeyEnum.aiChatTemperature);
defaultAppForm.aiSettings.maxHistories = inputMap.get(NodeInputKeyEnum.history);
defaultAppForm.aiSettings.aiChatTopP = inputMap.get(NodeInputKeyEnum.aiChatTopP);
@ -134,14 +135,18 @@ export function agentForm2AppWorkflow(
value: data.aiSettings.model
},
{
key: NodeInputKeyEnum.aiSystemPrompt,
key: NodeInputKeyEnum.aiRole,
renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference],
max: 3000,
valueType: WorkflowIOValueTypeEnum.string,
label: t('common:core.ai.Prompt'),
description: t('common:core.app.tip.systemPromptTip'),
placeholder: t('common:core.app.tip.chatNodeSystemPromptTip'),
value: data.aiSettings.systemPrompt
label: t('app:ai_role'),
value: data.aiSettings.aiRole
},
{
key: NodeInputKeyEnum.aiTaskObject,
renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
label: t('app:task_object'),
value: data.aiSettings.aiTaskObject
},
{
...Input_Template_File_Link,