mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 23:45:54 +08:00
chore: temp show lengcy
This commit is contained in:
parent
475e1d07a7
commit
cea0886e4a
@ -10,6 +10,8 @@ import Slider from '@/app/components/base/slider'
|
|||||||
import Radio from '@/app/components/base/radio'
|
import Radio from '@/app/components/base/radio'
|
||||||
import { SimpleSelect } from '@/app/components/base/select'
|
import { SimpleSelect } from '@/app/components/base/select'
|
||||||
import TagInput from '@/app/components/base/tag-input'
|
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
|
export type ParameterValue = number | string | string[] | boolean | undefined
|
||||||
|
|
||||||
@ -27,6 +29,7 @@ const ParameterItem: FC<ParameterItemProps> = ({
|
|||||||
onSwitch,
|
onSwitch,
|
||||||
isInWorkflow,
|
isInWorkflow,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const [localValue, setLocalValue] = useState(value)
|
const [localValue, setLocalValue] = useState(value)
|
||||||
const numberInputRef = useRef<HTMLInputElement>(null)
|
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>
|
</div>
|
||||||
{
|
{
|
||||||
parameterRule.type === 'tag' && (
|
parameterRule.type === 'tag' && (
|
||||||
|
@ -67,6 +67,7 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||||||
contexts,
|
contexts,
|
||||||
setContexts,
|
setContexts,
|
||||||
runningStatus,
|
runningStatus,
|
||||||
|
isModelSupportStructuredOutput,
|
||||||
handleStructureOutputEnableChange,
|
handleStructureOutputEnableChange,
|
||||||
handleStructureOutputChange,
|
handleStructureOutputChange,
|
||||||
handleRun,
|
handleRun,
|
||||||
@ -280,16 +281,18 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||||||
<OutputVars
|
<OutputVars
|
||||||
operations={
|
operations={
|
||||||
<div className='mr-4 flex items-center'>
|
<div className='mr-4 flex items-center'>
|
||||||
<Tooltip noDecoration popupContent={
|
{!isModelSupportStructuredOutput && (
|
||||||
<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]'>
|
<Tooltip noDecoration popupContent={
|
||||||
<div className='title-xs-semi-bold text-text-primary'>{t('app.structOutput.modelNotSupported')}</div>
|
<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='mt-1 body-xs-regular text-text-secondary'>{t('app.structOutput.modelNotSupportedTip')}</div>
|
<div className='title-xs-semi-bold text-text-primary'>{t('app.structOutput.modelNotSupported')}</div>
|
||||||
</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>
|
||||||
</div>
|
<RiAlertFill className='mr-1 size-4 text-text-warning-secondary' />
|
||||||
</Tooltip>
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
<div className='mr-0.5 system-xs-medium-uppercase text-text-tertiary'>{t('app.structOutput.structured')}</div>
|
<div className='mr-0.5 system-xs-medium-uppercase text-text-tertiary'>{t('app.structOutput.structured')}</div>
|
||||||
<Tooltip popupContent={
|
<Tooltip popupContent={
|
||||||
<div className='max-w-[150px]'>{t('app.structOutput.structuredTip')}</div>
|
<div className='max-w-[150px]'>{t('app.structOutput.structuredTip')}</div>
|
||||||
|
@ -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 useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
|
||||||
import { RETRIEVAL_OUTPUT_STRUCT } from '@/app/components/workflow/constants'
|
import { RETRIEVAL_OUTPUT_STRUCT } from '@/app/components/workflow/constants'
|
||||||
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/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 useConfig = (id: string, payload: LLMNodeType) => {
|
||||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||||
@ -277,6 +279,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||||||
setInputs(newInputs)
|
setInputs(newInputs)
|
||||||
}, [inputs, setInputs])
|
}, [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 handleStructureOutputEnableChange = useCallback((enabled: boolean) => {
|
||||||
const newInputs = produce(inputs, (draft) => {
|
const newInputs = produce(inputs, (draft) => {
|
||||||
draft.structured_output_enabled = enabled
|
draft.structured_output_enabled = enabled
|
||||||
@ -422,6 +429,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||||||
setContexts,
|
setContexts,
|
||||||
varInputs,
|
varInputs,
|
||||||
runningStatus,
|
runningStatus,
|
||||||
|
isModelSupportStructuredOutput,
|
||||||
handleStructureOutputChange,
|
handleStructureOutputChange,
|
||||||
handleStructureOutputEnableChange,
|
handleStructureOutputEnableChange,
|
||||||
handleRun,
|
handleRun,
|
||||||
|
@ -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',
|
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',
|
modelNotSupported: 'Model not supported',
|
||||||
modelNotSupportedTip: 'The current model does not support this feature and is automatically downgraded to prompt injection.',
|
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',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +191,9 @@ const translation = {
|
|||||||
structuredTip: '结构化输出是一项功能,可确保模型始终生成符合您提供的 JSON 模式的响应',
|
structuredTip: '结构化输出是一项功能,可确保模型始终生成符合您提供的 JSON 模式的响应',
|
||||||
modelNotSupported: '模型不支持',
|
modelNotSupported: '模型不支持',
|
||||||
modelNotSupportedTip: '当前模型不支持此功能,将自动降级为提示注入。',
|
modelNotSupportedTip: '当前模型不支持此功能,将自动降级为提示注入。',
|
||||||
|
legacy: '遗留',
|
||||||
|
legacyTip: '此功能将在未来版本中删除',
|
||||||
|
learnMore: '了解更多',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user