feat: remove Sleep
node.
This commit is contained in:
parent
8c0ffb92a8
commit
733e7a3f58
@ -1,46 +0,0 @@
|
||||
{
|
||||
"icon": {
|
||||
"type": "element",
|
||||
"isRootNode": true,
|
||||
"name": "svg",
|
||||
"attributes": {
|
||||
"width": "14",
|
||||
"height": "14",
|
||||
"viewBox": "0 0 1024 1024",
|
||||
"fill": "none",
|
||||
"xmlns": "http://www.w3.org/2000/svg"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "element",
|
||||
"name": "g",
|
||||
"attributes": {
|
||||
"id": "icons/sleep"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"id": "Vector (Stroke)",
|
||||
"d": "M221.78789744 920.38454701c-15.71774359 0-28.4991453-12.78249572-28.49914531-28.4991453s12.78140171-28.50023931 28.49914531-28.50023932h28.99145299V732.11186325c0-88.83309402 74.38659829-147.01948718 128.70345299-189.51111112 14.95521367-11.70160684 33.45723077-26.17545299 42.02119658-35.78201708l4.02160684-4.51500856-4.20102564-4.34652991c-8.86700854-9.1580171-27.59111111-22.61770941-42.6425983-33.43425641-54.56300854-39.20957265-129.26905983-92.90393162-129.26905982-178.6945641V160.61483761h-27.63049573a28.53305983 28.53305983 0 0 1-28.50023932-28.4991453 28.53305983 28.53305983 0 0 1 28.4991453-28.50023932h580.44170941a28.53305983 28.53305983 0 0 1 28.50023931 28.4991453 28.52758974 28.52758974 0 0 1-28.4991453 28.50023932h-27.63158974v125.22447863c0 85.80157265-74.71699146 139.49046154-129.26358975 178.6945641-15.07336752 10.83295726-33.79309402 24.28717949-42.6371282 33.43425641l-4.20649573 4.34762394 4.02707693 4.51391452c8.55302564 9.60109402 27.03316239 24.0574359 41.88663248 35.67589744 54.44594872 42.58680342 128.8259829 100.76225641 128.8259829 189.61723077v131.27329914h29.0045812a28.53305983 28.53305983 0 0 1 28.50461539 28.49476923 28.33176069 28.33176069 0 0 1-8.33969231 20.15835898 28.31535043 28.31535043 0 0 1-20.15398291 8.34735043h-580.45264957z m84.62550427-634.54523077c0 56.56287179 58.51131624 98.6114188 105.52888888 132.40451282 39.70844444 28.53962393 71.06516239 51.07418803 71.0651624 83.89251282 0 31.85449572-30.18064957 55.45900854-68.38700855 85.35302564-47.61162393 37.23815385-106.8351453 83.56758974-106.83514529 144.62249573v131.26782906h408.44034188V732.11186325c0-61.0494359-59.22352136-107.38434188-106.81217095-144.60499146-38.22386325-29.91152136-68.40451282-53.52150428-68.40451282-85.37709402 0-32.81176069 31.35671795-55.34632479 71.05422223-83.87938461 47.02851282-33.79418803 105.53982906-75.84820513 105.53982905-132.41107692V160.61483761H306.41449572v125.22447863z",
|
||||
"fill": "currentColor"
|
||||
},
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"type": "element",
|
||||
"name": "path",
|
||||
"attributes": {
|
||||
"id": "Vector (Stroke)",
|
||||
"d": "M412.28820513 765.81538462c-13.6 0-24.66461538-11.06461538-24.66461539-24.66564103s11.06461538-24.66461538 24.66461539-24.66461538h199.42871795c13.6 0 24.66461538 11.06461538 24.66461538 24.66461538s-11.06461538 24.66666667-24.66461538 24.66666667H412.28717949z",
|
||||
"fill": "currentColor"
|
||||
},
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": "Sleep"
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
import * as React from 'react'
|
||||
import data from './Sleep.json'
|
||||
import IconBase from '@/app/components/base/icons/IconBase'
|
||||
import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase'
|
||||
|
||||
const Icon = React.forwardRef<React.MutableRefObject<SVGElement>, Omit<IconBaseProps, 'data'>>((
|
||||
props,
|
||||
ref,
|
||||
) => <IconBase {...props} ref={ref} data={data as IconData} />)
|
||||
|
||||
Icon.displayName = 'Sleep'
|
||||
|
||||
export default Icon
|
@ -11,7 +11,6 @@ export { default as IterationStart } from './IterationStart'
|
||||
export { default as Iteration } from './Iteration'
|
||||
export { default as LoopStart } from './LoopStart'
|
||||
export { default as Loop } from './Loop'
|
||||
export { default as Sleep } from './Sleep'
|
||||
export { default as Jinja } from './Jinja'
|
||||
export { default as KnowledgeRetrieval } from './KnowledgeRetrieval'
|
||||
export { default as ListFilter } from './ListFilter'
|
||||
|
@ -1 +0,0 @@
|
||||
export const CUSTOM_SLEEP_NODE = 'custom-sleep'
|
@ -1,26 +0,0 @@
|
||||
import { BlockEnum, type NodeDefault } from '../../types'
|
||||
import type { SleepNodeType } from './types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
|
||||
|
||||
const nodeDefault: NodeDefault<SleepNodeType> = {
|
||||
defaultValue: {
|
||||
sleep_time_ms: 1000,
|
||||
},
|
||||
getAvailablePrevNodes(isChatMode: boolean) {
|
||||
const nodes = isChatMode
|
||||
? ALL_CHAT_AVAILABLE_BLOCKS
|
||||
: ALL_COMPLETION_AVAILABLE_BLOCKS.filter(type => type !== BlockEnum.End)
|
||||
return nodes
|
||||
},
|
||||
getAvailableNextNodes(isChatMode: boolean) {
|
||||
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||
return nodes
|
||||
},
|
||||
checkValid() {
|
||||
return {
|
||||
isValid: true,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default nodeDefault
|
@ -1,28 +0,0 @@
|
||||
import { memo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type { NodeProps } from 'reactflow'
|
||||
import { RiHome5Fill } from '@remixicon/react'
|
||||
import Tooltip from '@/app/components/base/tooltip'
|
||||
import { NodeSourceHandle } from '@/app/components/workflow/nodes/_base/components/node-handle'
|
||||
|
||||
const SleepNode = ({ id, data }: NodeProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className='group flex nodrag items-center justify-center w-11 h-11 mt-1 rounded-2xl border border-workflow-block-border bg-white'>
|
||||
<Tooltip popupContent={t('workflow.blocks.sleep')} asChild={false}>
|
||||
<div className='flex items-center justify-center w-6 h-6 rounded-full border-[0.5px] border-components-panel-border-subtle bg-util-colors-blue-brand-blue-brand-500'>
|
||||
<RiHome5Fill className='w-3 h-3 text-text-primary-on-surface' />
|
||||
</div>
|
||||
</Tooltip>
|
||||
<NodeSourceHandle
|
||||
id={id}
|
||||
data={data}
|
||||
handleClassName='!top-1/2 !-right-[9px] !-translate-y-1/2'
|
||||
handleId='source'
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(SleepNode)
|
@ -1,10 +0,0 @@
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import type { SleepNodeType } from './types'
|
||||
import type { NodeProps } from '@/app/components/workflow/types'
|
||||
|
||||
const Node: FC<NodeProps<SleepNodeType>> = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
export default React.memo(Node)
|
@ -1,50 +0,0 @@
|
||||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import useConfig from './use-config'
|
||||
|
||||
import type { SleepNodeType } from './types'
|
||||
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
import { InputNumber } from '@/app/components/base/input-number'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.sleep'
|
||||
|
||||
const Panel: FC<NodePanelProps<SleepNodeType>> = ({
|
||||
id,
|
||||
data,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const {
|
||||
inputs,
|
||||
handleSleepTimeChange,
|
||||
} = useConfig(id, data)
|
||||
|
||||
return (
|
||||
<div className='mt-2'>
|
||||
<div className='px-4 pb-4 space-y-4'>
|
||||
<Field
|
||||
title={t(`${i18nPrefix}.sleepTime`)}
|
||||
>
|
||||
<>
|
||||
<InputNumber
|
||||
min={1}
|
||||
max={60 * 1000}
|
||||
value={inputs.sleep_time_ms}
|
||||
onChange={handleSleepTimeChange}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t(`${i18nPrefix}.sleepTimeTip`)!}
|
||||
/>
|
||||
<div className="text-sm text-gray-500 mt-2">
|
||||
{t(`${i18nPrefix}.sleepTimeTip`)}
|
||||
</div>
|
||||
</>
|
||||
</Field>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(Panel)
|
@ -1,5 +0,0 @@
|
||||
import type { CommonNodeType } from '@/app/components/workflow/types'
|
||||
|
||||
export type SleepNodeType = CommonNodeType & {
|
||||
sleep_time_ms: number
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import produce from 'immer'
|
||||
import { useCallback } from 'react'
|
||||
import useNodeCrud from '../_base/hooks/use-node-crud'
|
||||
import type { SleepNodeType } from './types'
|
||||
|
||||
const useConfig = (id: string, payload: SleepNodeType) => {
|
||||
const { inputs, setInputs } = useNodeCrud<SleepNodeType>(id, payload)
|
||||
|
||||
const handleSleepTimeChange = useCallback((sleepTimeMs: number | undefined) => {
|
||||
const newInputs = produce(inputs, (draft: SleepNodeType) => {
|
||||
draft.sleep_time_ms = sleepTimeMs || 1000
|
||||
})
|
||||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
|
||||
return {
|
||||
inputs,
|
||||
handleSleepTimeChange,
|
||||
}
|
||||
}
|
||||
|
||||
export default useConfig
|
Loading…
Reference in New Issue
Block a user