You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

default.ts 1.3KB

6 months ago
6 months ago
4 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import type { NodeDefault } from '../../types'
  2. import type { KnowledgeBaseNodeType } from './types'
  3. import { genNodeMetaData } from '@/app/components/workflow/utils'
  4. import { BlockEnum } from '@/app/components/workflow/types'
  5. const metaData = genNodeMetaData({
  6. sort: 3.1,
  7. type: BlockEnum.KnowledgeBase,
  8. })
  9. const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
  10. metaData,
  11. defaultValue: {
  12. index_chunk_variable_selector: [],
  13. keyword_number: 10,
  14. retrieval_model: {
  15. top_k: 3,
  16. score_threshold_enabled: false,
  17. score_threshold: 0.5,
  18. },
  19. },
  20. checkValid(payload, t) {
  21. const {
  22. chunk_structure,
  23. indexing_technique,
  24. retrieval_model,
  25. } = payload
  26. if (!chunk_structure) {
  27. return {
  28. isValid: false,
  29. errorMessage: t('workflow.nodes.knowledgeBase.chunkIsRequired'),
  30. }
  31. }
  32. if (!indexing_technique) {
  33. return {
  34. isValid: false,
  35. errorMessage: t('workflow.nodes.knowledgeBase.indexMethodIsRequired'),
  36. }
  37. }
  38. if (!retrieval_model || !retrieval_model.search_method) {
  39. return {
  40. isValid: false,
  41. errorMessage: t('workflow.nodes.knowledgeBase.retrievalSettingIsRequired'),
  42. }
  43. }
  44. return {
  45. isValid: true,
  46. errorMessage: '',
  47. }
  48. },
  49. }
  50. export default nodeDefault