chore: use node specify llm to auto generate prompt (#6525)
This commit is contained in:
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import { BlockEnum, EditionType } from '../../../../types'
|
||||
import type {
|
||||
ModelConfig,
|
||||
Node,
|
||||
NodeOutPutVar,
|
||||
Variable,
|
||||
@@ -58,6 +59,7 @@ type Props = {
|
||||
availableNodes?: Node[]
|
||||
isSupportPromptGenerator?: boolean
|
||||
onGenerated?: (prompt: string) => void
|
||||
modelConfig?: ModelConfig
|
||||
// for jinja
|
||||
isSupportJinja?: boolean
|
||||
editionType?: EditionType
|
||||
@@ -90,6 +92,7 @@ const Editor: FC<Props> = ({
|
||||
varList = [],
|
||||
handleAddVariable,
|
||||
onGenerated,
|
||||
modelConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { eventEmitter } = useEventEmitterContextContext()
|
||||
@@ -130,7 +133,7 @@ const Editor: FC<Props> = ({
|
||||
<div className='flex items-center'>
|
||||
<div className='leading-[18px] text-xs font-medium text-gray-500'>{value?.length || 0}</div>
|
||||
{isSupportPromptGenerator && (
|
||||
<PromptGeneratorBtn className='ml-[5px]' onGenerated={onGenerated} />
|
||||
<PromptGeneratorBtn className='ml-[5px]' onGenerated={onGenerated} modelConfig={modelConfig} />
|
||||
)}
|
||||
|
||||
<div className='w-px h-3 ml-2 mr-2 bg-gray-200'></div>
|
||||
|
@@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useState } from 'react'
|
||||
import { uniqueId } from 'lodash-es'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RiQuestionLine } from '@remixicon/react'
|
||||
import type { PromptItem, Variable } from '../../../types'
|
||||
import type { ModelConfig, PromptItem, Variable } from '../../../types'
|
||||
import { EditionType } from '../../../types'
|
||||
import { useWorkflowStore } from '../../../store'
|
||||
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
|
||||
@@ -38,6 +38,7 @@ type Props = {
|
||||
availableNodes: any
|
||||
varList: Variable[]
|
||||
handleAddVariable: (payload: any) => void
|
||||
modelConfig?: ModelConfig
|
||||
}
|
||||
|
||||
const roleOptions = [
|
||||
@@ -77,6 +78,7 @@ const ConfigPromptItem: FC<Props> = ({
|
||||
availableNodes,
|
||||
varList,
|
||||
handleAddVariable,
|
||||
modelConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const workflowStore = useWorkflowStore()
|
||||
@@ -138,6 +140,7 @@ const ConfigPromptItem: FC<Props> = ({
|
||||
availableNodes={availableNodes}
|
||||
isSupportPromptGenerator={payload.role === PromptRole.system}
|
||||
onGenerated={handleGenerated}
|
||||
modelConfig={modelConfig}
|
||||
isSupportJinja
|
||||
editionType={payload.edition_type}
|
||||
onEditionTypeChange={onEditionTypeChange}
|
||||
|
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import produce from 'immer'
|
||||
import { ReactSortable } from 'react-sortablejs'
|
||||
import { v4 as uuid4 } from 'uuid'
|
||||
import type { PromptItem, ValueSelector, Var, Variable } from '../../../types'
|
||||
import type { ModelConfig, PromptItem, ValueSelector, Var, Variable } from '../../../types'
|
||||
import { EditionType, PromptRole } from '../../../types'
|
||||
import useAvailableVarList from '../../_base/hooks/use-available-var-list'
|
||||
import { useWorkflowStore } from '../../../store'
|
||||
@@ -33,6 +33,7 @@ type Props = {
|
||||
}
|
||||
varList?: Variable[]
|
||||
handleAddVariable: (payload: any) => void
|
||||
modelConfig: ModelConfig
|
||||
}
|
||||
|
||||
const ConfigPrompt: FC<Props> = ({
|
||||
@@ -47,6 +48,7 @@ const ConfigPrompt: FC<Props> = ({
|
||||
hasSetBlockStatus,
|
||||
varList = [],
|
||||
handleAddVariable,
|
||||
modelConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const workflowStore = useWorkflowStore()
|
||||
@@ -199,6 +201,7 @@ const ConfigPrompt: FC<Props> = ({
|
||||
availableNodes={availableNodesWithParent}
|
||||
varList={varList}
|
||||
handleAddVariable={handleAddVariable}
|
||||
modelConfig={modelConfig}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
@@ -234,6 +237,7 @@ const ConfigPrompt: FC<Props> = ({
|
||||
onEditionTypeChange={handleCompletionEditionTypeChange}
|
||||
handleAddVariable={handleAddVariable}
|
||||
onGenerated={handleGenerated}
|
||||
modelConfig={modelConfig}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
@@ -7,14 +7,19 @@ import { Generator } from '@/app/components/base/icons/src/vender/other'
|
||||
import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'
|
||||
import { AppType } from '@/types/app'
|
||||
import type { AutomaticRes } from '@/service/debug'
|
||||
import type { ModelConfig } from '@/app/components/workflow/types'
|
||||
import type { Model } from '@/types/app'
|
||||
|
||||
type Props = {
|
||||
className?: string
|
||||
onGenerated?: (prompt: string) => void
|
||||
modelConfig?: ModelConfig
|
||||
}
|
||||
|
||||
const PromptGeneratorBtn: FC<Props> = ({
|
||||
className,
|
||||
onGenerated,
|
||||
modelConfig,
|
||||
}) => {
|
||||
const [showAutomatic, { setTrue: showAutomaticTrue, setFalse: showAutomaticFalse }] = useBoolean(false)
|
||||
const handleAutomaticRes = useCallback((res: AutomaticRes) => {
|
||||
@@ -32,6 +37,7 @@ const PromptGeneratorBtn: FC<Props> = ({
|
||||
isShow={showAutomatic}
|
||||
onClose={showAutomaticFalse}
|
||||
onFinished={handleAutomaticRes}
|
||||
model={modelConfig as Model}
|
||||
isInLLMNode
|
||||
/>
|
||||
)}
|
||||
|
@@ -178,6 +178,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
||||
hasSetBlockStatus={hasSetBlockStatus}
|
||||
varList={inputs.prompt_config?.jinja2_variables || []}
|
||||
handleAddVariable={handleAddVariable}
|
||||
modelConfig={model}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
Reference in New Issue
Block a user