use-node-help-link.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { useMemo } from 'react'
  2. import { useGetLanguage } from '@/context/i18n'
  3. import { BlockEnum } from '@/app/components/workflow/types'
  4. export const useNodeHelpLink = (nodeType: BlockEnum) => {
  5. const language = useGetLanguage()
  6. const prefixLink = useMemo(() => {
  7. if (language === 'zh_Hans')
  8. return 'https://docs.dify.ai/v/zh-hans/guides/workflow/node/'
  9. return 'https://docs.dify.ai/guides/workflow/node/'
  10. }, [language])
  11. const linkMap = useMemo(() => {
  12. if (language === 'zh_Hans') {
  13. return {
  14. [BlockEnum.Start]: 'start',
  15. [BlockEnum.End]: 'end',
  16. [BlockEnum.Answer]: 'answer',
  17. [BlockEnum.LLM]: 'llm',
  18. [BlockEnum.KnowledgeRetrieval]: 'knowledge-retrieval',
  19. [BlockEnum.QuestionClassifier]: 'question-classifier',
  20. [BlockEnum.IfElse]: 'ifelse',
  21. [BlockEnum.Code]: 'code',
  22. [BlockEnum.TemplateTransform]: 'template',
  23. [BlockEnum.VariableAssigner]: 'variable-assigner',
  24. [BlockEnum.VariableAggregator]: 'variable-aggregator',
  25. [BlockEnum.Assigner]: 'variable-assigner',
  26. [BlockEnum.Iteration]: 'iteration',
  27. [BlockEnum.IterationStart]: 'iteration',
  28. [BlockEnum.ParameterExtractor]: 'parameter-extractor',
  29. [BlockEnum.HttpRequest]: 'http-request',
  30. [BlockEnum.Tool]: 'tools',
  31. [BlockEnum.DocExtractor]: 'doc-extractor',
  32. [BlockEnum.ListFilter]: 'list-operator',
  33. }
  34. }
  35. return {
  36. [BlockEnum.Start]: 'start',
  37. [BlockEnum.End]: 'end',
  38. [BlockEnum.Answer]: 'answer',
  39. [BlockEnum.LLM]: 'llm',
  40. [BlockEnum.KnowledgeRetrieval]: 'knowledge-retrieval',
  41. [BlockEnum.QuestionClassifier]: 'question-classifier',
  42. [BlockEnum.IfElse]: 'ifelse',
  43. [BlockEnum.Code]: 'code',
  44. [BlockEnum.TemplateTransform]: 'template',
  45. [BlockEnum.VariableAssigner]: 'variable-assigner',
  46. [BlockEnum.VariableAggregator]: 'variable-aggregator',
  47. [BlockEnum.Assigner]: 'variable-assigner',
  48. [BlockEnum.Iteration]: 'iteration',
  49. [BlockEnum.IterationStart]: 'iteration',
  50. [BlockEnum.ParameterExtractor]: 'parameter-extractor',
  51. [BlockEnum.HttpRequest]: 'http-request',
  52. [BlockEnum.Tool]: 'tools',
  53. [BlockEnum.DocExtractor]: 'doc-extractor',
  54. [BlockEnum.ListFilter]: 'list-operator',
  55. }
  56. }, [language])
  57. return `${prefixLink}${linkMap[nodeType]}`
  58. }