chore: add i18n

This commit is contained in:
AkaraChen 2024-12-25 14:52:11 +08:00
parent c867584049
commit a7b2f9aef0
5 changed files with 41 additions and 8 deletions

View File

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

View File

@ -4,8 +4,9 @@ import type { AgentNodeType } from './types'
import Field from '../_base/components/field'
import { InputNumber } from '@/app/components/base/input-number'
import Slider from '@/app/components/base/slider'
import useNodeCrud from '../_base/hooks/use-node-crud'
import { AgentStrategy } from '../_base/components/agent-strategy'
import useConfig from './use-config'
import { useTranslation } from 'react-i18next'
const mockSchema = [
{
@ -260,7 +261,8 @@ const mockSchema = [
] as const
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) => {
setInputs({
...inputs,
@ -268,7 +270,7 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
})
}]
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
strategy={inputs.agent_strategy_name ? {
agent_strategy_provider_name: inputs.agent_strategy_provider_name!,
@ -291,10 +293,10 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
})}
/>
</Field>
<Field title={'tools'} className='px-4'>
<Field title={t('workflow.nodes.agent.tools')} className='px-4'>
</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'>
<Slider value={iter} onChange={setIter} className='w-full' min={1} max={10} />
<InputNumber

View File

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

View File

@ -700,6 +700,7 @@ const translation = {
agent: {
strategy: {
label: 'Agentic Strategy',
shortLabel: '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. ',
selectTip: 'Select agentic strategy',
@ -715,6 +716,12 @@ const translation = {
model: 'model',
toolbox: 'toolbox',
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: {

View File

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