| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import type { FC } from 'react' | 
					
						
							| 
									
										
										
										
											2025-03-20 10:55:37 +08:00
										 |  |  | import React, { useCallback } from 'react' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							|  |  |  | import MemoryConfig from '../_base/components/memory-config' | 
					
						
							|  |  |  | import VarReferencePicker from '../_base/components/variable/var-reference-picker' | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  | import ConfigVision from '../_base/components/config-vision' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import useConfig from './use-config' | 
					
						
							| 
									
										
										
										
											2025-03-03 13:29:59 +08:00
										 |  |  | import { findVariableWhenOnLLMVision } from '../utils' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import type { LLMNodeType } from './types' | 
					
						
							|  |  |  | import ConfigPrompt from './components/config-prompt' | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  | import VarList from '@/app/components/workflow/nodes/_base/components/variable/var-list' | 
					
						
							|  |  |  | import AddButton2 from '@/app/components/base/button/add-button' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import Field from '@/app/components/workflow/nodes/_base/components/field' | 
					
						
							|  |  |  | import Split from '@/app/components/workflow/nodes/_base/components/split' | 
					
						
							|  |  |  | import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' | 
					
						
							|  |  |  | import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' | 
					
						
							|  |  |  | import { InputVarType, type NodePanelProps } from '@/app/components/workflow/types' | 
					
						
							|  |  |  | import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form' | 
					
						
							|  |  |  | import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' | 
					
						
							|  |  |  | import ResultPanel from '@/app/components/workflow/run/result-panel' | 
					
						
							| 
									
										
										
										
											2024-08-26 13:00:02 +08:00
										 |  |  | import Tooltip from '@/app/components/base/tooltip' | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor' | 
					
						
							| 
									
										
										
										
											2025-04-18 16:53:43 +08:00
										 |  |  | import StructureOutput from './components/structure-output' | 
					
						
							|  |  |  | import Switch from '@/app/components/base/switch' | 
					
						
							|  |  |  | import { RiAlertFill, RiQuestionLine } from '@remixicon/react' | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  | const i18nPrefix = 'workflow.nodes.llm' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const Panel: FC<NodePanelProps<LLMNodeType>> = ({ | 
					
						
							|  |  |  |   id, | 
					
						
							|  |  |  |   data, | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   const { t } = useTranslation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     readOnly, | 
					
						
							|  |  |  |     inputs, | 
					
						
							|  |  |  |     isChatModel, | 
					
						
							|  |  |  |     isChatMode, | 
					
						
							|  |  |  |     isCompletionModel, | 
					
						
							|  |  |  |     shouldShowContextTip, | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |     isVisionModel, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     handleModelChanged, | 
					
						
							|  |  |  |     hasSetBlockStatus, | 
					
						
							|  |  |  |     handleCompletionParamsChange, | 
					
						
							|  |  |  |     handleContextVarChange, | 
					
						
							|  |  |  |     filterInputVar, | 
					
						
							|  |  |  |     filterVar, | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  |     availableVars, | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |     availableNodesWithParent, | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  |     isShowVars, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     handlePromptChange, | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  |     handleAddEmptyVariable, | 
					
						
							|  |  |  |     handleAddVariable, | 
					
						
							|  |  |  |     handleVarListChange, | 
					
						
							|  |  |  |     handleVarNameChange, | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  |     handleSyeQueryChange, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     handleMemoryChange, | 
					
						
							| 
									
										
										
										
											2024-04-09 15:07:43 +08:00
										 |  |  |     handleVisionResolutionEnabledChange, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     handleVisionResolutionChange, | 
					
						
							|  |  |  |     isShowSingleRun, | 
					
						
							|  |  |  |     hideSingleRun, | 
					
						
							|  |  |  |     inputVarValues, | 
					
						
							|  |  |  |     setInputVarValues, | 
					
						
							|  |  |  |     visionFiles, | 
					
						
							|  |  |  |     setVisionFiles, | 
					
						
							|  |  |  |     contexts, | 
					
						
							|  |  |  |     setContexts, | 
					
						
							|  |  |  |     runningStatus, | 
					
						
							| 
									
										
										
										
											2025-04-18 16:53:43 +08:00
										 |  |  |     isModelSupportStructuredOutput, | 
					
						
							|  |  |  |     structuredOutputCollapsed, | 
					
						
							|  |  |  |     setStructuredOutputCollapsed, | 
					
						
							|  |  |  |     handleStructureOutputEnableChange, | 
					
						
							|  |  |  |     handleStructureOutputChange, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |     handleRun, | 
					
						
							|  |  |  |     handleStop, | 
					
						
							|  |  |  |     varInputs, | 
					
						
							|  |  |  |     runResult, | 
					
						
							| 
									
										
										
										
											2024-11-22 16:30:22 +08:00
										 |  |  |     filterJinjia2InputVar, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   } = useConfig(id, data) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const model = inputs.model | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const singleRunForms = (() => { | 
					
						
							|  |  |  |     const forms: FormProps[] = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (varInputs.length > 0) { | 
					
						
							|  |  |  |       forms.push( | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           label: t(`${i18nPrefix}.singleRun.variable`)!, | 
					
						
							|  |  |  |           inputs: varInputs, | 
					
						
							|  |  |  |           values: inputVarValues, | 
					
						
							|  |  |  |           onChange: setInputVarValues, | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (inputs.context?.variable_selector && inputs.context?.variable_selector.length > 0) { | 
					
						
							|  |  |  |       forms.push( | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           label: t(`${i18nPrefix}.context`)!, | 
					
						
							|  |  |  |           inputs: [{ | 
					
						
							|  |  |  |             label: '', | 
					
						
							|  |  |  |             variable: '#context#', | 
					
						
							|  |  |  |             type: InputVarType.contexts, | 
					
						
							|  |  |  |             required: false, | 
					
						
							|  |  |  |           }], | 
					
						
							|  |  |  |           values: { '#context#': contexts }, | 
					
						
							| 
									
										
										
										
											2025-04-14 16:06:10 +08:00
										 |  |  |           onChange: keyValue => setContexts(keyValue['#context#']), | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         }, | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-16 08:54:18 +08:00
										 |  |  |     if (isVisionModel && data.vision?.enabled && data.vision?.configs?.variable_selector) { | 
					
						
							| 
									
										
										
										
											2025-03-03 13:29:59 +08:00
										 |  |  |       const currentVariable = findVariableWhenOnLLMVision(data.vision.configs.variable_selector, availableVars) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       forms.push( | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           label: t(`${i18nPrefix}.vision`)!, | 
					
						
							|  |  |  |           inputs: [{ | 
					
						
							| 
									
										
										
										
											2025-03-03 13:29:59 +08:00
										 |  |  |             label: currentVariable?.variable as any, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             variable: '#files#', | 
					
						
							| 
									
										
										
										
											2025-03-03 13:29:59 +08:00
										 |  |  |             type: currentVariable?.formType as any, | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             required: false, | 
					
						
							|  |  |  |           }], | 
					
						
							|  |  |  |           values: { '#files#': visionFiles }, | 
					
						
							|  |  |  |           onChange: keyValue => setVisionFiles((keyValue as any)['#files#']), | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return forms | 
					
						
							|  |  |  |   })() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-19 17:48:18 +08:00
										 |  |  |   const handleModelChange = useCallback((model: { | 
					
						
							|  |  |  |     provider: string | 
					
						
							|  |  |  |     modelId: string | 
					
						
							|  |  |  |     mode?: string | 
					
						
							|  |  |  |   }) => { | 
					
						
							|  |  |  |     handleCompletionParamsChange({}) | 
					
						
							|  |  |  |     handleModelChanged(model) | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     // eslint-disable-next-line react-hooks/exhaustive-deps
 | 
					
						
							| 
									
										
										
										
											2025-03-19 17:48:18 +08:00
										 |  |  |   }, []) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <div className='mt-2'> | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |       <div className='space-y-4 px-4 pb-4'> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         <Field | 
					
						
							|  |  |  |           title={t(`${i18nPrefix}.model`)} | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           <ModelParameterModal | 
					
						
							|  |  |  |             popupClassName='!w-[387px]' | 
					
						
							|  |  |  |             isInWorkflow | 
					
						
							|  |  |  |             isAdvancedMode={true} | 
					
						
							|  |  |  |             mode={model?.mode} | 
					
						
							|  |  |  |             provider={model?.provider} | 
					
						
							|  |  |  |             completionParams={model?.completion_params} | 
					
						
							|  |  |  |             modelId={model?.name} | 
					
						
							| 
									
										
										
										
											2025-03-19 17:48:18 +08:00
										 |  |  |             setModel={handleModelChange} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             onCompletionParamsChange={handleCompletionParamsChange} | 
					
						
							|  |  |  |             hideDebugWithMultipleModel | 
					
						
							|  |  |  |             debugWithMultipleModel={false} | 
					
						
							|  |  |  |             readonly={readOnly} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </Field> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         {/* knowledge */} | 
					
						
							|  |  |  |         <Field | 
					
						
							|  |  |  |           title={t(`${i18nPrefix}.context`)} | 
					
						
							|  |  |  |           tooltip={t(`${i18nPrefix}.contextTooltip`)!} | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           <> | 
					
						
							|  |  |  |             <VarReferencePicker | 
					
						
							|  |  |  |               readonly={readOnly} | 
					
						
							|  |  |  |               nodeId={id} | 
					
						
							|  |  |  |               isShowNodeName | 
					
						
							|  |  |  |               value={inputs.context?.variable_selector || []} | 
					
						
							|  |  |  |               onChange={handleContextVarChange} | 
					
						
							|  |  |  |               filterVar={filterVar} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |             {shouldShowContextTip && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |               <div className='text-xs font-normal leading-[18px] text-[#DC6803]'>{t(`${i18nPrefix}.notSetContextInPromptTip`)}</div> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             )} | 
					
						
							|  |  |  |           </> | 
					
						
							|  |  |  |         </Field> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         {/* Prompt */} | 
					
						
							|  |  |  |         {model.name && ( | 
					
						
							|  |  |  |           <ConfigPrompt | 
					
						
							|  |  |  |             readOnly={readOnly} | 
					
						
							|  |  |  |             nodeId={id} | 
					
						
							|  |  |  |             filterVar={filterInputVar} | 
					
						
							|  |  |  |             isChatModel={isChatModel} | 
					
						
							|  |  |  |             isChatApp={isChatMode} | 
					
						
							|  |  |  |             isShowContext | 
					
						
							|  |  |  |             payload={inputs.prompt_template} | 
					
						
							|  |  |  |             onChange={handlePromptChange} | 
					
						
							|  |  |  |             hasSetBlockStatus={hasSetBlockStatus} | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  |             varList={inputs.prompt_config?.jinja2_variables || []} | 
					
						
							|  |  |  |             handleAddVariable={handleAddVariable} | 
					
						
							| 
									
										
										
										
											2024-07-23 19:51:38 +08:00
										 |  |  |             modelConfig={model} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |           /> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  |         {isShowVars && ( | 
					
						
							|  |  |  |           <Field | 
					
						
							|  |  |  |             title={t('workflow.nodes.templateTransform.inputVars')} | 
					
						
							|  |  |  |             operations={ | 
					
						
							|  |  |  |               !readOnly ? <AddButton2 onClick={handleAddEmptyVariable} /> : undefined | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <VarList | 
					
						
							|  |  |  |               nodeId={id} | 
					
						
							|  |  |  |               readonly={readOnly} | 
					
						
							|  |  |  |               list={inputs.prompt_config?.jinja2_variables || []} | 
					
						
							|  |  |  |               onChange={handleVarListChange} | 
					
						
							|  |  |  |               onVarNameChange={handleVarNameChange} | 
					
						
							| 
									
										
										
										
											2024-11-22 16:30:22 +08:00
										 |  |  |               filterVar={filterJinjia2InputVar} | 
					
						
							|  |  |  |               isSupportFileVar={false} | 
					
						
							| 
									
										
										
										
											2024-05-10 18:14:05 +08:00
										 |  |  |             /> | 
					
						
							|  |  |  |           </Field> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         {/* Memory put place examples. */} | 
					
						
							|  |  |  |         {isChatMode && isChatModel && !!inputs.memory && ( | 
					
						
							|  |  |  |           <div className='mt-4'> | 
					
						
							| 
									
										
										
										
											2025-04-10 17:15:48 +08:00
										 |  |  |             <div className='flex h-8 items-center justify-between rounded-lg bg-components-input-bg-normal pl-3 pr-2'> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |               <div className='flex items-center space-x-1'> | 
					
						
							| 
									
										
										
										
											2025-04-10 17:15:48 +08:00
										 |  |  |                 <div className='text-xs font-semibold uppercase text-text-secondary'>{t('workflow.nodes.common.memories.title')}</div> | 
					
						
							| 
									
										
										
										
											2024-08-26 13:00:02 +08:00
										 |  |  |                 <Tooltip | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |                   popupContent={t('workflow.nodes.common.memories.tip')} | 
					
						
							| 
									
										
										
										
											2024-08-26 13:00:02 +08:00
										 |  |  |                   triggerClassName='w-4 h-4' | 
					
						
							|  |  |  |                 /> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |               </div> | 
					
						
							| 
									
										
										
										
											2025-04-10 17:15:48 +08:00
										 |  |  |               <div className='flex h-[18px] items-center rounded-[5px] border border-divider-deep bg-components-badge-bg-dimm px-1 text-xs font-semibold uppercase text-text-tertiary'>{t('workflow.nodes.common.memories.builtIn')}</div> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             </div> | 
					
						
							|  |  |  |             {/* Readonly User Query */} | 
					
						
							|  |  |  |             <div className='mt-4'> | 
					
						
							|  |  |  |               <Editor | 
					
						
							|  |  |  |                 title={<div className='flex items-center space-x-1'> | 
					
						
							| 
									
										
										
										
											2025-04-10 17:15:48 +08:00
										 |  |  |                   <div className='text-xs font-semibold uppercase text-text-secondary'>user</div> | 
					
						
							| 
									
										
										
										
											2024-08-26 13:00:02 +08:00
										 |  |  |                   <Tooltip | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |                     popupContent={ | 
					
						
							|  |  |  |                       <div className='max-w-[180px]'>{t('workflow.nodes.llm.roleDescription.user')}</div> | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2024-08-26 13:00:02 +08:00
										 |  |  |                     triggerClassName='w-4 h-4' | 
					
						
							|  |  |  |                   /> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |                 </div>} | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  |                 value={inputs.memory.query_prompt_template || '{{#sys.query#}}'} | 
					
						
							|  |  |  |                 onChange={handleSyeQueryChange} | 
					
						
							|  |  |  |                 readOnly={readOnly} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |                 isShowContext={false} | 
					
						
							|  |  |  |                 isChatApp | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  |                 isChatModel | 
					
						
							|  |  |  |                 hasSetBlockStatus={hasSetBlockStatus} | 
					
						
							|  |  |  |                 nodesOutputVars={availableVars} | 
					
						
							| 
									
										
										
										
											2024-05-27 21:57:08 +08:00
										 |  |  |                 availableNodes={availableNodesWithParent} | 
					
						
							| 
									
										
										
										
											2024-11-22 16:30:22 +08:00
										 |  |  |                 isSupportFileVar | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |               /> | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |               {inputs.memory.query_prompt_template && !inputs.memory.query_prompt_template.includes('{{#sys.query#}}') && ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |                 <div className='text-xs font-normal leading-[18px] text-[#DC6803]'>{t(`${i18nPrefix}.sysQueryInUser`)}</div> | 
					
						
							| 
									
										
										
										
											2024-04-25 18:01:53 +08:00
										 |  |  |               )} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |             </div> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         {/* Memory */} | 
					
						
							|  |  |  |         {isChatMode && ( | 
					
						
							|  |  |  |           <> | 
					
						
							|  |  |  |             <Split /> | 
					
						
							|  |  |  |             <MemoryConfig | 
					
						
							|  |  |  |               readonly={readOnly} | 
					
						
							|  |  |  |               config={{ data: inputs.memory }} | 
					
						
							|  |  |  |               onChange={handleMemoryChange} | 
					
						
							|  |  |  |               canSetRoleName={isCompletionModel} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           </> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         {/* Vision: GPT4-vision and so on */} | 
					
						
							| 
									
										
										
										
											2024-10-21 10:32:37 +08:00
										 |  |  |         <ConfigVision | 
					
						
							|  |  |  |           nodeId={id} | 
					
						
							|  |  |  |           readOnly={readOnly} | 
					
						
							|  |  |  |           isVisionModel={isVisionModel} | 
					
						
							|  |  |  |           enabled={inputs.vision?.enabled} | 
					
						
							|  |  |  |           onEnabledChange={handleVisionResolutionEnabledChange} | 
					
						
							|  |  |  |           config={inputs.vision?.configs} | 
					
						
							|  |  |  |           onConfigChange={handleVisionResolutionChange} | 
					
						
							|  |  |  |         /> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |       <Split /> | 
					
						
							| 
									
										
										
										
											2025-04-18 16:53:43 +08:00
										 |  |  |       <OutputVars | 
					
						
							|  |  |  |         collapsed={structuredOutputCollapsed} | 
					
						
							|  |  |  |         onCollapse={setStructuredOutputCollapsed} | 
					
						
							|  |  |  |         operations={ | 
					
						
							|  |  |  |           <div className='mr-4 flex shrink-0 items-center'> | 
					
						
							|  |  |  |             {!isModelSupportStructuredOutput && ( | 
					
						
							|  |  |  |               <Tooltip noDecoration popupContent={ | 
					
						
							|  |  |  |                 <div className='w-[232px] rounded-xl border-[0.5px] border-components-panel-border bg-components-tooltip-bg px-4 py-3.5 shadow-lg backdrop-blur-[5px]'> | 
					
						
							|  |  |  |                   <div className='title-xs-semi-bold text-text-primary'>{t('app.structOutput.modelNotSupported')}</div> | 
					
						
							|  |  |  |                   <div className='body-xs-regular mt-1 text-text-secondary'>{t('app.structOutput.modelNotSupportedTip')}</div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |               }> | 
					
						
							|  |  |  |                 <div> | 
					
						
							|  |  |  |                   <RiAlertFill className='mr-1 size-4 text-text-warning-secondary' /> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |               </Tooltip> | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |             <div className='system-xs-medium-uppercase mr-0.5 text-text-tertiary'>{t('app.structOutput.structured')}</div> | 
					
						
							|  |  |  |             <Tooltip popupContent={ | 
					
						
							|  |  |  |               <div className='max-w-[150px]'>{t('app.structOutput.structuredTip')}</div> | 
					
						
							|  |  |  |             }> | 
					
						
							|  |  |  |               <div> | 
					
						
							|  |  |  |                 <RiQuestionLine className='size-3.5 text-text-quaternary' /> | 
					
						
							|  |  |  |               </div> | 
					
						
							|  |  |  |             </Tooltip> | 
					
						
							|  |  |  |             <Switch | 
					
						
							|  |  |  |               className='ml-2' | 
					
						
							|  |  |  |               defaultValue={!!inputs.structured_output_enabled} | 
					
						
							|  |  |  |               onChange={handleStructureOutputEnableChange} | 
					
						
							|  |  |  |               size='md' | 
					
						
							|  |  |  |               disabled={readOnly} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2024-12-11 14:21:38 +08:00
										 |  |  |         <> | 
					
						
							|  |  |  |           <VarItem | 
					
						
							|  |  |  |             name='text' | 
					
						
							|  |  |  |             type='string' | 
					
						
							|  |  |  |             description={t(`${i18nPrefix}.outputVars.output`)} | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2025-04-18 16:53:43 +08:00
										 |  |  |           {inputs.structured_output_enabled && ( | 
					
						
							|  |  |  |             <> | 
					
						
							|  |  |  |               <Split className='mt-3' /> | 
					
						
							|  |  |  |               <StructureOutput | 
					
						
							|  |  |  |                 className='mt-4' | 
					
						
							|  |  |  |                 value={inputs.structured_output} | 
					
						
							|  |  |  |                 onChange={handleStructureOutputChange} | 
					
						
							|  |  |  |               /> | 
					
						
							|  |  |  |             </> | 
					
						
							|  |  |  |           )} | 
					
						
							| 
									
										
										
										
											2024-12-11 14:21:38 +08:00
										 |  |  |         </> | 
					
						
							|  |  |  |       </OutputVars> | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |       {isShowSingleRun && ( | 
					
						
							|  |  |  |         <BeforeRunForm | 
					
						
							|  |  |  |           nodeName={inputs.title} | 
					
						
							| 
									
										
										
										
											2024-12-20 15:44:37 +08:00
										 |  |  |           nodeType={inputs.type} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |           onHide={hideSingleRun} | 
					
						
							|  |  |  |           forms={singleRunForms} | 
					
						
							|  |  |  |           runningStatus={runningStatus} | 
					
						
							|  |  |  |           onRun={handleRun} | 
					
						
							|  |  |  |           onStop={handleStop} | 
					
						
							| 
									
										
										
										
											2025-02-17 17:05:13 +08:00
										 |  |  |           result={<ResultPanel {...runResult} showSteps={false} />} | 
					
						
							| 
									
										
										
										
											2024-04-08 18:51:46 +08:00
										 |  |  |         /> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default React.memo(Panel) |