support variable for number, select, file
This commit is contained in:
parent
6d36f2d239
commit
5d7400c8bb
@ -26,6 +26,7 @@ type Props = {
|
|||||||
supportVariables?: boolean
|
supportVariables?: boolean
|
||||||
nodeOutputVars: NodeOutPutVar[],
|
nodeOutputVars: NodeOutPutVar[],
|
||||||
availableNodes: Node[],
|
availableNodes: Node[],
|
||||||
|
nodeId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const MultipleToolSelector = ({
|
const MultipleToolSelector = ({
|
||||||
@ -40,6 +41,7 @@ const MultipleToolSelector = ({
|
|||||||
supportVariables,
|
supportVariables,
|
||||||
nodeOutputVars,
|
nodeOutputVars,
|
||||||
availableNodes,
|
availableNodes,
|
||||||
|
nodeId,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const enabledCount = value.filter(item => item.enabled).length
|
const enabledCount = value.filter(item => item.enabled).length
|
||||||
@ -130,6 +132,7 @@ const MultipleToolSelector = ({
|
|||||||
<>
|
<>
|
||||||
<ToolSelector
|
<ToolSelector
|
||||||
supportVariables={supportVariables}
|
supportVariables={supportVariables}
|
||||||
|
nodeId={nodeId}
|
||||||
nodeOutputVars={nodeOutputVars}
|
nodeOutputVars={nodeOutputVars}
|
||||||
availableNodes={availableNodes}
|
availableNodes={availableNodes}
|
||||||
scope={scope}
|
scope={scope}
|
||||||
@ -152,6 +155,7 @@ const MultipleToolSelector = ({
|
|||||||
<div className='mb-1' key={index}>
|
<div className='mb-1' key={index}>
|
||||||
<ToolSelector
|
<ToolSelector
|
||||||
supportVariables={supportVariables}
|
supportVariables={supportVariables}
|
||||||
|
nodeId={nodeId}
|
||||||
nodeOutputVars={nodeOutputVars}
|
nodeOutputVars={nodeOutputVars}
|
||||||
availableNodes={availableNodes}
|
availableNodes={availableNodes}
|
||||||
scope={scope}
|
scope={scope}
|
||||||
|
@ -73,6 +73,7 @@ type Props = {
|
|||||||
supportVariables?: boolean
|
supportVariables?: boolean
|
||||||
nodeOutputVars: NodeOutPutVar[],
|
nodeOutputVars: NodeOutPutVar[],
|
||||||
availableNodes: Node[],
|
availableNodes: Node[],
|
||||||
|
nodeId?: string,
|
||||||
}
|
}
|
||||||
const ToolSelector: FC<Props> = ({
|
const ToolSelector: FC<Props> = ({
|
||||||
value,
|
value,
|
||||||
@ -91,6 +92,7 @@ const ToolSelector: FC<Props> = ({
|
|||||||
onPanelShowStateChange,
|
onPanelShowStateChange,
|
||||||
nodeOutputVars,
|
nodeOutputVars,
|
||||||
availableNodes,
|
availableNodes,
|
||||||
|
nodeId = '',
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [isShow, onShowChange] = useState(false)
|
const [isShow, onShowChange] = useState(false)
|
||||||
@ -414,6 +416,7 @@ const ToolSelector: FC<Props> = ({
|
|||||||
schemas={paramsFormSchemas as any}
|
schemas={paramsFormSchemas as any}
|
||||||
nodeOutputVars={nodeOutputVars}
|
nodeOutputVars={nodeOutputVars}
|
||||||
availableNodes={availableNodes}
|
availableNodes={availableNodes}
|
||||||
|
nodeId={nodeId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -6,14 +6,20 @@ import {
|
|||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import Switch from '@/app/components/base/switch'
|
import Switch from '@/app/components/base/switch'
|
||||||
|
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
||||||
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
||||||
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
|
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
|
||||||
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
import type { Node } from 'reactflow'
|
import type { Node } from 'reactflow'
|
||||||
import type { NodeOutPutVar, ValueSelector } from '@/app/components/workflow/types'
|
import type {
|
||||||
|
NodeOutPutVar,
|
||||||
|
ValueSelector,
|
||||||
|
Var,
|
||||||
|
} from '@/app/components/workflow/types'
|
||||||
import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types'
|
import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types'
|
||||||
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
||||||
|
import { VarType } from '@/app/components/workflow/types'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -22,6 +28,7 @@ type Props = {
|
|||||||
schemas: any[]
|
schemas: any[]
|
||||||
nodeOutputVars: NodeOutPutVar[],
|
nodeOutputVars: NodeOutPutVar[],
|
||||||
availableNodes: Node[],
|
availableNodes: Node[],
|
||||||
|
nodeId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReasoningConfigForm: React.FC<Props> = ({
|
const ReasoningConfigForm: React.FC<Props> = ({
|
||||||
@ -30,17 +37,15 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
schemas,
|
schemas,
|
||||||
nodeOutputVars,
|
nodeOutputVars,
|
||||||
availableNodes,
|
availableNodes,
|
||||||
|
nodeId,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const handleFormChange = (key: string, val: string | boolean) => {
|
|
||||||
onChange({ ...value, [key]: val })
|
|
||||||
}
|
|
||||||
const handleAutomatic = (key: string, val: any) => {
|
const handleAutomatic = (key: string, val: any) => {
|
||||||
onChange({
|
onChange({
|
||||||
...value,
|
...value,
|
||||||
[key]: {
|
[key]: {
|
||||||
...value[key],
|
value: val ? null : value[key]?.value,
|
||||||
auto: val ? 1 : 0,
|
auto: val ? 1 : 0,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -60,13 +65,13 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
const handleNotMixedTypeChange = useCallback((variable: string) => {
|
const handleNotMixedTypeChange = useCallback((variable: string) => {
|
||||||
return (varValue: ValueSelector | string, varKindType: VarKindType) => {
|
return (varValue: ValueSelector | string, varKindType: VarKindType) => {
|
||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
const target = draft[variable]
|
const target = draft[variable].value
|
||||||
if (target) {
|
if (target) {
|
||||||
target.type = varKindType
|
target.type = varKindType
|
||||||
target.value = varValue
|
target.value = varValue
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
draft[variable] = {
|
draft[variable].value = {
|
||||||
type: varKindType,
|
type: varKindType,
|
||||||
value: varValue,
|
value: varValue,
|
||||||
}
|
}
|
||||||
@ -78,12 +83,12 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
const handleMixedTypeChange = useCallback((variable: string) => {
|
const handleMixedTypeChange = useCallback((variable: string) => {
|
||||||
return (itemValue: string) => {
|
return (itemValue: string) => {
|
||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
const target = draft[variable]
|
const target = draft[variable].value
|
||||||
if (target) {
|
if (target) {
|
||||||
target.value = itemValue
|
target.value = itemValue
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
draft[variable] = {
|
draft[variable].value = {
|
||||||
type: VarKindType.mixed,
|
type: VarKindType.mixed,
|
||||||
value: itemValue,
|
value: itemValue,
|
||||||
}
|
}
|
||||||
@ -95,7 +100,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
const handleFileChange = useCallback((variable: string) => {
|
const handleFileChange = useCallback((variable: string) => {
|
||||||
return (varValue: ValueSelector | string) => {
|
return (varValue: ValueSelector | string) => {
|
||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
draft[variable] = {
|
draft[variable].value = {
|
||||||
type: VarKindType.variable,
|
type: VarKindType.variable,
|
||||||
value: varValue,
|
value: varValue,
|
||||||
}
|
}
|
||||||
@ -103,7 +108,6 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
onChange(newValue)
|
onChange(newValue)
|
||||||
}
|
}
|
||||||
}, [value, onChange])
|
}, [value, onChange])
|
||||||
|
|
||||||
const handleAppChange = useCallback((variable: string) => {
|
const handleAppChange = useCallback((variable: string) => {
|
||||||
return (app: {
|
return (app: {
|
||||||
app_id: string
|
app_id: string
|
||||||
@ -111,7 +115,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
files?: any[]
|
files?: any[]
|
||||||
}) => {
|
}) => {
|
||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
draft[variable] = app as any
|
draft[variable].value = app as any
|
||||||
})
|
})
|
||||||
onChange(newValue)
|
onChange(newValue)
|
||||||
}
|
}
|
||||||
@ -119,8 +123,8 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
const handleModelChange = useCallback((variable: string) => {
|
const handleModelChange = useCallback((variable: string) => {
|
||||||
return (model: any) => {
|
return (model: any) => {
|
||||||
const newValue = produce(value, (draft: ToolVarInputs) => {
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
||||||
draft[variable] = {
|
draft[variable].value = {
|
||||||
...draft[variable],
|
...draft[variable].value,
|
||||||
...model,
|
...model,
|
||||||
} as any
|
} as any
|
||||||
})
|
})
|
||||||
@ -188,33 +192,31 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|||||||
placeholderClassName='!leading-[21px]'
|
placeholderClassName='!leading-[21px]'
|
||||||
/>
|
/>
|
||||||
)} */}
|
)} */}
|
||||||
{/* {(isNumber || isSelect) && (
|
{(isNumber || isSelect) && (
|
||||||
<VarReferencePicker
|
<VarReferencePicker
|
||||||
readonly={readOnly}
|
readonly={false}
|
||||||
isShowNodeName
|
isShowNodeName
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
value={varInput?.type === VarKindType.constant ? (varInput?.value ?? '') : (varInput?.value ?? [])}
|
value={varInput?.type === VarKindType.constant ? (varInput?.value ?? '') : (varInput?.value ?? [])}
|
||||||
onChange={handleNotMixedTypeChange(variable)}
|
onChange={handleNotMixedTypeChange(variable)}
|
||||||
onOpen={handleOpen(index)}
|
|
||||||
defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
|
defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
|
||||||
isSupportConstantValue={isSupportConstantValue}
|
isSupportConstantValue
|
||||||
filterVar={isNumber ? filterVar : undefined}
|
filterVar={isNumber ? (varPayload: Var) => varPayload.type === schema._type : undefined}
|
||||||
availableVars={isSelect ? availableVars : undefined}
|
availableVars={isSelect ? nodeOutputVars : undefined}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
{/* {isFile && (
|
{isFile && (
|
||||||
<VarReferencePicker
|
<VarReferencePicker
|
||||||
readonly={readOnly}
|
readonly={false}
|
||||||
isShowNodeName
|
isShowNodeName
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
value={varInput?.value || []}
|
value={varInput?.value || []}
|
||||||
onChange={handleFileChange(variable)}
|
onChange={handleFileChange(variable)}
|
||||||
onOpen={handleOpen(index)}
|
|
||||||
defaultVarKindType={VarKindType.variable}
|
defaultVarKindType={VarKindType.variable}
|
||||||
filterVar={(varPayload: Var) => varPayload.type === VarType.file || varPayload.type === VarType.arrayFile}
|
filterVar={(varPayload: Var) => varPayload.type === VarType.file || varPayload.type === VarType.arrayFile}
|
||||||
/>
|
/>
|
||||||
)} */}
|
)}
|
||||||
{isAppSelector && (
|
{isAppSelector && (
|
||||||
<AppSelector
|
<AppSelector
|
||||||
disabled={false}
|
disabled={false}
|
||||||
|
@ -36,6 +36,7 @@ export type AgentStrategyProps = {
|
|||||||
onFormValueChange: (value: ToolVarInputs) => void
|
onFormValueChange: (value: ToolVarInputs) => void
|
||||||
nodeOutputVars?: NodeOutPutVar[],
|
nodeOutputVars?: NodeOutPutVar[],
|
||||||
availableNodes?: Node[],
|
availableNodes?: Node[],
|
||||||
|
nodeId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomSchema<Type, Field = {}> = Omit<CredentialFormSchema, 'type'> & { type: Type } & Field
|
type CustomSchema<Type, Field = {}> = Omit<CredentialFormSchema, 'type'> & { type: Type } & Field
|
||||||
@ -46,7 +47,7 @@ type MultipleToolSelectorSchema = CustomSchema<'array[tools]'>
|
|||||||
type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema
|
type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema
|
||||||
|
|
||||||
export const AgentStrategy = memo((props: AgentStrategyProps) => {
|
export const AgentStrategy = memo((props: AgentStrategyProps) => {
|
||||||
const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange, nodeOutputVars, availableNodes } = props
|
const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange, nodeOutputVars, availableNodes, nodeId } = props
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration)
|
const defaultModel = useDefaultModel(ModelTypeEnum.textGeneration)
|
||||||
const renderI18nObject = useRenderI18nObject()
|
const renderI18nObject = useRenderI18nObject()
|
||||||
@ -155,6 +156,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
|
|||||||
>
|
>
|
||||||
<ToolSelector
|
<ToolSelector
|
||||||
supportVariables
|
supportVariables
|
||||||
|
nodeId={nodeId || ''}
|
||||||
nodeOutputVars={nodeOutputVars || []}
|
nodeOutputVars={nodeOutputVars || []}
|
||||||
availableNodes={availableNodes || []}
|
availableNodes={availableNodes || []}
|
||||||
scope={schema.scope}
|
scope={schema.scope}
|
||||||
@ -173,6 +175,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => {
|
|||||||
return (
|
return (
|
||||||
<MultipleToolSelector
|
<MultipleToolSelector
|
||||||
supportVariables
|
supportVariables
|
||||||
|
nodeId={nodeId || ''}
|
||||||
nodeOutputVars={nodeOutputVars || []}
|
nodeOutputVars={nodeOutputVars || []}
|
||||||
availableNodes={availableNodes || []}
|
availableNodes={availableNodes || []}
|
||||||
scope={schema.scope}
|
scope={schema.scope}
|
||||||
|
@ -103,6 +103,7 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
|
|||||||
onFormValueChange={onFormChange}
|
onFormValueChange={onFormChange}
|
||||||
nodeOutputVars={availableVars}
|
nodeOutputVars={availableVars}
|
||||||
availableNodes={availableNodesWithParent}
|
availableNodes={availableNodesWithParent}
|
||||||
|
nodeId={props.id}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user