mirror of
https://github.com/langgenius/dify.git
synced 2025-11-04 21:03:02 +00:00
Merge branch 'feat/rag-pipeline' of https://github.com/langgenius/dify into feat/rag-pipeline
This commit is contained in:
commit
0099f2296d
@ -1,4 +1,7 @@
|
|||||||
import { useMemo } from 'react'
|
import {
|
||||||
|
memo,
|
||||||
|
useMemo,
|
||||||
|
} from 'react'
|
||||||
import type { PanelProps } from '@/app/components/workflow/panel'
|
import type { PanelProps } from '@/app/components/workflow/panel'
|
||||||
import Panel from '@/app/components/workflow/panel'
|
import Panel from '@/app/components/workflow/panel'
|
||||||
import { useStore } from '@/app/components/workflow/store'
|
import { useStore } from '@/app/components/workflow/store'
|
||||||
@ -28,4 +31,4 @@ const RagPipelinePanel = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RagPipelinePanel
|
export default memo(RagPipelinePanel)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { memo } from 'react'
|
||||||
import { useStore } from '../../workflow/store'
|
import { useStore } from '../../workflow/store'
|
||||||
import InputField from './input-field'
|
import InputField from './input-field'
|
||||||
import RagPipelinePanel from './panel'
|
import RagPipelinePanel from './panel'
|
||||||
@ -17,4 +18,4 @@ const RagPipelineChildren = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RagPipelineChildren
|
export default memo(RagPipelineChildren)
|
||||||
|
|||||||
@ -1,10 +1,25 @@
|
|||||||
import { useMemo } from 'react'
|
import {
|
||||||
|
memo,
|
||||||
|
useMemo,
|
||||||
|
} from 'react'
|
||||||
import type { HeaderProps } from '@/app/components/workflow/header'
|
import type { HeaderProps } from '@/app/components/workflow/header'
|
||||||
import Header from '@/app/components/workflow/header'
|
import Header from '@/app/components/workflow/header'
|
||||||
|
import { fetchWorkflowRunHistory } from '@/service/workflow'
|
||||||
|
import { useStore } from '@/app/components/workflow/store'
|
||||||
import InputFieldButton from './input-field-button'
|
import InputFieldButton from './input-field-button'
|
||||||
import Publisher from './publisher'
|
import Publisher from './publisher'
|
||||||
|
|
||||||
const RagPipelineHeader = () => {
|
const RagPipelineHeader = () => {
|
||||||
|
const pipelineId = useStore(s => s.pipelineId)
|
||||||
|
|
||||||
|
const viewHistoryProps = useMemo(() => {
|
||||||
|
return {
|
||||||
|
historyUrl: '',
|
||||||
|
// historyUrl: `/rag/pipeline/${pipelineId}/workflow-runs`,
|
||||||
|
historyFetcher: fetchWorkflowRunHistory,
|
||||||
|
}
|
||||||
|
}, [pipelineId])
|
||||||
|
|
||||||
const headerProps: HeaderProps = useMemo(() => {
|
const headerProps: HeaderProps = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
normal: {
|
normal: {
|
||||||
@ -12,13 +27,21 @@ const RagPipelineHeader = () => {
|
|||||||
left: <InputFieldButton />,
|
left: <InputFieldButton />,
|
||||||
middle: <Publisher />,
|
middle: <Publisher />,
|
||||||
},
|
},
|
||||||
|
runAndHistoryProps: {
|
||||||
|
showRunButton: true,
|
||||||
|
runButtonText: 'Test Run',
|
||||||
|
viewHistoryProps,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
viewHistory: {
|
||||||
|
viewHistoryProps,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [])
|
}, [viewHistoryProps])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header {...headerProps} />
|
<Header {...headerProps} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RagPipelineHeader
|
export default memo(RagPipelineHeader)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { memo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiArrowDownSLine } from '@remixicon/react'
|
import { RiArrowDownSLine } from '@remixicon/react'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
@ -25,11 +26,11 @@ const Publisher = () => {
|
|||||||
<RiArrowDownSLine className='h-4 w-4' />
|
<RiArrowDownSLine className='h-4 w-4' />
|
||||||
</Button>
|
</Button>
|
||||||
</PortalToFollowElemTrigger>
|
</PortalToFollowElemTrigger>
|
||||||
<PortalToFollowElemContent>
|
<PortalToFollowElemContent className='z-[11]'>
|
||||||
<Popup />
|
<Popup />
|
||||||
</PortalToFollowElemContent>
|
</PortalToFollowElemContent>
|
||||||
</PortalToFollowElem>
|
</PortalToFollowElem>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Publisher
|
export default memo(Publisher)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
@ -77,9 +78,10 @@ const Popup = () => {
|
|||||||
}
|
}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className='space-y-1 border-t-[0.5px] border-t-divider-regular p-4 pt-3'>
|
<div className='border-t-[0.5px] border-t-divider-regular p-4 pt-3'>
|
||||||
<Button
|
<Button
|
||||||
className='w-full'
|
className='mb-1 w-full hover:bg-state-accent-hover hover:text-text-accent'
|
||||||
|
variant='tertiary'
|
||||||
>
|
>
|
||||||
<div className='flex grow items-center'>
|
<div className='flex grow items-center'>
|
||||||
<RiPlayCircleLine className='mr-2 h-4 w-4' />
|
<RiPlayCircleLine className='mr-2 h-4 w-4' />
|
||||||
@ -88,7 +90,8 @@ const Popup = () => {
|
|||||||
<RiArrowRightUpLine className='ml-2 h-4 w-4 shrink-0' />
|
<RiArrowRightUpLine className='ml-2 h-4 w-4 shrink-0' />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className='w-full'
|
className='w-full hover:bg-state-accent-hover hover:text-text-accent'
|
||||||
|
variant='tertiary'
|
||||||
>
|
>
|
||||||
<div className='flex grow items-center'>
|
<div className='flex grow items-center'>
|
||||||
<RiTerminalBoxLine className='mr-2 h-4 w-4' />
|
<RiTerminalBoxLine className='mr-2 h-4 w-4' />
|
||||||
@ -96,16 +99,19 @@ const Popup = () => {
|
|||||||
</div>
|
</div>
|
||||||
<RiArrowRightUpLine className='ml-2 h-4 w-4 shrink-0' />
|
<RiArrowRightUpLine className='ml-2 h-4 w-4 shrink-0' />
|
||||||
</Button>
|
</Button>
|
||||||
<Divider />
|
<Divider className='my-2' />
|
||||||
<Button
|
<Button
|
||||||
className='w-full'
|
className='w-full hover:bg-state-accent-hover hover:text-text-accent'
|
||||||
|
variant='tertiary'
|
||||||
>
|
>
|
||||||
<RiHammerLine className='mr-2 h-4 w-4' />
|
<div className='flex grow items-center'>
|
||||||
Publish as a Knowledge Pipeline
|
<RiHammerLine className='mr-2 h-4 w-4' />
|
||||||
|
Publish as a Knowledge Pipeline
|
||||||
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Popup
|
export default memo(Popup)
|
||||||
|
|||||||
@ -279,6 +279,7 @@ export const useWorkflowRun = () => {
|
|||||||
const handleStopRun = useCallback((taskId: string) => {
|
const handleStopRun = useCallback((taskId: string) => {
|
||||||
const { pipelineId } = workflowStore.getState()
|
const { pipelineId } = workflowStore.getState()
|
||||||
|
|
||||||
|
return
|
||||||
stopWorkflowRun(`/rag/pipeline/${pipelineId}/workflow-runs/tasks/${taskId}/stop`)
|
stopWorkflowRun(`/rag/pipeline/${pipelineId}/workflow-runs/tasks/${taskId}/stop`)
|
||||||
}, [workflowStore])
|
}, [workflowStore])
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,41 @@
|
|||||||
import { useMemo } from 'react'
|
import {
|
||||||
|
memo,
|
||||||
|
useCallback,
|
||||||
|
useMemo,
|
||||||
|
} from 'react'
|
||||||
|
import { useShallow } from 'zustand/react/shallow'
|
||||||
import type { HeaderProps } from '@/app/components/workflow/header'
|
import type { HeaderProps } from '@/app/components/workflow/header'
|
||||||
import Header from '@/app/components/workflow/header'
|
import Header from '@/app/components/workflow/header'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
|
import {
|
||||||
|
fetchWorkflowRunHistory,
|
||||||
|
} from '@/service/workflow'
|
||||||
import ChatVariableTrigger from './chat-variable-trigger'
|
import ChatVariableTrigger from './chat-variable-trigger'
|
||||||
import FeaturesTrigger from './features-trigger'
|
import FeaturesTrigger from './features-trigger'
|
||||||
import { useResetWorkflowVersionHistory } from '@/service/use-workflow'
|
import { useResetWorkflowVersionHistory } from '@/service/use-workflow'
|
||||||
|
import { useIsChatMode } from '../../hooks'
|
||||||
|
|
||||||
const WorkflowHeader = () => {
|
const WorkflowHeader = () => {
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
const { appDetail, setCurrentLogItem, setShowMessageLogModal } = useAppStore(useShallow(state => ({
|
||||||
|
appDetail: state.appDetail,
|
||||||
|
setCurrentLogItem: state.setCurrentLogItem,
|
||||||
|
setShowMessageLogModal: state.setShowMessageLogModal,
|
||||||
|
})))
|
||||||
const resetWorkflowVersionHistory = useResetWorkflowVersionHistory(appDetail!.id)
|
const resetWorkflowVersionHistory = useResetWorkflowVersionHistory(appDetail!.id)
|
||||||
|
const isChatMode = useIsChatMode()
|
||||||
|
|
||||||
|
const handleClearLogAndMessageModal = useCallback(() => {
|
||||||
|
setCurrentLogItem()
|
||||||
|
setShowMessageLogModal(false)
|
||||||
|
}, [setCurrentLogItem, setShowMessageLogModal])
|
||||||
|
|
||||||
|
const viewHistoryProps = useMemo(() => {
|
||||||
|
return {
|
||||||
|
onClearLogAndMessageModal: handleClearLogAndMessageModal,
|
||||||
|
historyUrl: isChatMode ? `/apps/${appDetail!.id}/advanced-chat/workflow-runs` : `/apps/${appDetail!.id}/workflow-runs`,
|
||||||
|
historyFetcher: fetchWorkflowRunHistory,
|
||||||
|
}
|
||||||
|
}, [appDetail, isChatMode, handleClearLogAndMessageModal])
|
||||||
|
|
||||||
const headerProps: HeaderProps = useMemo(() => {
|
const headerProps: HeaderProps = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
@ -17,15 +44,23 @@ const WorkflowHeader = () => {
|
|||||||
left: <ChatVariableTrigger />,
|
left: <ChatVariableTrigger />,
|
||||||
middle: <FeaturesTrigger />,
|
middle: <FeaturesTrigger />,
|
||||||
},
|
},
|
||||||
|
runAndHistoryProps: {
|
||||||
|
showRunButton: !isChatMode,
|
||||||
|
showPreviewButton: isChatMode,
|
||||||
|
viewHistoryProps,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
viewHistory: {
|
||||||
|
viewHistoryProps,
|
||||||
},
|
},
|
||||||
restoring: {
|
restoring: {
|
||||||
onRestoreSettled: resetWorkflowVersionHistory,
|
onRestoreSettled: resetWorkflowVersionHistory,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [resetWorkflowVersionHistory])
|
}, [resetWorkflowVersionHistory, isChatMode, viewHistoryProps])
|
||||||
return (
|
return (
|
||||||
<Header {...headerProps} />
|
<Header {...headerProps} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default WorkflowHeader
|
export default memo(WorkflowHeader)
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { useMemo } from 'react'
|
import {
|
||||||
|
memo,
|
||||||
|
useMemo,
|
||||||
|
} from 'react'
|
||||||
import { useShallow } from 'zustand/react/shallow'
|
import { useShallow } from 'zustand/react/shallow'
|
||||||
import { useStore } from '@/app/components/workflow/store'
|
import { useStore } from '@/app/components/workflow/store'
|
||||||
import {
|
import {
|
||||||
@ -106,4 +109,4 @@ const WorkflowPanel = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default WorkflowPanel
|
export default memo(WorkflowPanel)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import {
|
|||||||
useWorkflowRun,
|
useWorkflowRun,
|
||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
import Divider from '../../base/divider'
|
import Divider from '../../base/divider'
|
||||||
|
import type { RunAndHistoryProps } from './run-and-history'
|
||||||
import RunAndHistory from './run-and-history'
|
import RunAndHistory from './run-and-history'
|
||||||
import EditingTitle from './editing-title'
|
import EditingTitle from './editing-title'
|
||||||
import EnvButton from './env-button'
|
import EnvButton from './env-button'
|
||||||
@ -23,9 +24,11 @@ export type HeaderInNormalProps = {
|
|||||||
left?: React.ReactNode
|
left?: React.ReactNode
|
||||||
middle?: React.ReactNode
|
middle?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
runAndHistoryProps?: RunAndHistoryProps
|
||||||
}
|
}
|
||||||
const HeaderInNormal = ({
|
const HeaderInNormal = ({
|
||||||
components,
|
components,
|
||||||
|
runAndHistoryProps,
|
||||||
}: HeaderInNormalProps) => {
|
}: HeaderInNormalProps) => {
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
@ -58,7 +61,7 @@ const HeaderInNormal = ({
|
|||||||
{components?.left}
|
{components?.left}
|
||||||
<EnvButton disabled={nodesReadOnly} />
|
<EnvButton disabled={nodesReadOnly} />
|
||||||
<Divider type='vertical' className='mx-auto h-3.5' />
|
<Divider type='vertical' className='mx-auto h-3.5' />
|
||||||
<RunAndHistory />
|
<RunAndHistory {...runAndHistoryProps} />
|
||||||
{components?.middle}
|
{components?.middle}
|
||||||
<VersionHistoryButton onClick={onStartRestoring} />
|
<VersionHistoryButton onClick={onStartRestoring} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,11 +10,17 @@ import {
|
|||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
import Divider from '../../base/divider'
|
import Divider from '../../base/divider'
|
||||||
import RunningTitle from './running-title'
|
import RunningTitle from './running-title'
|
||||||
|
import type { ViewHistoryProps } from './view-history'
|
||||||
import ViewHistory from './view-history'
|
import ViewHistory from './view-history'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { ArrowNarrowLeft } from '@/app/components/base/icons/src/vender/line/arrows'
|
import { ArrowNarrowLeft } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||||
|
|
||||||
const HeaderInHistory = () => {
|
export type HeaderInHistoryProps = {
|
||||||
|
viewHistoryProps?: ViewHistoryProps
|
||||||
|
}
|
||||||
|
const HeaderInHistory = ({
|
||||||
|
viewHistoryProps,
|
||||||
|
}: HeaderInHistoryProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
|
|
||||||
@ -33,7 +39,7 @@ const HeaderInHistory = () => {
|
|||||||
<RunningTitle />
|
<RunningTitle />
|
||||||
</div>
|
</div>
|
||||||
<div className='flex items-center space-x-2'>
|
<div className='flex items-center space-x-2'>
|
||||||
<ViewHistory withText />
|
<ViewHistory {...viewHistoryProps} withText />
|
||||||
<Divider type='vertical' className='mx-auto h-3.5' />
|
<Divider type='vertical' className='mx-auto h-3.5' />
|
||||||
<Button
|
<Button
|
||||||
variant='primary'
|
variant='primary'
|
||||||
|
|||||||
@ -3,16 +3,19 @@ import {
|
|||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
import type { HeaderInNormalProps } from './header-in-normal'
|
import type { HeaderInNormalProps } from './header-in-normal'
|
||||||
import HeaderInNormal from './header-in-normal'
|
import HeaderInNormal from './header-in-normal'
|
||||||
|
import type { HeaderInHistoryProps } from './header-in-view-history'
|
||||||
import HeaderInHistory from './header-in-view-history'
|
import HeaderInHistory from './header-in-view-history'
|
||||||
import type { HeaderInRestoringProps } from './header-in-restoring'
|
import type { HeaderInRestoringProps } from './header-in-restoring'
|
||||||
import HeaderInRestoring from './header-in-restoring'
|
import HeaderInRestoring from './header-in-restoring'
|
||||||
|
|
||||||
export type HeaderProps = {
|
export type HeaderProps = {
|
||||||
normal?: HeaderInNormalProps
|
normal?: HeaderInNormalProps
|
||||||
|
viewHistory?: HeaderInHistoryProps
|
||||||
restoring?: HeaderInRestoringProps
|
restoring?: HeaderInRestoringProps
|
||||||
}
|
}
|
||||||
const Header = ({
|
const Header = ({
|
||||||
normal: normalProps,
|
normal: normalProps,
|
||||||
|
viewHistory: viewHistoryProps,
|
||||||
restoring: restoringProps,
|
restoring: restoringProps,
|
||||||
}: HeaderProps) => {
|
}: HeaderProps) => {
|
||||||
const {
|
const {
|
||||||
@ -34,7 +37,9 @@ const Header = ({
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
viewHistory && (
|
viewHistory && (
|
||||||
<HeaderInHistory />
|
<HeaderInHistory
|
||||||
|
{...viewHistoryProps}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import type { FC } from 'react'
|
|
||||||
import { memo } from 'react'
|
import { memo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
@ -7,12 +6,12 @@ import {
|
|||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import { useStore } from '../store'
|
import { useStore } from '../store'
|
||||||
import {
|
import {
|
||||||
useIsChatMode,
|
|
||||||
useNodesReadOnly,
|
useNodesReadOnly,
|
||||||
useWorkflowRun,
|
useWorkflowRun,
|
||||||
useWorkflowStartRun,
|
useWorkflowStartRun,
|
||||||
} from '../hooks'
|
} from '../hooks'
|
||||||
import { WorkflowRunningStatus } from '../types'
|
import { WorkflowRunningStatus } from '../types'
|
||||||
|
import type { ViewHistoryProps } from './view-history'
|
||||||
import ViewHistory from './view-history'
|
import ViewHistory from './view-history'
|
||||||
import Checklist from './checklist'
|
import Checklist from './checklist'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
@ -20,7 +19,12 @@ import {
|
|||||||
StopCircle,
|
StopCircle,
|
||||||
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
} from '@/app/components/base/icons/src/vender/line/mediaAndDevices'
|
||||||
|
|
||||||
const RunMode = memo(() => {
|
type RunModeProps = {
|
||||||
|
text?: string
|
||||||
|
}
|
||||||
|
const RunMode = memo(({
|
||||||
|
text,
|
||||||
|
}: RunModeProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { handleWorkflowStartRunInWorkflow } = useWorkflowStartRun()
|
const { handleWorkflowStartRunInWorkflow } = useWorkflowStartRun()
|
||||||
const { handleStopRun } = useWorkflowRun()
|
const { handleStopRun } = useWorkflowRun()
|
||||||
@ -50,7 +54,7 @@ const RunMode = memo(() => {
|
|||||||
: (
|
: (
|
||||||
<>
|
<>
|
||||||
<RiPlayLargeLine className='mr-1 h-4 w-4' />
|
<RiPlayLargeLine className='mr-1 h-4 w-4' />
|
||||||
{t('workflow.common.run')}
|
{text ?? t('workflow.common.run')}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -68,7 +72,6 @@ const RunMode = memo(() => {
|
|||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
RunMode.displayName = 'RunMode'
|
|
||||||
|
|
||||||
const PreviewMode = memo(() => {
|
const PreviewMode = memo(() => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -87,22 +90,31 @@ const PreviewMode = memo(() => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
PreviewMode.displayName = 'PreviewMode'
|
|
||||||
|
|
||||||
const RunAndHistory: FC = () => {
|
export type RunAndHistoryProps = {
|
||||||
const isChatMode = useIsChatMode()
|
showRunButton?: boolean
|
||||||
|
runButtonText?: string
|
||||||
|
showPreviewButton?: boolean
|
||||||
|
viewHistoryProps?: ViewHistoryProps
|
||||||
|
}
|
||||||
|
const RunAndHistory = ({
|
||||||
|
showRunButton,
|
||||||
|
runButtonText,
|
||||||
|
showPreviewButton,
|
||||||
|
viewHistoryProps,
|
||||||
|
}: RunAndHistoryProps) => {
|
||||||
const { nodesReadOnly } = useNodesReadOnly()
|
const { nodesReadOnly } = useNodesReadOnly()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex h-8 items-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-0.5 shadow-xs'>
|
<div className='flex h-8 items-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-0.5 shadow-xs'>
|
||||||
{
|
{
|
||||||
!isChatMode && <RunMode />
|
showRunButton && <RunMode text={runButtonText} />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isChatMode && <PreviewMode />
|
showPreviewButton && <PreviewMode />
|
||||||
}
|
}
|
||||||
<div className='mx-0.5 h-3.5 w-[1px] bg-divider-regular'></div>
|
<div className='mx-0.5 h-3.5 w-[1px] bg-divider-regular'></div>
|
||||||
<ViewHistory />
|
<ViewHistory {...viewHistoryProps} />
|
||||||
<Checklist disabled={nodesReadOnly} />
|
<Checklist disabled={nodesReadOnly} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import {
|
|||||||
memo,
|
memo,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import type { Fetcher } from 'swr'
|
||||||
import useSWR from 'swr'
|
import useSWR from 'swr'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useShallow } from 'zustand/react/shallow'
|
import { noop } from 'lodash-es'
|
||||||
import {
|
import {
|
||||||
RiCheckboxCircleLine,
|
RiCheckboxCircleLine,
|
||||||
RiCloseLine,
|
RiCloseLine,
|
||||||
@ -25,27 +26,29 @@ import {
|
|||||||
PortalToFollowElemTrigger,
|
PortalToFollowElemTrigger,
|
||||||
} from '@/app/components/base/portal-to-follow-elem'
|
} from '@/app/components/base/portal-to-follow-elem'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
|
||||||
import {
|
import {
|
||||||
ClockPlay,
|
ClockPlay,
|
||||||
ClockPlaySlim,
|
ClockPlaySlim,
|
||||||
} from '@/app/components/base/icons/src/vender/line/time'
|
} from '@/app/components/base/icons/src/vender/line/time'
|
||||||
import { AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'
|
import { AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'
|
||||||
import {
|
|
||||||
fetchChatRunHistory,
|
|
||||||
fetchWorkflowRunHistory,
|
|
||||||
} from '@/service/workflow'
|
|
||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import {
|
import {
|
||||||
useStore,
|
useStore,
|
||||||
useWorkflowStore,
|
useWorkflowStore,
|
||||||
} from '@/app/components/workflow/store'
|
} from '@/app/components/workflow/store'
|
||||||
|
import type { WorkflowRunHistoryResponse } from '@/types/workflow'
|
||||||
|
|
||||||
type ViewHistoryProps = {
|
export type ViewHistoryProps = {
|
||||||
withText?: boolean
|
withText?: boolean
|
||||||
|
onClearLogAndMessageModal?: () => void
|
||||||
|
historyUrl?: string
|
||||||
|
historyFetcher?: Fetcher<WorkflowRunHistoryResponse, string>
|
||||||
}
|
}
|
||||||
const ViewHistory = ({
|
const ViewHistory = ({
|
||||||
withText,
|
withText,
|
||||||
|
onClearLogAndMessageModal,
|
||||||
|
historyUrl,
|
||||||
|
historyFetcher,
|
||||||
}: ViewHistoryProps) => {
|
}: ViewHistoryProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const isChatMode = useIsChatMode()
|
const isChatMode = useIsChatMode()
|
||||||
@ -59,18 +62,14 @@ const ViewHistory = ({
|
|||||||
} = useWorkflowInteractions()
|
} = useWorkflowInteractions()
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const setControlMode = useStore(s => s.setControlMode)
|
const setControlMode = useStore(s => s.setControlMode)
|
||||||
const { appDetail, setCurrentLogItem, setShowMessageLogModal } = useAppStore(useShallow(state => ({
|
|
||||||
appDetail: state.appDetail,
|
|
||||||
setCurrentLogItem: state.setCurrentLogItem,
|
|
||||||
setShowMessageLogModal: state.setShowMessageLogModal,
|
|
||||||
})))
|
|
||||||
const historyWorkflowData = useStore(s => s.historyWorkflowData)
|
const historyWorkflowData = useStore(s => s.historyWorkflowData)
|
||||||
const { handleBackupDraft } = useWorkflowRun()
|
const { handleBackupDraft } = useWorkflowRun()
|
||||||
const { data: runList, isLoading: runListLoading } = useSWR((appDetail && !isChatMode && open) ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory)
|
|
||||||
const { data: chatList, isLoading: chatListLoading } = useSWR((appDetail && isChatMode && open) ? `/apps/${appDetail.id}/advanced-chat/workflow-runs` : null, fetchChatRunHistory)
|
|
||||||
|
|
||||||
const data = isChatMode ? chatList : runList
|
const fetcher = historyFetcher ?? (noop as Fetcher<WorkflowRunHistoryResponse, string>)
|
||||||
const isLoading = isChatMode ? chatListLoading : runListLoading
|
const {
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
} = useSWR((open && historyUrl && historyFetcher) ? historyUrl : null, fetcher)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(
|
(
|
||||||
@ -106,8 +105,7 @@ const ViewHistory = ({
|
|||||||
<div
|
<div
|
||||||
className={cn('group flex h-7 w-7 cursor-pointer items-center justify-center rounded-md hover:bg-state-accent-hover', open && 'bg-state-accent-hover')}
|
className={cn('group flex h-7 w-7 cursor-pointer items-center justify-center rounded-md hover:bg-state-accent-hover', open && 'bg-state-accent-hover')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentLogItem()
|
onClearLogAndMessageModal?.()
|
||||||
setShowMessageLogModal(false)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ClockPlay className={cn('h-4 w-4 group-hover:text-components-button-secondary-accent-text', open ? 'text-components-button-secondary-accent-text' : 'text-components-button-ghost-text')} />
|
<ClockPlay className={cn('h-4 w-4 group-hover:text-components-button-secondary-accent-text', open ? 'text-components-button-secondary-accent-text' : 'text-components-button-ghost-text')} />
|
||||||
@ -128,8 +126,7 @@ const ViewHistory = ({
|
|||||||
<div
|
<div
|
||||||
className='flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center'
|
className='flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentLogItem()
|
onClearLogAndMessageModal?.()
|
||||||
setShowMessageLogModal(false)
|
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,12 +1,18 @@
|
|||||||
import { memo } from 'react'
|
import { memo } from 'react'
|
||||||
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
||||||
import { Field } from '@/app/components/workflow/nodes/_base/components/layout'
|
import { Field } from '@/app/components/workflow/nodes/_base/components/layout'
|
||||||
|
import type { ValueSelector } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
const InputVariable = () => {
|
type InputVariableProps = {
|
||||||
const handleChange = () => {
|
nodeId: string
|
||||||
console.log('')
|
inputVariable?: string[]
|
||||||
}
|
onInputVariableChange: (inputVariable: string | ValueSelector) => void
|
||||||
|
}
|
||||||
|
const InputVariable = ({
|
||||||
|
nodeId,
|
||||||
|
inputVariable = [],
|
||||||
|
onInputVariableChange,
|
||||||
|
}: InputVariableProps) => {
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
fieldTitleProps={{
|
fieldTitleProps={{
|
||||||
@ -15,10 +21,10 @@ const InputVariable = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<VarReferencePicker
|
<VarReferencePicker
|
||||||
nodeId={''}
|
nodeId={nodeId}
|
||||||
isShowNodeName
|
isShowNodeName
|
||||||
value={[]}
|
value={inputVariable}
|
||||||
onChange={handleChange}
|
onChange={onInputVariableChange}
|
||||||
readonly={false}
|
readonly={false}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import { useStoreApi } from 'reactflow'
|
import { useStoreApi } from 'reactflow'
|
||||||
import { useNodeDataUpdate } from '@/app/components/workflow/hooks'
|
import { useNodeDataUpdate } from '@/app/components/workflow/hooks'
|
||||||
|
import type { ValueSelector } from '@/app/components/workflow/types'
|
||||||
import type {
|
import type {
|
||||||
ChunkStructureEnum,
|
ChunkStructureEnum,
|
||||||
HybridSearchModeEnum,
|
HybridSearchModeEnum,
|
||||||
@ -147,6 +148,12 @@ export const useConfig = (id: string) => {
|
|||||||
})
|
})
|
||||||
}, [getNodeData, handleNodeDataUpdate])
|
}, [getNodeData, handleNodeDataUpdate])
|
||||||
|
|
||||||
|
const handleInputVariableChange = useCallback((inputVariable: string | ValueSelector) => {
|
||||||
|
handleNodeDataUpdate({
|
||||||
|
index_chunk_variable_selector: Array.isArray(inputVariable) ? inputVariable : [],
|
||||||
|
})
|
||||||
|
}, [handleNodeDataUpdate])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleChunkStructureChange,
|
handleChunkStructureChange,
|
||||||
handleIndexMethodChange,
|
handleIndexMethodChange,
|
||||||
@ -159,5 +166,6 @@ export const useConfig = (id: string) => {
|
|||||||
handleTopKChange,
|
handleTopKChange,
|
||||||
handleScoreThresholdChange,
|
handleScoreThresholdChange,
|
||||||
handleScoreThresholdEnabledChange,
|
handleScoreThresholdEnabledChange,
|
||||||
|
handleInputVariableChange,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,12 +35,17 @@ const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
|
|||||||
handleTopKChange,
|
handleTopKChange,
|
||||||
handleScoreThresholdChange,
|
handleScoreThresholdChange,
|
||||||
handleScoreThresholdEnabledChange,
|
handleScoreThresholdEnabledChange,
|
||||||
|
handleInputVariableChange,
|
||||||
} = useConfig(id)
|
} = useConfig(id)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<GroupWithBox boxProps={{ withBorderBottom: true }}>
|
<GroupWithBox boxProps={{ withBorderBottom: true }}>
|
||||||
<InputVariable />
|
<InputVariable
|
||||||
|
nodeId={id}
|
||||||
|
inputVariable={data.index_chunk_variable_selector}
|
||||||
|
onInputVariableChange={handleInputVariableChange}
|
||||||
|
/>
|
||||||
</GroupWithBox>
|
</GroupWithBox>
|
||||||
<Group
|
<Group
|
||||||
className='py-3'
|
className='py-3'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user