diff --git a/web/app/components/app/configuration/prompt-value-panel/index.tsx b/web/app/components/app/configuration/prompt-value-panel/index.tsx index 949a7d2097..3ea87683ea 100644 --- a/web/app/components/app/configuration/prompt-value-panel/index.tsx +++ b/web/app/components/app/configuration/prompt-value-panel/index.tsx @@ -1,6 +1,6 @@ 'use client' import type { FC } from 'react' -import React from 'react' +import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import { @@ -13,6 +13,7 @@ import { AppType } from '@/types/app' import Select from '@/app/components/base/select' import { DEFAULT_VALUE_MAX_LEN } from '@/config' import Button from '@/app/components/base/button' +import { ChevronDown, ChevronRight } from '@/app/components/base/icons/src/vender/line/arrows' export type IPromptValuePanelProps = { appType: AppType @@ -37,6 +38,8 @@ const PromptValuePanel: FC = ({ }) => { const { t } = useTranslation() const { modelConfig, inputs, setInputs } = useContext(ConfigContext) + const [promptPreviewCollapse, setPromptPreviewCollapse] = useState(false) + const [userInputFieldCollapse, setUserInputFieldCollapse] = useState(false) const promptTemplate = modelConfig.configs.prompt_template const promptVariables = modelConfig.configs.prompt_variables.filter(({ key, name }) => { return key && key?.trim() && name && name?.trim() @@ -63,93 +66,115 @@ const PromptValuePanel: FC = ({ } const promptPreview = ( -
+
-
+
setPromptPreviewCollapse(!promptPreviewCollapse)}> {starIcon}
{t('appDebug.inputs.previewTitle')}
-
-
{ - (promptTemplate && promptTemplate?.trim()) - ? ( -
/g, '>'), promptVariables, inputs)), - }} - > -
- ) - : ( -
{t('appDebug.inputs.noPrompt')}
- ) + promptPreviewCollapse + ? + : }
+ { + !promptPreviewCollapse && ( +
+ { + (promptTemplate && promptTemplate?.trim()) + ? ( +
/g, '>'), promptVariables, inputs)), + }} + > +
+ ) + : ( +
{t('appDebug.inputs.noPrompt')}
+ ) + } +
+ ) + }
) return ( -
{promptPreview} -
-
-
+
+
+
setUserInputFieldCollapse(!userInputFieldCollapse)}>
-
{t('appDebug.inputs.userInputField')}
+
{t('appDebug.inputs.userInputField')}
+ { + userInputFieldCollapse + ? + : + }
- {appType === AppType.completion && promptVariables.length > 0 && ( + {appType === AppType.completion && promptVariables.length > 0 && !userInputFieldCollapse && (
{t('appDebug.inputs.completionVarTip')}
)}
{ - promptVariables.length > 0 - ? ( -
- {promptVariables.map(({ key, name, type, options, max_length, required }) => ( -
-
{name || key}
- {type === 'select' - ? ( - { handleInputValueChange(key, e.target.value) }} - maxLength={max_length || DEFAULT_VALUE_MAX_LEN} - /> - )} + !userInputFieldCollapse && ( + <> + { + promptVariables.length > 0 + ? ( +
+ {promptVariables.map(({ key, name, type, options, max_length, required }) => ( +
+
{name || key}
+ {type === 'select' + ? ( + { handleInputValueChange(key, e.target.value) }} + maxLength={max_length || DEFAULT_VALUE_MAX_LEN} + /> + )} -
- ))} -
- ) - : ( -
{t('appDebug.inputs.noVar')}
- ) +
+ ))} +
+ ) + : ( +
{t('appDebug.inputs.noVar')}
+ ) + } + + ) }
{ appType === AppType.completion && (
-
+
{t('appDebug.inputs.queryTitle')}