Compare commits

...

2 Commits

Author SHA1 Message Date
Joel
b83999c17b fix: content would be used the same value 2025-09-11 17:07:48 +08:00
Joel
b23d97013a feat: user message support generate prompt 2025-09-10 10:36:55 +08:00
4 changed files with 13 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ export type IGetAutomaticResProps = {
onFinished: (res: GenRes) => void
flowId?: string
nodeId?: string
editorId?: string
currentPrompt?: string
isBasicMode?: boolean
}
@@ -76,6 +77,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
onClose,
flowId,
nodeId,
editorId,
currentPrompt,
isBasicMode,
onFinished,
@@ -132,7 +134,8 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
},
]
const [instructionFromSessionStorage, setInstruction] = useSessionStorageState<string>(`improve-instruction-${flowId}${isBasicMode ? '' : `-${nodeId}`}`)
// eslint-disable-next-line sonarjs/no-nested-template-literals, sonarjs/no-nested-conditional
const [instructionFromSessionStorage, setInstruction] = useSessionStorageState<string>(`improve-instruction-${flowId}${isBasicMode ? '' : `-${nodeId}${editorId ? `-${editorId}` : ''}`}`)
const instruction = instructionFromSessionStorage || ''
const [ideaOutput, setIdeaOutput] = useState<string>('')
@@ -166,7 +169,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
return true
}
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false)
const storageKey = `${flowId}${isBasicMode ? '' : `-${nodeId}`}`
const storageKey = `${flowId}${isBasicMode ? '' : `-${nodeId}${editorId ? `-${editorId}` : ''}`}`
const { addVersion, current, currentVersionIndex, setCurrentVersionIndex, versions } = useGenData({
storageKey,
})

View File

@@ -42,6 +42,7 @@ type Props = {
headerClassName?: string
instanceId?: string
nodeId?: string
editorId?: string
title: string | React.JSX.Element
value: string
onChange: (value: string) => void
@@ -85,6 +86,7 @@ const Editor: FC<Props> = ({
headerClassName,
instanceId,
nodeId,
editorId,
title,
value,
onChange,
@@ -163,6 +165,7 @@ const Editor: FC<Props> = ({
{isSupportPromptGenerator && (
<PromptGeneratorBtn
nodeId={nodeId!}
editorId={editorId}
className='ml-[5px]'
onGenerated={onGenerated}
modelConfig={modelConfig}

View File

@@ -136,7 +136,8 @@ const ConfigPromptItem: FC<Props> = ({
nodesOutputVars={availableVars}
availableNodes={availableNodes}
nodeId={nodeId}
isSupportPromptGenerator={payload.role === PromptRole.system}
editorId={id}
isSupportPromptGenerator
onGenerated={handleGenerated}
modelConfig={modelConfig}
isSupportJinja

View File

@@ -16,6 +16,7 @@ type Props = {
onGenerated?: (prompt: string) => void
modelConfig?: ModelConfig
nodeId: string
editorId?: string
currentPrompt?: string
}
@@ -23,6 +24,7 @@ const PromptGeneratorBtn: FC<Props> = ({
className,
onGenerated,
nodeId,
editorId,
currentPrompt,
}) => {
const [showAutomatic, { setTrue: showAutomaticTrue, setFalse: showAutomaticFalse }] = useBoolean(false)
@@ -46,6 +48,7 @@ const PromptGeneratorBtn: FC<Props> = ({
onFinished={handleAutomaticRes}
flowId={configsMap?.flowId || ''}
nodeId={nodeId}
editorId={editorId}
currentPrompt={currentPrompt}
/>
)}