chore: add i18n

pull/12372/head
AkaraChen 1 year ago
parent c867584049
commit a7b2f9aef0

@ -13,7 +13,13 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
const { t } = useTranslation() const { t } = useTranslation()
return <div className='mb-1 px-3 py-1 space-y-1'> return <div className='mb-1 px-3 py-1 space-y-1'>
{inputs.agent_strategy_name {inputs.agent_strategy_name
? <SettingItem label='Strategy' status='error' tooltip='ReAct is not installed'> ? <SettingItem
label={t('workflow.nodes.agent.strategy.shortLabel')}
status='error'
tooltip={t('workflow.nodes.agent.strategyNotInstallTooltip', {
strategy: inputs.agent_strategy_name,
})}
>
{inputs.agent_strategy_name} {inputs.agent_strategy_name}
</SettingItem> </SettingItem>
: <SettingItem label={t('workflow.nodes.agent.strategyNotSet')} />} : <SettingItem label={t('workflow.nodes.agent.strategyNotSet')} />}
@ -40,8 +46,18 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
</GroupLabel>}> </GroupLabel>}>
<div className='grid grid-cols-10 gap-0.5'> <div className='grid grid-cols-10 gap-0.5'>
<ToolIcon src='/logo/logo.png' /> <ToolIcon src='/logo/logo.png' />
<ToolIcon src='/logo/logo.png' status='error' tooltip='Gmail Sender is not installed' /> <ToolIcon
<ToolIcon src='/logo/logo.png' status='warning' tooltip='DuckDuckGo AI Search Not Authorized' /> src='/logo/logo.png'
status='error'
tooltip={t('workflow.nodes.agent.toolNotInstallTooltip', {
tool: 'Gmail Sender',
})} />
<ToolIcon
src='/logo/logo.png'
status='warning'
tooltip={t('workflow.nodes.agent.toolNotAuthorizedTooltip', {
tool: 'DuckDuckGo AI Search',
})} />
</div> </div>
</Group> </Group>
</div> </div>

@ -4,8 +4,9 @@ import type { AgentNodeType } from './types'
import Field from '../_base/components/field' import Field from '../_base/components/field'
import { InputNumber } from '@/app/components/base/input-number' import { InputNumber } from '@/app/components/base/input-number'
import Slider from '@/app/components/base/slider' import Slider from '@/app/components/base/slider'
import useNodeCrud from '../_base/hooks/use-node-crud'
import { AgentStrategy } from '../_base/components/agent-strategy' import { AgentStrategy } from '../_base/components/agent-strategy'
import useConfig from './use-config'
import { useTranslation } from 'react-i18next'
const mockSchema = [ const mockSchema = [
{ {
@ -260,7 +261,8 @@ const mockSchema = [
] as const ] as const
const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => { const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
const { inputs, setInputs } = useNodeCrud(props.id, props.data) const { inputs, setInputs } = useConfig(props.id, props.data)
const { t } = useTranslation()
const [iter, setIter] = [inputs.max_iterations, (value: number) => { const [iter, setIter] = [inputs.max_iterations, (value: number) => {
setInputs({ setInputs({
...inputs, ...inputs,
@ -268,7 +270,7 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
}) })
}] }]
return <div className='space-y-2 my-2'> return <div className='space-y-2 my-2'>
<Field title={'Strategy'} className='px-4' > <Field title={t('workflow.nodes.agent.strategy.label')} className='px-4' >
<AgentStrategy <AgentStrategy
strategy={inputs.agent_strategy_name ? { strategy={inputs.agent_strategy_name ? {
agent_strategy_provider_name: inputs.agent_strategy_provider_name!, agent_strategy_provider_name: inputs.agent_strategy_provider_name!,
@ -291,10 +293,10 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
})} })}
/> />
</Field> </Field>
<Field title={'tools'} className='px-4'> <Field title={t('workflow.nodes.agent.tools')} className='px-4'>
</Field> </Field>
<Field title={'max iterations'} tooltip={'max iter'} inline className='px-4'> <Field title={t('workflow.nodes.agent.maxIterations')} tooltip={'max iter'} inline className='px-4'>
<div className='flex w-[200px] items-center gap-3'> <div className='flex w-[200px] items-center gap-3'>
<Slider value={iter} onChange={setIter} className='w-full' min={1} max={10} /> <Slider value={iter} onChange={setIter} className='w-full' min={1} max={10} />
<InputNumber <InputNumber

@ -17,6 +17,7 @@ const useConfig = (id: string, payload: AgentNodeType) => {
return { return {
readOnly, readOnly,
inputs, inputs,
setInputs,
handleVarListChange, handleVarListChange,
handleAddVariable, handleAddVariable,
} }

@ -700,6 +700,7 @@ const translation = {
agent: { agent: {
strategy: { strategy: {
label: 'Agentic Strategy', label: 'Agentic Strategy',
shortLabel: 'Strategy',
configureTip: 'Please configure agentic strategy.', configureTip: 'Please configure agentic strategy.',
configureTipDesc: 'After configuring the agentic strategy, this node will automatically load the remaining configurations. The strategy will affect the mechanism of multi-step tool reasoning. ', configureTipDesc: 'After configuring the agentic strategy, this node will automatically load the remaining configurations. The strategy will affect the mechanism of multi-step tool reasoning. ',
selectTip: 'Select agentic strategy', selectTip: 'Select agentic strategy',
@ -715,6 +716,12 @@ const translation = {
model: 'model', model: 'model',
toolbox: 'toolbox', toolbox: 'toolbox',
strategyNotSet: 'Agentic strategy Not Set', strategyNotSet: 'Agentic strategy Not Set',
tools: 'Tools',
maxIterations: 'Max Iterations',
modelNotInstallTooltip: 'This model is not installed',
toolNotInstallTooltip: '{{tool}} is not installed',
toolNotAuthorizedTooltip: '{{tool}} Not Authorized',
strategyNotInstallTooltip: '{{strategy}} is not installed',
}, },
}, },
tracing: { tracing: {

@ -700,6 +700,7 @@ const translation = {
agent: { agent: {
strategy: { strategy: {
label: 'Agent 策略', label: 'Agent 策略',
shortLabel: '策略',
configureTip: '请配置 Agent 策略。', configureTip: '请配置 Agent 策略。',
configureTipDesc: '配置完成后,此节点将自动加载剩余配置。策略将影响多步工具推理的机制。', configureTipDesc: '配置完成后,此节点将自动加载剩余配置。策略将影响多步工具推理的机制。',
selectTip: '选择 Agent 策略', selectTip: '选择 Agent 策略',
@ -715,6 +716,12 @@ const translation = {
model: '模型', model: '模型',
toolbox: '工具箱', toolbox: '工具箱',
strategyNotSet: '代理策略未设置', strategyNotSet: '代理策略未设置',
tools: '工具',
maxIterations: '最大迭代次数',
modelNotInstallTooltip: '此模型未安装',
toolNotInstallTooltip: '{{tool}} 未安装',
toolNotAuthorizedTooltip: '{{tool}} 未授权',
strategyNotInstallTooltip: '{{strategy}} 未安装',
}, },
}, },
tracing: { tracing: {

Loading…
Cancel
Save