default.ts 857 B

123456789101112131415161718192021222324252627282930313233
  1. import { BlockEnum } from '../../types'
  2. import type { NodeDefault } from '../../types'
  3. import { type EndNodeType } from './types'
  4. import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
  5. const nodeDefault: NodeDefault<EndNodeType> = {
  6. defaultValue: {
  7. outputs: [],
  8. },
  9. getAvailablePrevNodes(isChatMode: boolean) {
  10. const nodes = isChatMode
  11. ? ALL_CHAT_AVAILABLE_BLOCKS
  12. : ALL_COMPLETION_AVAILABLE_BLOCKS.filter(type => type !== BlockEnum.End)
  13. return nodes
  14. },
  15. getAvailableNextNodes() {
  16. return []
  17. },
  18. checkValid(payload: EndNodeType) {
  19. let isValid = true
  20. let errorMessages = ''
  21. if (payload.type) {
  22. isValid = true
  23. errorMessages = ''
  24. }
  25. return {
  26. isValid,
  27. errorMessage: errorMessages,
  28. }
  29. },
  30. }
  31. export default nodeDefault