feat: APO node select quickly
parent
ab453fa9d6
commit
fbbfaddd85
@ -0,0 +1,35 @@
|
||||
import { memo, useContext } from 'react'
|
||||
import I18n from '@/context/i18n'
|
||||
import { getLanguage } from '@/i18n/language'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
const ParametersInfo = ({ parameter }) => {
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getLanguage(locale)
|
||||
const { t } = useTranslation()
|
||||
const getType = (type: string) => {
|
||||
if (type === 'number-input')
|
||||
return t('tools.setBuiltInTools.number')
|
||||
if (type === 'text-input')
|
||||
return t('tools.setBuiltInTools.string')
|
||||
if (type === 'file')
|
||||
return t('tools.setBuiltInTools.file')
|
||||
return type
|
||||
}
|
||||
return <div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='text-text-secondary code-sm-semibold'>{parameter.label[language]}</div>
|
||||
<div className='text-text-tertiary system-xs-regular'>
|
||||
{getType(parameter.type)}
|
||||
</div>
|
||||
{parameter.required && (
|
||||
<div className='text-text-warning-secondary system-xs-medium'>{t('tools.setBuiltInTools.required')}</div>
|
||||
)}
|
||||
</div>
|
||||
{parameter.human_description && (
|
||||
<div className='mt-0.5 text-text-tertiary system-xs-regular'>
|
||||
{parameter.human_description?.[language]}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
export default memo(ParametersInfo)
|
||||
@ -0,0 +1,42 @@
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
|
||||
import Form from '../../nodes/_base/components/before-run-form/form'
|
||||
import { InputVarType } from '../../types'
|
||||
import ParametersInfo from './parameters-info'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
const varTypeToInputVarType = (type: string) => {
|
||||
if(type === 'string')
|
||||
return InputVarType.textInput
|
||||
else if (type === 'file')
|
||||
return InputVarType.singleFile
|
||||
return type
|
||||
}
|
||||
const ToolTrialRun = ({ infoSchemas }) => {
|
||||
const [formValues, setFormValues] = useState(null)
|
||||
const [formInputs, setFormInputs] = useState([])
|
||||
const language = useGetLanguage()
|
||||
const { t } = useTranslation()
|
||||
useEffect(() => {
|
||||
const formValues = infoSchemas?.reduce((acc, item) => {
|
||||
acc[item.name] = null
|
||||
return acc
|
||||
}, {})
|
||||
const formInputs = infoSchemas.map(item => ({
|
||||
// label: formLable(item),
|
||||
label: item.label[language],
|
||||
require: item.require,
|
||||
type: varTypeToInputVarType(item.type),
|
||||
variable: item.name,
|
||||
customLabel: <ParametersInfo parameter={item} />,
|
||||
}))
|
||||
setFormValues(formValues)
|
||||
setFormInputs(formInputs)
|
||||
}, [infoSchemas])
|
||||
return <>
|
||||
<div className='py-2 text-text-primary system-sm-semibold-uppercase'>{t('tools.setBuiltInTools.parameters')}</div>
|
||||
<Form inputs={formInputs} values={formValues} onChange={newValues => setFormValues(newValues) }
|
||||
></Form>
|
||||
</>
|
||||
}
|
||||
export default memo(ToolTrialRun)
|
||||
Loading…
Reference in New Issue