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.0KB

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