perf: support prompt editor dynamic height increase & modify aichat placeholder (#2817)

This commit is contained in:
heheer
2024-09-27 13:45:44 +08:00
committed by shilin66
parent d5fa6ce734
commit b967be94ef
25 changed files with 57 additions and 79 deletions

View File

@@ -318,7 +318,8 @@ const DatasetParamsModal = ({
</Flex>
<Box mt={1}>
<PromptEditor
h={200}
minH={150}
maxH={300}
showOpenModal={false}
placeholder={t('common:core.module.QueryExtension.placeholder')}
value={cfbBgDesc}

View File

@@ -168,13 +168,14 @@ const EditForm = ({
<Box mt={4}>
<HStack {...LabelStyles} w={'100%'}>
<Box>{t('common:core.ai.Prompt')}</Box>
<QuestionTip label={t('common:core.app.tip.chatNodeSystemPromptTip')} />
<QuestionTip label={t('common:core.app.tip.systemPromptTip')} />
<Box flex={1} />
<VariableTip color={'myGray.500'} />
</HStack>
<Box mt={1}>
<PromptEditor
minH={150}
value={appForm.aiSettings.systemPrompt}
bg={'myGray.50'}
onChange={(text) => {
@@ -190,7 +191,7 @@ const EditForm = ({
}}
variableLabels={formatVariables}
variables={formatVariables}
placeholder={t('common:core.app.tip.chatNodeSystemPromptTip')}
placeholder={t('common:core.app.tip.systemPromptTip')}
title={t('common:core.ai.Prompt')}
/>
</Box>

View File

@@ -701,7 +701,7 @@ const RenderBody = ({
}}
showOpenModal={false}
variableLabels={variables}
h={200}
minH={200}
/>
)}
</Box>

View File

@@ -12,8 +12,7 @@ import {
NumberInput,
NumberInputField,
NumberInputStepper,
Switch,
Textarea
Switch
} from '@chakra-ui/react';
import { TUpdateListItem } from '@fastgpt/global/core/workflow/template/system/variableUpdate/type';
import { NodeInputKeyEnum, WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
@@ -25,7 +24,6 @@ import {
} from '@fastgpt/global/core/workflow/node/constant';
import Container from '../components/Container';
import MyIcon from '@fastgpt/web/components/common/Icon';
import JsonEditor from '@fastgpt/web/components/common/Textarea/JsonEditor';
import { SmallAddIcon } from '@chakra-ui/icons';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { ReferenceValueProps } from '@fastgpt/global/core/workflow/type/io';
@@ -219,7 +217,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
onChange={handleUpdate}
showOpenModal={false}
variableLabels={variables}
h={100}
minH={100}
/>
</Box>
);
@@ -251,7 +249,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
onChange={handleUpdate}
showOpenModal={false}
variableLabels={variables}
h={100}
minH={100}
/>
</Box>
);

View File

@@ -32,14 +32,18 @@ export const ConnectionSourceHandle = ({
);
/*
If the node is folded, must show the handle
If the node is folded and has outputs, must show the handle
hide handle when:
- not folded
- not node
- not sourceHandle
- already connected
*/
if (!isFoldNode && (!node || !node?.sourceHandle?.right || rightTargetConnected)) return null;
if (
!(isFoldNode && node?.outputs.length) &&
(!node || !node?.sourceHandle?.right || rightTargetConnected)
)
return null;
return (
<SourceHandle

View File

@@ -181,7 +181,7 @@ const NodeCard = (props: Props) => {
}}
>
<MyIcon
name={isFolded ? 'core/chat/chevronDown' : 'core/chat/chevronRight'}
name={!isFolded ? 'core/chat/chevronDown' : 'core/chat/chevronRight'}
w={'24px'}
h={'24px'}
color={'myGray.500'}

View File

@@ -259,7 +259,7 @@ const SettingQuotePrompt = (props: RenderInputProps) => {
<PromptEditor
variables={quoteTemplateVariables}
h={160}
minH={160}
title={t('common:core.app.Quote templates')}
placeholder={t('workflow:quote_content_placeholder')}
value={aiChatQuoteTemplate}
@@ -281,7 +281,7 @@ const SettingQuotePrompt = (props: RenderInputProps) => {
<PromptEditor
variables={quotePromptVariables}
title={t('common:core.app.Quote prompt')}
h={300}
minH={300}
placeholder={t('workflow:quote_prompt_tip', {
default: quotePromptTemplates[0].value
})}

View File

@@ -49,7 +49,8 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
variables={variables}
title={t(item.label as any)}
maxLength={item.maxLength}
h={150}
minH={100}
maxH={300}
placeholder={t((item.placeholder as any) || '')}
value={item.value}
onChange={onChange}

View File

@@ -192,7 +192,7 @@ export const emptyTemplates: Record<
max: 3000,
valueType: WorkflowIOValueTypeEnum.string,
label: 'core.ai.Prompt',
description: 'core.app.tip.chatNodeSystemPromptTip',
description: 'core.app.tip.systemPromptTip',
placeholder: 'core.app.tip.chatNodeSystemPromptTip',
value: ''
},

View File

@@ -140,7 +140,7 @@ export function form2AppWorkflow(
max: 3000,
valueType: WorkflowIOValueTypeEnum.string,
label: 'core.ai.Prompt',
description: 'core.app.tip.chatNodeSystemPromptTip',
description: 'core.app.tip.systemPromptTip',
placeholder: 'core.app.tip.chatNodeSystemPromptTip',
value: formData.aiSettings.systemPrompt
},
@@ -461,7 +461,7 @@ export function form2AppWorkflow(
max: 3000,
valueType: WorkflowIOValueTypeEnum.string,
label: 'core.ai.Prompt',
description: 'core.app.tip.chatNodeSystemPromptTip',
description: 'core.app.tip.systemPromptTip',
placeholder: 'core.app.tip.chatNodeSystemPromptTip',
value: formData.aiSettings.systemPrompt
},