mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 22:05:53 +08:00
chore: enable auto collapse
This commit is contained in:
parent
5cdf70503d
commit
d568ecb3ff
@ -4,11 +4,15 @@ import Collapse from '.'
|
|||||||
type FieldCollapseProps = {
|
type FieldCollapseProps = {
|
||||||
title: string
|
title: string
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
|
collapsed?: boolean
|
||||||
|
onCollapse?: (collapsed: boolean) => void
|
||||||
operations?: ReactNode
|
operations?: ReactNode
|
||||||
}
|
}
|
||||||
const FieldCollapse = ({
|
const FieldCollapse = ({
|
||||||
title,
|
title,
|
||||||
children,
|
children,
|
||||||
|
collapsed,
|
||||||
|
onCollapse,
|
||||||
operations,
|
operations,
|
||||||
}: FieldCollapseProps) => {
|
}: FieldCollapseProps) => {
|
||||||
return (
|
return (
|
||||||
@ -18,6 +22,8 @@ const FieldCollapse = ({
|
|||||||
<div className='system-sm-semibold-uppercase flex h-6 cursor-pointer items-center text-text-secondary'>{title}</div>
|
<div className='system-sm-semibold-uppercase flex h-6 cursor-pointer items-center text-text-secondary'>{title}</div>
|
||||||
}
|
}
|
||||||
operations={operations}
|
operations={operations}
|
||||||
|
collapsed={collapsed}
|
||||||
|
onCollapse={onCollapse}
|
||||||
>
|
>
|
||||||
<div className='px-4'>
|
<div className='px-4'>
|
||||||
{children}
|
{children}
|
||||||
|
@ -9,18 +9,24 @@ type Props = {
|
|||||||
title?: string
|
title?: string
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
operations?: ReactNode
|
operations?: ReactNode
|
||||||
|
collapsed?: boolean
|
||||||
|
onCollapse?: (collapsed: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const OutputVars: FC<Props> = ({
|
const OutputVars: FC<Props> = ({
|
||||||
title,
|
title,
|
||||||
children,
|
children,
|
||||||
operations,
|
operations,
|
||||||
|
collapsed,
|
||||||
|
onCollapse,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<FieldCollapse
|
<FieldCollapse
|
||||||
title={title || t('workflow.nodes.common.outputVars')}
|
title={title || t('workflow.nodes.common.outputVars')}
|
||||||
operations={operations}
|
operations={operations}
|
||||||
|
collapsed={collapsed}
|
||||||
|
onCollapse={onCollapse}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</FieldCollapse>
|
</FieldCollapse>
|
||||||
|
@ -68,6 +68,8 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||||||
setContexts,
|
setContexts,
|
||||||
runningStatus,
|
runningStatus,
|
||||||
isModelSupportStructuredOutput,
|
isModelSupportStructuredOutput,
|
||||||
|
structuredOutputCollapsed,
|
||||||
|
setStructuredOutputCollapsed,
|
||||||
handleStructureOutputEnableChange,
|
handleStructureOutputEnableChange,
|
||||||
handleStructureOutputChange,
|
handleStructureOutputChange,
|
||||||
handleRun,
|
handleRun,
|
||||||
@ -289,6 +291,8 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||||||
</div>
|
</div>
|
||||||
<Split />
|
<Split />
|
||||||
<OutputVars
|
<OutputVars
|
||||||
|
collapsed={structuredOutputCollapsed}
|
||||||
|
onCollapse={setStructuredOutputCollapsed}
|
||||||
operations={
|
operations={
|
||||||
<div className='mr-4 flex items-center'>
|
<div className='mr-4 flex items-center'>
|
||||||
{!isModelSupportStructuredOutput && (
|
{!isModelSupportStructuredOutput && (
|
||||||
|
@ -285,11 +285,14 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||||||
?.models.find(modelItem => modelItem.model === model?.name)
|
?.models.find(modelItem => modelItem.model === model?.name)
|
||||||
?.features?.includes(ModelFeatureEnum.StructuredOutput)
|
?.features?.includes(ModelFeatureEnum.StructuredOutput)
|
||||||
|
|
||||||
|
const [structuredOutputCollapsed, setStructuredOutputCollapsed] = useState(true)
|
||||||
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
|
||||||
})
|
})
|
||||||
setInputs(newInputs)
|
setInputs(newInputs)
|
||||||
|
if (enabled)
|
||||||
|
setStructuredOutputCollapsed(false)
|
||||||
}, [inputs, setInputs])
|
}, [inputs, setInputs])
|
||||||
|
|
||||||
const handleStructureOutputChange = useCallback((newOutput: StructuredOutput) => {
|
const handleStructureOutputChange = useCallback((newOutput: StructuredOutput) => {
|
||||||
@ -432,6 +435,8 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||||||
runningStatus,
|
runningStatus,
|
||||||
isModelSupportStructuredOutput,
|
isModelSupportStructuredOutput,
|
||||||
handleStructureOutputChange,
|
handleStructureOutputChange,
|
||||||
|
structuredOutputCollapsed,
|
||||||
|
setStructuredOutputCollapsed,
|
||||||
handleStructureOutputEnableChange,
|
handleStructureOutputEnableChange,
|
||||||
handleRun,
|
handleRun,
|
||||||
handleStop,
|
handleStop,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user