chore: temp show lengcy

This commit is contained in:
Joel 2025-03-17 16:30:04 +08:00
parent 475e1d07a7
commit cea0886e4a
5 changed files with 43 additions and 10 deletions

View File

@ -10,6 +10,8 @@ import Slider from '@/app/components/base/slider'
import Radio from '@/app/components/base/radio'
import { SimpleSelect } from '@/app/components/base/select'
import TagInput from '@/app/components/base/tag-input'
import Badge from '@/app/components/base/badge'
import { useTranslation } from 'react-i18next'
export type ParameterValue = number | string | string[] | boolean | undefined
@ -27,6 +29,7 @@ const ParameterItem: FC<ParameterItemProps> = ({
onSwitch,
isInWorkflow,
}) => {
const { t } = useTranslation()
const language = useLanguage()
const [localValue, setLocalValue] = useState(value)
const numberInputRef = useRef<HTMLInputElement>(null)
@ -278,6 +281,19 @@ const ParameterItem: FC<ParameterItemProps> = ({
/>
)
}
{/* TODO: wait api return and product design */}
{parameterRule.name === 'json_schema' && (
<Tooltip
popupContent={(
<div className='w-[232px]'>
<div className='mb-1 body-xs-regular text-text-secondary'>{t('app.structOutput.legacyTip')}</div>
<a className='' target='_blank' href='https://todo'>{t('app.structOutput.learnMore')}</a>
</div>
)}
>
<Badge uppercase className='text-text-accent-secondary'>{t('app.structOutput.legacy')}</Badge>
</Tooltip>
)}
</div>
{
parameterRule.type === 'tag' && (

View File

@ -67,6 +67,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
contexts,
setContexts,
runningStatus,
isModelSupportStructuredOutput,
handleStructureOutputEnableChange,
handleStructureOutputChange,
handleRun,
@ -280,16 +281,18 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
<OutputVars
operations={
<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>
{!isModelSupportStructuredOutput && (
<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>

View File

@ -18,6 +18,8 @@ import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-cr
import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
import { RETRIEVAL_OUTPUT_STRUCT } from '@/app/components/workflow/constants'
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/constants'
import useSWR from 'swr'
import { fetchModelParameterRules } from '@/service/common'
const useConfig = (id: string, payload: LLMNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
@ -277,6 +279,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
setInputs(newInputs)
}, [inputs, setInputs])
// structure output
// TODO: this method has problem, different model has different parameter rules that show support structured output
const { data: parameterRulesData } = useSWR((model?.provider && model?.name) ? `/workspaces/current/model-providers/${model.provider}/models/parameter-rules?model=${model.name}` : null, fetchModelParameterRules)
const isModelSupportStructuredOutput = parameterRulesData?.data?.some((rule: any) => rule.name === 'json_schema')
const handleStructureOutputEnableChange = useCallback((enabled: boolean) => {
const newInputs = produce(inputs, (draft) => {
draft.structured_output_enabled = enabled
@ -422,6 +429,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
setContexts,
varInputs,
runningStatus,
isModelSupportStructuredOutput,
handleStructureOutputChange,
handleStructureOutputEnableChange,
handleRun,

View File

@ -190,6 +190,9 @@ const translation = {
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.',
legacy: 'Legacy',
legacyTip: 'JSON Schema will be removed from model parameters, you can use the structured output functionality under nodes instead.',
learnMore: 'Learn more',
},
}

View File

@ -191,6 +191,9 @@ const translation = {
structuredTip: '结构化输出是一项功能,可确保模型始终生成符合您提供的 JSON 模式的响应',
modelNotSupported: '模型不支持',
modelNotSupportedTip: '当前模型不支持此功能,将自动降级为提示注入。',
legacy: '遗留',
legacyTip: '此功能将在未来版本中删除',
learnMore: '了解更多',
},
}