feat: user message support generate prompt (#25689)

This commit is contained in:
Joel 2025-09-15 10:17:19 +08:00 • committed by GitHub
commit 9bb7bcf52e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 3 deletions

View file

@ -50,6 +50,7 @@ export type IGetAutomaticResProps = {
onFinished: (res: GenRes) => void onFinished: (res: GenRes) => void
flowId?: string flowId?: string
nodeId?: string nodeId?: string
editorId?: string
currentPrompt?: string currentPrompt?: string
isBasicMode?: boolean isBasicMode?: boolean
} }
@ -76,6 +77,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
onClose, onClose,
flowId, flowId,
nodeId, nodeId,
editorId,
currentPrompt, currentPrompt,
isBasicMode, isBasicMode,
onFinished, 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 instruction = instructionFromSessionStorage || ''
const [ideaOutput, setIdeaOutput] = useState<string>('') const [ideaOutput, setIdeaOutput] = useState<string>('')
@ -166,7 +169,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
return true return true
} }
const [isLoading, { setTrue: setLoadingTrue, setFalse: setLoadingFalse }] = useBoolean(false) 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({ const { addVersion, current, currentVersionIndex, setCurrentVersionIndex, versions } = useGenData({
storageKey, storageKey,
}) })

View file

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

View file

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

View file

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