feat: code generate use prompt editor
parent
635e92d762
commit
ba8129cf73
@ -0,0 +1,48 @@
|
|||||||
|
'use client'
|
||||||
|
import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general'
|
||||||
|
import { useBoolean } from 'ahooks'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React from 'react'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
import Textarea from '@/app/components/base/textarea'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
const i18nPrefix = 'appDebug.generate'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value: string
|
||||||
|
onChange: (value: string) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const IdeaOutput: FC<Props> = ({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const [isFoldIdeaOutput, {
|
||||||
|
toggle: toggleFoldIdeaOutput,
|
||||||
|
}] = useBoolean(true)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='mt-4 text-[0px]'>
|
||||||
|
<div
|
||||||
|
className='mb-1.5 flex cursor-pointer items-center text-sm font-medium leading-5 text-text-primary'
|
||||||
|
onClick={toggleFoldIdeaOutput}
|
||||||
|
>
|
||||||
|
<div className='system-sm-semibold-uppercase mr-1 text-text-secondary'>{t(`${i18nPrefix}.ideaOutput`)}</div>
|
||||||
|
<div className='system-xs-regular text-text-tertiary'>({t(`${i18nPrefix}.optional`)})</div>
|
||||||
|
<ArrowDownRoundFill className={cn('size text-text-quaternary', isFoldIdeaOutput && 'relative top-[1px] rotate-[-90deg]')} />
|
||||||
|
</div>
|
||||||
|
{!isFoldIdeaOutput && (
|
||||||
|
<Textarea
|
||||||
|
className="h-[80px]"
|
||||||
|
placeholder={t(`${i18nPrefix}.ideaOutputPlaceholder`)}
|
||||||
|
value={value}
|
||||||
|
onChange={e => onChange(e.target.value)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(IdeaOutput)
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React, { useCallback } from 'react'
|
||||||
|
import type { GeneratorType } from './types'
|
||||||
|
import type { Var } from '@/app/components/workflow/types'
|
||||||
|
import { VarType } from '@/app/components/workflow/types'
|
||||||
|
import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list'
|
||||||
|
import InstructionEditor from './instruction-editor'
|
||||||
|
import { useWorkflowVariableType } from '@/app/components/workflow/hooks'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
nodeId: string
|
||||||
|
value: string
|
||||||
|
onChange: (text: string) => void
|
||||||
|
generatorType: GeneratorType
|
||||||
|
}
|
||||||
|
|
||||||
|
const InstructionEditorInWorkflow: FC<Props> = ({
|
||||||
|
nodeId,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
generatorType,
|
||||||
|
}) => {
|
||||||
|
const filterVar = useCallback((payload: Var) => {
|
||||||
|
return payload.type !== VarType.file && payload.type !== VarType.arrayFile
|
||||||
|
}, [])
|
||||||
|
const {
|
||||||
|
availableVars,
|
||||||
|
availableNodes,
|
||||||
|
} = useAvailableVarList(nodeId, {
|
||||||
|
onlyLeafNodeVar: false,
|
||||||
|
filterVar,
|
||||||
|
})
|
||||||
|
const getVarType = useWorkflowVariableType()
|
||||||
|
|
||||||
|
console.log(availableVars)
|
||||||
|
return (
|
||||||
|
<InstructionEditor
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
generatorType={generatorType}
|
||||||
|
availableVars={availableVars}
|
||||||
|
availableNodes={availableNodes}
|
||||||
|
getVarType={getVarType}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(InstructionEditorInWorkflow)
|
||||||
Loading…
Reference in New Issue