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,
}