fix: can overwrite the gened prompt

feat/enchance-prompt-and-code-fe
Joel 10 months ago
parent 0066cfe4ed
commit 91b0672001

@ -1,7 +1,6 @@
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import React, { useCallback, useEffect, useState } from 'react' import React, { useCallback } from 'react'
import { uniqueId } from 'lodash-es'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import type { ModelConfig, PromptItem, Variable } from '../../../types' import type { ModelConfig, PromptItem, Variable } from '../../../types'
import { EditionType } from '../../../types' import { EditionType } from '../../../types'
@ -14,6 +13,7 @@ import { PromptRole } from '@/models/debug'
const i18nPrefix = 'workflow.nodes.llm' const i18nPrefix = 'workflow.nodes.llm'
type Props = { type Props = {
instanceId: string
className?: string className?: string
headerClassName?: string headerClassName?: string
canNotChooseSystemRole?: boolean canNotChooseSystemRole?: boolean
@ -59,6 +59,7 @@ const roleOptions = [
const roleOptionsWithoutSystemRole = roleOptions.filter(item => item.value !== PromptRole.system) const roleOptionsWithoutSystemRole = roleOptions.filter(item => item.value !== PromptRole.system)
const ConfigPromptItem: FC<Props> = ({ const ConfigPromptItem: FC<Props> = ({
instanceId,
className, className,
headerClassName, headerClassName,
canNotChooseSystemRole, canNotChooseSystemRole,
@ -86,10 +87,6 @@ const ConfigPromptItem: FC<Props> = ({
const { const {
setControlPromptEditorRerenderKey, setControlPromptEditorRerenderKey,
} = workflowStore.getState() } = workflowStore.getState()
const [instanceId, setInstanceId] = useState(uniqueId())
useEffect(() => {
setInstanceId(`${id}-${uniqueId()}`)
}, [id])
const handleGenerated = useCallback((prompt: string) => { const handleGenerated = useCallback((prompt: string) => {
onPromptChange(prompt) onPromptChange(prompt)

@ -182,6 +182,7 @@ const ConfigPrompt: FC<Props> = ({
<div key={item.id || index} className='group relative'> <div key={item.id || index} className='group relative'>
{canDrag && <DragHandle className='absolute left-[-14px] top-2 hidden h-3.5 w-3.5 text-text-quaternary group-hover:block' />} {canDrag && <DragHandle className='absolute left-[-14px] top-2 hidden h-3.5 w-3.5 text-text-quaternary group-hover:block' />}
<ConfigPromptItem <ConfigPromptItem
instanceId={item.role === PromptRole.system ? `${nodeId}-chat-workflow-llm-prompt-editor` : `${nodeId}-chat-workflow-llm-prompt-editor-${index}`}
className={cn(canDrag && 'handle')} className={cn(canDrag && 'handle')}
headerClassName={cn(canDrag && 'cursor-grab')} headerClassName={cn(canDrag && 'cursor-grab')}
canNotChooseSystemRole={!canChooseSystemRole} canNotChooseSystemRole={!canChooseSystemRole}

Loading…
Cancel
Save