feat: i18n and struct tooltip

This commit is contained in:
Joel 2025-03-17 14:59:03 +08:00
parent b1c5299ff4
commit 475e1d07a7
4 changed files with 37 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import ShowPanel from '@/app/components/workflow/nodes/_base/components/variable
import { useBoolean } from 'ahooks'
import JsonSchemaConfigModal from './json-schema-config-modal'
import cn from '@/utils/classnames'
import { useTranslation } from 'react-i18next'
type Props = {
className?: string
@ -20,6 +21,7 @@ const StructureOutput: FC<Props> = ({
value,
onChange,
}) => {
const { t } = useTranslation()
const [showConfig, {
setTrue: showConfigModal,
setFalse: hideConfigModal,
@ -44,14 +46,14 @@ const StructureOutput: FC<Props> = ({
onClick={showConfigModal}
>
<RiEditLine className='size-3.5 mr-1' />
<div className='system-xs-medium text-components-button-secondary-text'>Configure</div>
<div className='system-xs-medium text-components-button-secondary-text'>{t('app.structOutput.configure')}</div>
</Button>
</div>
{value?.schema ? (
<ShowPanel
payload={value}
/>) : (
<div className='mt-1.5 flex items-center h-10 justify-center rounded-[10px] bg-background-section system-xs-regular text-text-tertiary'>no data</div>
<div className='mt-1.5 flex items-center h-10 justify-center rounded-[10px] bg-background-section system-xs-regular text-text-tertiary'>{t('app.structOutput.notConfiguredTip')}</div>
)}
{showConfig && (

View File

@ -22,6 +22,7 @@ import Tooltip from '@/app/components/base/tooltip'
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
import StructureOutput from './components/structure-output'
import Switch from '@/app/components/base/switch'
import { RiAlertFill, RiQuestionLine } from '@remixicon/react'
const i18nPrefix = 'workflow.nodes.llm'
@ -278,8 +279,27 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
<Split />
<OutputVars
operations={
<div className='mr-4'>
<div className='mr-4 flex items-center'>
<Tooltip noDecoration popupContent={
<div className='w-[232px] px-4 py-3.5 rounded-xl bg-components-tooltip-bg border-[0.5px] border-components-panel-border shadow-lg backdrop-blur-[5px]'>
<div className='title-xs-semi-bold text-text-primary'>{t('app.structOutput.modelNotSupported')}</div>
<div className='mt-1 body-xs-regular text-text-secondary'>{t('app.structOutput.modelNotSupportedTip')}</div>
</div>
}>
<div>
<RiAlertFill className='mr-1 size-4 text-text-warning-secondary' />
</div>
</Tooltip>
<div className='mr-0.5 system-xs-medium-uppercase text-text-tertiary'>{t('app.structOutput.structured')}</div>
<Tooltip popupContent={
<div className='max-w-[150px]'>{t('app.structOutput.structuredTip')}</div>
}>
<div>
<RiQuestionLine className='size-3.5 text-text-quaternary' />
</div>
</Tooltip>
<Switch
className='ml-2'
defaultValue={!!inputs.structured_output_enabled}
onChange={handleStructureOutputEnableChange}
size='md'

View File

@ -184,6 +184,12 @@ const translation = {
moreFillTip: 'Showing max 10 levels of nesting',
required: 'Required',
LLMResponse: 'LLM Response',
configure: 'Configure',
notConfiguredTip: 'Structured output has not been configured yet',
structured: 'Structured',
structuredTip: 'Structured Outputs is a feature that ensures the model will always generate responses that adhere to your supplied JSON Schema',
modelNotSupported: 'Model not supported',
modelNotSupportedTip: 'The current model does not support this feature and is automatically downgraded to prompt injection.',
},
}

View File

@ -185,6 +185,12 @@ const translation = {
moreFillTip: '最多显示 10 级嵌套',
required: '必填',
LLMResponse: 'LLM 的响应',
configure: '配置',
notConfiguredTip: '结构化输出尚未配置',
structured: '结构化',
structuredTip: '结构化输出是一项功能,可确保模型始终生成符合您提供的 JSON 模式的响应',
modelNotSupported: '模型不支持',
modelNotSupportedTip: '当前模型不支持此功能,将自动降级为提示注入。',
},
}