fix: can set the template value

feat/enchance-prompt-and-code-fe
Joel 7 months ago
parent 525e64467d
commit 4e27d2c35f

@ -134,10 +134,12 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
const [instruction, setInstruction] = useState<string>('')
const [ideaOutput, setIdeaOutput] = useState<string>('')
const [editorKey, setEditorKey] = useState(`${flowId}-0`)
const handleChooseTemplate = useCallback((key: string) => {
return () => {
const template = t(`appDebug.generate.template.${key}.instruction`)
setInstruction(template)
setEditorKey(`${flowId}-${Date.now()}`)
}
}, [t])
const isValid = () => {
@ -318,6 +320,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
<div className='system-sm-semibold-uppercase mb-1.5 text-text-secondary'>{t('appDebug.generate.instruction')}</div>
{isBasicMode ? (
<InstructionEditorInBasic
editorKey={editorKey}
generatorType={GeneratorType.prompt}
value={instruction}
onChange={setInstruction}
@ -326,6 +329,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
/>
) : (
<InstructionEditorInWorkflow
editorKey={editorKey}
generatorType={GeneratorType.prompt}
value={instruction}
onChange={setInstruction}

@ -11,6 +11,7 @@ import { useWorkflowVariableType } from '@/app/components/workflow/hooks'
type Props = {
nodeId: string
value: string
editorKey: string
onChange: (text: string) => void
generatorType: GeneratorType
}
@ -18,6 +19,7 @@ type Props = {
const InstructionEditorInWorkflow: FC<Props> = ({
nodeId,
value,
editorKey,
onChange,
generatorType,
}) => {
@ -37,6 +39,7 @@ const InstructionEditorInWorkflow: FC<Props> = ({
<InstructionEditor
value={value}
onChange={onChange}
editorKey={editorKey}
generatorType={generatorType}
availableVars={availableVars}
availableNodes={availableNodes}

@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next'
import { Type } from '@/app/components/workflow/nodes/llm/types'
type Props = {
editorKey: string
value: string
onChange: (text: string) => void
generatorType: GeneratorType
@ -24,6 +25,7 @@ type Props = {
const i18nPrefix = 'appDebug.generate'
const InstructionEditor: FC<Props> = ({
editorKey,
generatorType,
value,
onChange,
@ -50,7 +52,7 @@ const InstructionEditor: FC<Props> = ({
<div>
<PromptEditor
wrapperClassName='border !border-components-input-bg-normal bg-components-input-bg-normal hover:!border-components-input-bg-hover rounded-[10px] px-4 pt-3'
// key={controlPromptEditorRerenderKey}
key={editorKey}
placeholder={placeholder}
placeholderClassName='px-4 pt-3'
className={cn('min-h-[240px] ')}

@ -75,7 +75,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
const [ideaOutput, setIdeaOutput] = useState<string>('')
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false)
const storageKey = `${flowId}-${nodeId}}`
const storageKey = `${flowId}-${nodeId}`
const { addVersion, current, currentVersionIndex, setCurrentVersionIndex, versions } = useGenData({
storageKey,
})

Loading…
Cancel
Save