Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

enums.py 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. from enum import Enum, StrEnum
  2. class NodeState(Enum):
  3. """State of a node or edge during workflow execution."""
  4. UNKNOWN = "unknown"
  5. TAKEN = "taken"
  6. SKIPPED = "skipped"
  7. class SystemVariableKey(StrEnum):
  8. """
  9. System Variables.
  10. """
  11. QUERY = "query"
  12. FILES = "files"
  13. CONVERSATION_ID = "conversation_id"
  14. USER_ID = "user_id"
  15. DIALOGUE_COUNT = "dialogue_count"
  16. APP_ID = "app_id"
  17. WORKFLOW_ID = "workflow_id"
  18. WORKFLOW_EXECUTION_ID = "workflow_run_id"
  19. # RAG Pipeline
  20. DOCUMENT_ID = "document_id"
  21. ORIGINAL_DOCUMENT_ID = "original_document_id"
  22. BATCH = "batch"
  23. DATASET_ID = "dataset_id"
  24. DATASOURCE_TYPE = "datasource_type"
  25. DATASOURCE_INFO = "datasource_info"
  26. INVOKE_FROM = "invoke_from"
  27. class NodeType(StrEnum):
  28. START = "start"
  29. END = "end"
  30. ANSWER = "answer"
  31. LLM = "llm"
  32. KNOWLEDGE_RETRIEVAL = "knowledge-retrieval"
  33. KNOWLEDGE_INDEX = "knowledge-index"
  34. IF_ELSE = "if-else"
  35. CODE = "code"
  36. TEMPLATE_TRANSFORM = "template-transform"
  37. QUESTION_CLASSIFIER = "question-classifier"
  38. HTTP_REQUEST = "http-request"
  39. TOOL = "tool"
  40. DATASOURCE = "datasource"
  41. VARIABLE_AGGREGATOR = "variable-aggregator"
  42. LEGACY_VARIABLE_AGGREGATOR = "variable-assigner" # TODO: Merge this into VARIABLE_AGGREGATOR in the database.
  43. LOOP = "loop"
  44. LOOP_START = "loop-start"
  45. LOOP_END = "loop-end"
  46. ITERATION = "iteration"
  47. ITERATION_START = "iteration-start" # Fake start node for iteration.
  48. PARAMETER_EXTRACTOR = "parameter-extractor"
  49. VARIABLE_ASSIGNER = "assigner"
  50. DOCUMENT_EXTRACTOR = "document-extractor"
  51. LIST_OPERATOR = "list-operator"
  52. AGENT = "agent"
  53. class NodeExecutionType(StrEnum):
  54. """Node execution type classification."""
  55. EXECUTABLE = "executable" # Regular nodes that execute and produce outputs
  56. RESPONSE = "response" # Response nodes that stream outputs (Answer, End)
  57. BRANCH = "branch" # Nodes that can choose different branches (if-else, question-classifier)
  58. CONTAINER = "container" # Container nodes that manage subgraphs (iteration, loop, graph)
  59. ROOT = "root" # Nodes that can serve as execution entry points
  60. class ErrorStrategy(StrEnum):
  61. FAIL_BRANCH = "fail-branch"
  62. DEFAULT_VALUE = "default-value"
  63. class FailBranchSourceHandle(StrEnum):
  64. FAILED = "fail-branch"
  65. SUCCESS = "success-branch"
  66. class WorkflowType(StrEnum):
  67. """
  68. Workflow Type Enum for domain layer
  69. """
  70. WORKFLOW = "workflow"
  71. CHAT = "chat"
  72. RAG_PIPELINE = "rag-pipeline"
  73. class WorkflowExecutionStatus(StrEnum):
  74. RUNNING = "running"
  75. SUCCEEDED = "succeeded"
  76. FAILED = "failed"
  77. STOPPED = "stopped"
  78. PARTIAL_SUCCEEDED = "partial-succeeded"
  79. class WorkflowNodeExecutionMetadataKey(StrEnum):
  80. """
  81. Node Run Metadata Key.
  82. """
  83. TOTAL_TOKENS = "total_tokens"
  84. TOTAL_PRICE = "total_price"
  85. CURRENCY = "currency"
  86. TOOL_INFO = "tool_info"
  87. AGENT_LOG = "agent_log"
  88. ITERATION_ID = "iteration_id"
  89. ITERATION_INDEX = "iteration_index"
  90. LOOP_ID = "loop_id"
  91. LOOP_INDEX = "loop_index"
  92. PARALLEL_ID = "parallel_id"
  93. PARALLEL_START_NODE_ID = "parallel_start_node_id"
  94. PARENT_PARALLEL_ID = "parent_parallel_id"
  95. PARENT_PARALLEL_START_NODE_ID = "parent_parallel_start_node_id"
  96. PARALLEL_MODE_RUN_ID = "parallel_mode_run_id"
  97. ITERATION_DURATION_MAP = "iteration_duration_map" # single iteration duration if iteration node runs
  98. LOOP_DURATION_MAP = "loop_duration_map" # single loop duration if loop node runs
  99. ERROR_STRATEGY = "error_strategy" # node in continue on error mode return the field
  100. LOOP_VARIABLE_MAP = "loop_variable_map" # single loop variable output
  101. DATASOURCE_INFO = "datasource_info"
  102. class WorkflowNodeExecutionStatus(StrEnum):
  103. PENDING = "pending" # Node is scheduled but not yet executing
  104. RUNNING = "running"
  105. SUCCEEDED = "succeeded"
  106. FAILED = "failed"
  107. EXCEPTION = "exception"
  108. STOPPED = "stopped"
  109. PAUSED = "paused"
  110. # Legacy statuses - kept for backward compatibility
  111. RETRY = "retry" # Legacy: replaced by retry mechanism in error handling