graphon 0.2.2__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. {graphon-0.2.2 → graphon-0.3.1}/PKG-INFO +8 -5
  2. {graphon-0.2.2 → graphon-0.3.1}/README.md +7 -4
  3. {graphon-0.2.2 → graphon-0.3.1}/pyproject.toml +2 -1
  4. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/file_manager.py +31 -8
  5. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/models.py +33 -5
  6. graphon-0.3.1/src/graphon/file/runtime.py +63 -0
  7. graphon-0.3.1/src/graphon/file/tool_file_parser.py +59 -0
  8. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph/graph.py +6 -0
  9. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/error_handler.py +3 -1
  10. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/event_management/event_handlers.py +9 -10
  11. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/graph_engine.py +2 -4
  12. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/graph_traversal/edge_processor.py +3 -5
  13. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/layers/execution_limits.py +2 -3
  14. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/orchestration/dispatcher.py +3 -5
  15. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/ready_queue/factory.py +1 -5
  16. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/response_coordinator/coordinator.py +8 -7
  17. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/http/__init__.py +5 -1
  18. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/http/response.py +23 -4
  19. graphon-0.3.1/src/graphon/http/runtime.py +20 -0
  20. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/README.md +26 -8
  21. graphon-0.3.1/src/graphon/model_runtime/__init__.py +21 -0
  22. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/llm_entities.py +61 -30
  23. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/ai_model.py +5 -5
  24. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/large_language_model.py +2 -1
  25. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/moderation_model.py +4 -1
  26. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/rerank_model.py +2 -1
  27. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/speech2text_model.py +4 -1
  28. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/text_embedding_model.py +16 -6
  29. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/tokenizers/gpt2_tokenizer.py +0 -7
  30. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/base/tts_model.py +2 -1
  31. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/model_provider_factory.py +11 -49
  32. graphon-0.3.1/src/graphon/model_runtime/protocols/__init__.py +25 -0
  33. graphon-0.3.1/src/graphon/model_runtime/protocols/llm_runtime.py +118 -0
  34. graphon-0.3.1/src/graphon/model_runtime/protocols/moderation_runtime.py +19 -0
  35. graphon-0.3.1/src/graphon/model_runtime/protocols/provider_runtime.py +47 -0
  36. graphon-0.3.1/src/graphon/model_runtime/protocols/rerank_runtime.py +38 -0
  37. graphon-0.3.1/src/graphon/model_runtime/protocols/runtime.py +29 -0
  38. graphon-0.3.1/src/graphon/model_runtime/protocols/speech_to_text_runtime.py +19 -0
  39. graphon-0.3.1/src/graphon/model_runtime/protocols/text_embedding_runtime.py +43 -0
  40. graphon-0.3.1/src/graphon/model_runtime/protocols/tts_runtime.py +30 -0
  41. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/slim/prepared_llm.py +16 -28
  42. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/slim/runtime.py +443 -59
  43. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/utils/encoders.py +1 -1
  44. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/node.py +48 -17
  45. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/code/code_node.py +79 -42
  46. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/document_extractor/node.py +231 -100
  47. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/__init__.py +2 -1
  48. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/executor.py +5 -2
  49. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/node.py +91 -18
  50. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/human_input/entities.py +27 -8
  51. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/human_input/human_input_node.py +27 -27
  52. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/iteration/iteration_node.py +9 -3
  53. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/file_saver.py +20 -1
  54. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/llm_utils.py +15 -2
  55. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/node.py +25 -11
  56. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/loop/loop_node.py +65 -50
  57. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/parameter_extractor/parameter_extractor_node.py +136 -27
  58. graphon-0.3.1/src/graphon/nodes/question_classifier/__init__.py +11 -0
  59. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/question_classifier/entities.py +17 -2
  60. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/question_classifier/question_classifier_node.py +141 -34
  61. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/runtime.py +48 -0
  62. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/template_transform/template_transform_node.py +21 -20
  63. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/tool/tool_node.py +41 -23
  64. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v1/node.py +34 -15
  65. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/helpers.py +3 -1
  66. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/node.py +15 -19
  67. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/protocols/__init__.py +21 -1
  68. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/runtime/graph_runtime_state.py +14 -15
  69. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/runtime/variable_pool.py +88 -47
  70. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/utils/condition/processor.py +31 -20
  71. graphon-0.3.1/src/graphon/variables/factory.py +441 -0
  72. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/types.py +27 -25
  73. graphon-0.2.2/src/graphon/file/runtime.py +0 -110
  74. graphon-0.2.2/src/graphon/file/tool_file_parser.py +0 -9
  75. graphon-0.2.2/src/graphon/http/runtime.py +0 -17
  76. graphon-0.2.2/src/graphon/model_runtime/README_CN.md +0 -64
  77. graphon-0.2.2/src/graphon/model_runtime/runtime.py +0 -179
  78. graphon-0.2.2/src/graphon/nodes/question_classifier/__init__.py +0 -4
  79. graphon-0.2.2/src/graphon/utils/condition/__init__.py +0 -0
  80. graphon-0.2.2/src/graphon/variables/factory.py +0 -274
  81. {graphon-0.2.2 → graphon-0.3.1}/LICENSE +0 -0
  82. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/__init__.py +0 -0
  83. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/__init__.py +0 -0
  84. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/base_node_data.py +0 -0
  85. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/exc.py +0 -0
  86. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/graph_config.py +0 -0
  87. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/graph_init_params.py +0 -0
  88. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/pause_reason.py +0 -0
  89. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/workflow_execution.py +0 -0
  90. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/workflow_node_execution.py +0 -0
  91. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/entities/workflow_start_reason.py +0 -0
  92. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/enums.py +0 -0
  93. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/errors.py +0 -0
  94. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/__init__.py +0 -0
  95. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/constants.py +0 -0
  96. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/enums.py +0 -0
  97. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/file_factory.py +0 -0
  98. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/helpers.py +0 -0
  99. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/file/protocols.py +0 -0
  100. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph/__init__.py +0 -0
  101. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph/edge.py +0 -0
  102. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph/graph_template.py +0 -0
  103. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph/validation.py +0 -0
  104. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/__init__.py +0 -0
  105. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/_engine_utils.py +0 -0
  106. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_channels/README.md +0 -0
  107. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_channels/__init__.py +0 -0
  108. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_channels/in_memory_channel.py +0 -0
  109. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_channels/protocol.py +0 -0
  110. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_channels/redis_channel.py +0 -0
  111. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_processing/__init__.py +0 -0
  112. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_processing/command_handlers.py +0 -0
  113. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/command_processing/command_processor.py +0 -0
  114. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/config.py +0 -0
  115. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/domain/__init__.py +0 -0
  116. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/domain/graph_execution.py +0 -0
  117. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/domain/node_execution.py +0 -0
  118. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/entities/__init__.py +0 -0
  119. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/entities/commands.py +0 -0
  120. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/event_management/__init__.py +0 -0
  121. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/event_management/event_manager.py +0 -0
  122. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/graph_state_manager.py +0 -0
  123. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/graph_traversal/__init__.py +0 -0
  124. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/graph_traversal/skip_propagator.py +0 -0
  125. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/layers/README.md +0 -0
  126. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/layers/__init__.py +0 -0
  127. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/layers/base.py +0 -0
  128. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/layers/debug_logging.py +0 -0
  129. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/manager.py +0 -0
  130. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/orchestration/__init__.py +0 -0
  131. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/orchestration/execution_coordinator.py +0 -0
  132. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/ready_queue/__init__.py +0 -0
  133. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/ready_queue/in_memory.py +0 -0
  134. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/ready_queue/protocol.py +0 -0
  135. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/response_coordinator/__init__.py +0 -0
  136. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/response_coordinator/path.py +0 -0
  137. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/response_coordinator/session.py +0 -0
  138. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/worker.py +0 -0
  139. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/worker_management/__init__.py +0 -0
  140. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_engine/worker_management/worker_pool.py +0 -0
  141. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/__init__.py +0 -0
  142. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/agent.py +0 -0
  143. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/base.py +0 -0
  144. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/graph.py +0 -0
  145. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/human_input.py +0 -0
  146. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/iteration.py +0 -0
  147. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/loop.py +0 -0
  148. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/graph_events/node.py +0 -0
  149. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/http/client.py +0 -0
  150. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/http/protocols.py +0 -0
  151. {graphon-0.2.2/src/graphon/model_runtime → graphon-0.3.1/src/graphon/model_runtime/callbacks}/__init__.py +0 -0
  152. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/callbacks/base_callback.py +0 -0
  153. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/callbacks/logging_callback.py +0 -0
  154. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/__init__.py +0 -0
  155. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/common_entities.py +0 -0
  156. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/defaults.py +0 -0
  157. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/message_entities.py +0 -0
  158. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/model_entities.py +0 -0
  159. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/provider_entities.py +0 -0
  160. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/rerank_entities.py +0 -0
  161. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/entities/text_embedding_entities.py +0 -0
  162. {graphon-0.2.2/src/graphon/model_runtime/callbacks → graphon-0.3.1/src/graphon/model_runtime/errors}/__init__.py +0 -0
  163. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/errors/invoke.py +0 -0
  164. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/errors/validate.py +0 -0
  165. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/memory/__init__.py +0 -0
  166. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/memory/prompt_message_memory.py +0 -0
  167. {graphon-0.2.2/src/graphon/model_runtime/errors → graphon-0.3.1/src/graphon/model_runtime/model_providers}/__init__.py +0 -0
  168. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/model_providers/_position.yaml +0 -0
  169. {graphon-0.2.2/src/graphon/model_runtime/model_providers → graphon-0.3.1/src/graphon/model_runtime/model_providers/base}/__init__.py +0 -0
  170. {graphon-0.2.2/src/graphon/model_runtime/model_providers/base → graphon-0.3.1/src/graphon/model_runtime/model_providers/base/tokenizers}/__init__.py +0 -0
  171. {graphon-0.2.2/src/graphon/model_runtime/model_providers/base/tokenizers → graphon-0.3.1/src/graphon/model_runtime/schema_validators}/__init__.py +0 -0
  172. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/schema_validators/common_validator.py +0 -0
  173. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/schema_validators/model_credential_schema_validator.py +0 -0
  174. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/schema_validators/provider_credential_schema_validator.py +0 -0
  175. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/slim/__init__.py +0 -0
  176. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/slim/config.py +0 -0
  177. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/model_runtime/slim/package_loader.py +0 -0
  178. {graphon-0.2.2/src/graphon/model_runtime/schema_validators → graphon-0.3.1/src/graphon/model_runtime/utils}/__init__.py +0 -0
  179. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/__init__.py +0 -0
  180. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/agent.py +0 -0
  181. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/base.py +0 -0
  182. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/iteration.py +0 -0
  183. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/loop.py +0 -0
  184. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/node_events/node.py +0 -0
  185. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/__init__.py +0 -0
  186. {graphon-0.2.2/src/graphon/model_runtime/utils → graphon-0.3.1/src/graphon/nodes/answer}/__init__.py +0 -0
  187. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/answer/answer_node.py +0 -0
  188. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/answer/entities.py +0 -0
  189. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/__init__.py +0 -0
  190. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/entities.py +0 -0
  191. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/template.py +0 -0
  192. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/usage_tracking_mixin.py +0 -0
  193. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/base/variable_template_parser.py +0 -0
  194. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/code/__init__.py +0 -0
  195. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/code/entities.py +0 -0
  196. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/code/exc.py +0 -0
  197. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/code/limits.py +0 -0
  198. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/document_extractor/__init__.py +0 -0
  199. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/document_extractor/entities.py +0 -0
  200. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/document_extractor/exc.py +0 -0
  201. {graphon-0.2.2/src/graphon/nodes/answer → graphon-0.3.1/src/graphon/nodes/end}/__init__.py +0 -0
  202. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/end/end_node.py +0 -0
  203. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/end/entities.py +0 -0
  204. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/config.py +0 -0
  205. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/entities.py +0 -0
  206. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/http_request/exc.py +0 -0
  207. {graphon-0.2.2/src/graphon/nodes/end → graphon-0.3.1/src/graphon/nodes/human_input}/__init__.py +0 -0
  208. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/human_input/enums.py +0 -0
  209. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/if_else/__init__.py +0 -0
  210. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/if_else/entities.py +0 -0
  211. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/if_else/if_else_node.py +0 -0
  212. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/iteration/__init__.py +0 -0
  213. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/iteration/entities.py +0 -0
  214. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/iteration/exc.py +0 -0
  215. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/iteration/iteration_start_node.py +0 -0
  216. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/list_operator/__init__.py +0 -0
  217. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/list_operator/entities.py +0 -0
  218. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/list_operator/exc.py +0 -0
  219. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/list_operator/node.py +0 -0
  220. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/__init__.py +0 -0
  221. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/entities.py +0 -0
  222. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/exc.py +0 -0
  223. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/protocols.py +0 -0
  224. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/llm/runtime_protocols.py +0 -0
  225. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/loop/__init__.py +0 -0
  226. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/loop/entities.py +0 -0
  227. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/loop/loop_end_node.py +0 -0
  228. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/loop/loop_start_node.py +0 -0
  229. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/parameter_extractor/__init__.py +0 -0
  230. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/parameter_extractor/entities.py +0 -0
  231. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/parameter_extractor/exc.py +0 -0
  232. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/parameter_extractor/prompts.py +0 -0
  233. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/protocols.py +0 -0
  234. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/question_classifier/exc.py +0 -0
  235. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/question_classifier/template_prompts.py +0 -0
  236. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/start/__init__.py +0 -0
  237. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/start/entities.py +0 -0
  238. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/start/start_node.py +0 -0
  239. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/template_transform/__init__.py +0 -0
  240. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/template_transform/entities.py +0 -0
  241. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/tool/__init__.py +0 -0
  242. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/tool/entities.py +0 -0
  243. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/tool/exc.py +0 -0
  244. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/tool_runtime_entities.py +0 -0
  245. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_aggregator/__init__.py +0 -0
  246. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_aggregator/entities.py +0 -0
  247. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_aggregator/variable_aggregator_node.py +0 -0
  248. {graphon-0.2.2/src/graphon/nodes/human_input → graphon-0.3.1/src/graphon/nodes/variable_assigner}/__init__.py +0 -0
  249. {graphon-0.2.2/src/graphon/nodes/variable_assigner → graphon-0.3.1/src/graphon/nodes/variable_assigner/common}/__init__.py +0 -0
  250. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/common/exc.py +0 -0
  251. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/common/helpers.py +0 -0
  252. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v1/__init__.py +0 -0
  253. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v1/node_data.py +0 -0
  254. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/__init__.py +0 -0
  255. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/entities.py +0 -0
  256. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/enums.py +0 -0
  257. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/nodes/variable_assigner/v2/exc.py +0 -0
  258. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/prompt_entities.py +0 -0
  259. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/py.typed +0 -0
  260. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/runtime/__init__.py +0 -0
  261. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/runtime/graph_runtime_state_protocol.py +0 -0
  262. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/runtime/read_only_wrappers.py +0 -0
  263. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/template_rendering.py +0 -0
  264. {graphon-0.2.2/src/graphon/nodes/variable_assigner/common → graphon-0.3.1/src/graphon/utils}/__init__.py +0 -0
  265. {graphon-0.2.2/src/graphon/utils → graphon-0.3.1/src/graphon/utils/condition}/__init__.py +0 -0
  266. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/utils/condition/entities.py +0 -0
  267. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/utils/json_in_md_parser.py +0 -0
  268. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variable_loader.py +0 -0
  269. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/__init__.py +0 -0
  270. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/consts.py +0 -0
  271. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/exc.py +0 -0
  272. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/input_entities.py +0 -0
  273. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/segment_group.py +0 -0
  274. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/segments.py +0 -0
  275. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/utils.py +0 -0
  276. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/variables/variables.py +0 -0
  277. {graphon-0.2.2 → graphon-0.3.1}/src/graphon/workflow_type_encoder.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphon
3
- Version: 0.2.2
3
+ Version: 0.3.1
4
4
  Summary: Graph execution engine for agentic AI workflows.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -73,7 +73,9 @@ make test
73
73
  ```
74
74
 
75
75
  `make dev` installs the project, syncs development dependencies, and sets up
76
- [`prek`](https://prek.j178.dev/) Git hooks.
76
+ [`prek`](https://prek.j178.dev/) Git hooks. `make test` is the progressive
77
+ local validation entrypoint: it formats, applies lint fixes, runs `ty check`,
78
+ and then runs `pytest`.
77
79
 
78
80
  ## Run the Example Workflow
79
81
 
@@ -169,9 +171,10 @@ construction, input seeding, and streamed output handling.
169
171
  Contributor setup, tooling details, CLA notes, and commit/PR conventions live
170
172
  in [CONTRIBUTING.md](CONTRIBUTING.md).
171
173
 
172
- CI currently validates commit messages, pull request titles, formatting, lint,
173
- and tests on Python 3.12 and 3.13. Python 3.14 is currently excluded because
174
- `unstructured` does not yet support it.
174
+ CI currently validates pull request titles, runs `make check` including
175
+ `uv.lock` freshness validation, and runs `uv run pytest` on Python 3.12 and
176
+ 3.13. Python 3.14 is currently excluded because `unstructured` does not yet
177
+ support it.
175
178
 
176
179
  ## License
177
180
 
@@ -44,7 +44,9 @@ make test
44
44
  ```
45
45
 
46
46
  `make dev` installs the project, syncs development dependencies, and sets up
47
- [`prek`](https://prek.j178.dev/) Git hooks.
47
+ [`prek`](https://prek.j178.dev/) Git hooks. `make test` is the progressive
48
+ local validation entrypoint: it formats, applies lint fixes, runs `ty check`,
49
+ and then runs `pytest`.
48
50
 
49
51
  ## Run the Example Workflow
50
52
 
@@ -140,9 +142,10 @@ construction, input seeding, and streamed output handling.
140
142
  Contributor setup, tooling details, CLA notes, and commit/PR conventions live
141
143
  in [CONTRIBUTING.md](CONTRIBUTING.md).
142
144
 
143
- CI currently validates commit messages, pull request titles, formatting, lint,
144
- and tests on Python 3.12 and 3.13. Python 3.14 is currently excluded because
145
- `unstructured` does not yet support it.
145
+ CI currently validates pull request titles, runs `make check` including
146
+ `uv.lock` freshness validation, and runs `uv run pytest` on Python 3.12 and
147
+ 3.13. Python 3.14 is currently excluded because `unstructured` does not yet
148
+ support it.
146
149
 
147
150
  ## License
148
151
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = 'graphon'
3
- version = "0.2.2"
3
+ version = "0.3.1"
4
4
  description = 'Graph execution engine for agentic AI workflows.'
5
5
  readme = 'README.md'
6
6
  license = 'Apache-2.0'
@@ -79,6 +79,7 @@ ignore-one-line-docstrings = true
79
79
  'tests/**/*.py' = [
80
80
  'S101', # Assert statements used for pytest.
81
81
  'PLR2004', # Magic value used in test cases.
82
+ 'PLC2701', # Allow import private members from graphon module.
82
83
  ]
83
84
 
84
85
  [tool.ty.environment]
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import base64
4
4
  from collections.abc import Callable, Mapping
5
- from operator import attrgetter
5
+ from typing import assert_never
6
6
 
7
7
  from graphon.model_runtime.entities.message_entities import (
8
8
  AudioPromptMessageContent,
@@ -40,15 +40,35 @@ def _get_file_transfer_method_value(file: File) -> str:
40
40
  return file.transfer_method.value
41
41
 
42
42
 
43
- _FILE_ATTRIBUTE_GETTERS: Mapping[FileAttribute, Callable[[File], object]] = {
43
+ def _get_file_size(file: File) -> int:
44
+ return file.size
45
+
46
+
47
+ def _get_file_name(file: File) -> str | None:
48
+ return file.filename
49
+
50
+
51
+ def _get_file_mime_type(file: File) -> str | None:
52
+ return file.mime_type
53
+
54
+
55
+ def _get_file_extension(file: File) -> str | None:
56
+ return file.extension
57
+
58
+
59
+ def _get_file_related_id(file: File) -> str | None:
60
+ return file.related_id
61
+
62
+
63
+ _FILE_ATTRIBUTE_GETTERS: Mapping[FileAttribute, Callable[[File], str | int | None]] = {
44
64
  FileAttribute.TYPE: _get_file_type_value,
45
- FileAttribute.SIZE: attrgetter("size"),
46
- FileAttribute.NAME: attrgetter("filename"),
47
- FileAttribute.MIME_TYPE: attrgetter("mime_type"),
65
+ FileAttribute.SIZE: _get_file_size,
66
+ FileAttribute.NAME: _get_file_name,
67
+ FileAttribute.MIME_TYPE: _get_file_mime_type,
48
68
  FileAttribute.TRANSFER_METHOD: _get_file_transfer_method_value,
49
69
  FileAttribute.URL: _to_url,
50
- FileAttribute.EXTENSION: attrgetter("extension"),
51
- FileAttribute.RELATED_ID: attrgetter("related_id"),
70
+ FileAttribute.EXTENSION: _get_file_extension,
71
+ FileAttribute.RELATED_ID: _get_file_related_id,
52
72
  }
53
73
  _PROMPT_CONTENT_CLASS_BY_FILE_TYPE: Mapping[
54
74
  FileType,
@@ -121,7 +141,8 @@ def _download_file_content(file: File, /) -> bytes:
121
141
 
122
142
 
123
143
  def _get_encoded_string(f: File, /) -> str:
124
- match f.transfer_method:
144
+ transfer_method = f.transfer_method
145
+ match transfer_method:
125
146
  case FileTransferMethod.REMOTE_URL:
126
147
  if f.remote_url is None:
127
148
  msg = "Missing file remote_url"
@@ -138,6 +159,8 @@ def _get_encoded_string(f: File, /) -> str:
138
159
  data = _download_file_content(f)
139
160
  case FileTransferMethod.DATASOURCE_FILE:
140
161
  data = _download_file_content(f)
162
+ case _:
163
+ assert_never(transfer_method)
141
164
 
142
165
  return base64.b64encode(data).decode("utf-8")
143
166
 
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import base64
4
4
  import json
5
5
  from collections.abc import Mapping, Sequence
6
- from typing import Any
6
+ from typing import Any, assert_never
7
7
 
8
8
  from pydantic import BaseModel, Field, model_validator
9
9
 
@@ -16,6 +16,10 @@ from .enums import FileTransferMethod, FileType
16
16
  _FILE_REFERENCE_PREFIX = "dify-file-ref:"
17
17
 
18
18
 
19
+ class _FileConstructorConflictError(Exception):
20
+ """Raised when multiple constructor inputs disagree on file identity."""
21
+
22
+
19
23
  def sign_tool_file(
20
24
  *,
21
25
  tool_file_id: str,
@@ -113,7 +117,7 @@ class File(BaseModel):
113
117
  *,
114
118
  file_id: str | None = None,
115
119
  tenant_id: str | None = None,
116
- file_type: FileType,
120
+ file_type: FileType | None = None,
117
121
  transfer_method: FileTransferMethod,
118
122
  remote_url: str | None = None,
119
123
  reference: str | None = None,
@@ -129,18 +133,39 @@ class File(BaseModel):
129
133
  tool_file_id: str | None = None,
130
134
  upload_file_id: str | None = None,
131
135
  datasource_file_id: str | None = None,
136
+ **legacy_kwargs: Any,
132
137
  ) -> None:
138
+ legacy_id = legacy_kwargs.pop("id", None)
139
+ legacy_type = legacy_kwargs.pop("type", None)
140
+ if legacy_kwargs:
141
+ unexpected_keys = ", ".join(sorted(legacy_kwargs))
142
+ msg = f"Unexpected keyword arguments: {unexpected_keys}"
143
+ raise TypeError(msg)
144
+
133
145
  legacy_record_id = (
134
146
  related_id or tool_file_id or upload_file_id or datasource_file_id
135
147
  )
148
+ if legacy_id is not None and file_id is not None and legacy_id != file_id:
149
+ msg = "Conflicting file identifiers"
150
+ raise _FileConstructorConflictError(msg)
151
+ if (
152
+ legacy_type is not None
153
+ and file_type is not None
154
+ and legacy_type != file_type
155
+ ):
156
+ msg = "Conflicting file types"
157
+ raise _FileConstructorConflictError(msg)
158
+
136
159
  normalized_reference = reference
137
160
  if normalized_reference is None and legacy_record_id is not None:
138
161
  normalized_reference = str(legacy_record_id)
139
162
  _, parsed_storage_key = _parse_reference(normalized_reference)
163
+ normalized_file_id = file_id if file_id is not None else legacy_id
164
+ normalized_file_type = file_type if file_type is not None else legacy_type
140
165
 
141
166
  super().__init__(
142
- id=file_id,
143
- type=file_type,
167
+ id=normalized_file_id,
168
+ type=normalized_file_type,
144
169
  transfer_method=transfer_method,
145
170
  remote_url=remote_url,
146
171
  reference=normalized_reference,
@@ -190,7 +215,8 @@ class File(BaseModel):
190
215
 
191
216
  @model_validator(mode="after")
192
217
  def validate_after(self) -> File:
193
- match self.transfer_method:
218
+ transfer_method = self.transfer_method
219
+ match transfer_method:
194
220
  case FileTransferMethod.REMOTE_URL:
195
221
  if not self.remote_url:
196
222
  msg = "Missing file url"
@@ -213,6 +239,8 @@ class File(BaseModel):
213
239
  if not self.reference:
214
240
  msg = "Missing file reference"
215
241
  raise ValueError(msg)
242
+ case _:
243
+ assert_never(transfer_method)
216
244
  return self
217
245
 
218
246
  @property
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ from .protocols import WorkflowFileRuntimeProtocol
4
+
5
+
6
+ class WorkflowFileRuntimeNotConfiguredError(RuntimeError):
7
+ """Raised when workflow file runtime dependencies were not configured."""
8
+
9
+
10
+ def _not_configured_error() -> WorkflowFileRuntimeNotConfiguredError:
11
+ msg = (
12
+ "workflow file runtime is not configured; call "
13
+ "set_workflow_file_runtime(...) first"
14
+ )
15
+ return WorkflowFileRuntimeNotConfiguredError(msg)
16
+
17
+
18
+ class WorkflowFileRuntimeRegistry:
19
+ """Small helper that keeps runtime configuration explicit."""
20
+
21
+ def __init__(
22
+ self,
23
+ runtime: WorkflowFileRuntimeProtocol | None = None,
24
+ ) -> None:
25
+ self._runtime = runtime
26
+
27
+ def set(
28
+ self,
29
+ runtime: WorkflowFileRuntimeProtocol,
30
+ ) -> WorkflowFileRuntimeProtocol:
31
+ self._runtime = runtime
32
+ return runtime
33
+
34
+ def peek(self) -> WorkflowFileRuntimeProtocol | None:
35
+ return self._runtime
36
+
37
+ def get(self) -> WorkflowFileRuntimeProtocol:
38
+ runtime = self.peek()
39
+ if runtime is None:
40
+ raise _not_configured_error()
41
+ return runtime
42
+
43
+
44
+ _workflow_file_runtime_registry = WorkflowFileRuntimeRegistry()
45
+
46
+
47
+ def configure_workflow_file_runtime(
48
+ runtime: WorkflowFileRuntimeProtocol,
49
+ ) -> WorkflowFileRuntimeProtocol:
50
+ """Compatibility alias for set_workflow_file_runtime()."""
51
+ return _workflow_file_runtime_registry.set(runtime)
52
+
53
+
54
+ def set_workflow_file_runtime(runtime: WorkflowFileRuntimeProtocol) -> None:
55
+ _workflow_file_runtime_registry.set(runtime)
56
+
57
+
58
+ def get_workflow_file_runtime() -> WorkflowFileRuntimeProtocol:
59
+ return _workflow_file_runtime_registry.get()
60
+
61
+
62
+ def peek_workflow_file_runtime() -> WorkflowFileRuntimeProtocol | None:
63
+ return _workflow_file_runtime_registry.peek()
@@ -0,0 +1,59 @@
1
+ from collections.abc import Callable
2
+ from typing import Any
3
+
4
+ ToolFileManagerFactory = Callable[[], Any]
5
+
6
+
7
+ class ToolFileManagerFactoryNotSetError(RuntimeError):
8
+ """Raised when code requires a configured tool file manager factory."""
9
+
10
+ def __init__(self) -> None:
11
+ super().__init__(
12
+ "Tool file manager factory is not configured. "
13
+ "Call set_tool_file_manager_factory(...)."
14
+ )
15
+
16
+
17
+ class _ToolFileManagerFactoryRegistry:
18
+ """Store the active tool file manager factory behind an explicit API."""
19
+
20
+ def __init__(self) -> None:
21
+ self._factory: ToolFileManagerFactory | None = None
22
+
23
+ def get(self) -> ToolFileManagerFactory | None:
24
+ return self._factory
25
+
26
+ def require(self) -> ToolFileManagerFactory:
27
+ factory = self.get()
28
+ if factory is None:
29
+ raise ToolFileManagerFactoryNotSetError
30
+ return factory
31
+
32
+ def set(self, factory: ToolFileManagerFactory) -> None:
33
+ self._factory = factory
34
+
35
+
36
+ _tool_file_manager_factory_registry = _ToolFileManagerFactoryRegistry()
37
+
38
+
39
+ def get_tool_file_manager_factory() -> ToolFileManagerFactory | None:
40
+ return _tool_file_manager_factory_registry.get()
41
+
42
+
43
+ def require_tool_file_manager_factory() -> ToolFileManagerFactory:
44
+ return _tool_file_manager_factory_registry.require()
45
+
46
+
47
+ def set_tool_file_manager_factory(factory: ToolFileManagerFactory) -> None:
48
+ """Compatibility wrapper around the registry's explicit setter."""
49
+
50
+ _tool_file_manager_factory_registry.set(factory)
51
+
52
+
53
+ __all__ = [
54
+ "ToolFileManagerFactory",
55
+ "ToolFileManagerFactoryNotSetError",
56
+ "get_tool_file_manager_factory",
57
+ "require_tool_file_manager_factory",
58
+ "set_tool_file_manager_factory",
59
+ ]
@@ -44,6 +44,12 @@ class NodeFactory(Protocol):
44
44
  class Graph:
45
45
  """Graph representation with nodes and edges for workflow execution."""
46
46
 
47
+ nodes: dict[str, Node]
48
+ edges: dict[str, Edge]
49
+ in_edges: dict[str, list[str]]
50
+ out_edges: dict[str, list[str]]
51
+ root_node: Node
52
+
47
53
  def __init__(
48
54
  self,
49
55
  *,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import logging
4
4
  import time
5
- from typing import final
5
+ from typing import assert_never, final
6
6
 
7
7
  from graphon.enums import (
8
8
  ErrorStrategy as ErrorStrategyEnum,
@@ -88,6 +88,8 @@ class ErrorHandler:
88
88
  return self._handle_fail_branch(event)
89
89
  case ErrorStrategyEnum.DEFAULT_VALUE:
90
90
  return self._handle_default_value(event)
91
+ case _:
92
+ assert_never(strategy)
91
93
 
92
94
  def _handle_abort(self, event: NodeRunFailedEvent) -> None:
93
95
  """Handle error by aborting execution.
@@ -3,7 +3,7 @@
3
3
  import logging
4
4
  from collections.abc import Mapping
5
5
  from functools import singledispatchmethod
6
- from typing import TYPE_CHECKING, final
6
+ from typing import final
7
7
 
8
8
  from graphon.enums import ErrorStrategy, NodeExecutionType, NodeState
9
9
  from graphon.graph.graph import Graph
@@ -39,11 +39,10 @@ from graphon.runtime.graph_runtime_state import (
39
39
  ResponseStreamCoordinatorProtocol,
40
40
  )
41
41
 
42
- if TYPE_CHECKING:
43
- from ..error_handler import ErrorHandler
44
- from ..graph_state_manager import GraphStateManager
45
- from ..graph_traversal import EdgeProcessor
46
- from .event_manager import EventManager
42
+ from ..error_handler import ErrorHandler
43
+ from ..graph_state_manager import GraphStateManager
44
+ from ..graph_traversal.edge_processor import EdgeProcessor
45
+ from .event_manager import EventManager
47
46
 
48
47
  logger = logging.getLogger(__name__)
49
48
 
@@ -62,10 +61,10 @@ class EventHandler:
62
61
  graph_runtime_state: GraphRuntimeState,
63
62
  graph_execution: GraphExecutionProtocol,
64
63
  response_coordinator: ResponseStreamCoordinatorProtocol,
65
- event_collector: "EventManager",
66
- edge_processor: "EdgeProcessor",
67
- state_manager: "GraphStateManager",
68
- error_handler: "ErrorHandler",
64
+ event_collector: EventManager,
65
+ edge_processor: EdgeProcessor,
66
+ state_manager: GraphStateManager,
67
+ error_handler: ErrorHandler,
69
68
  ) -> None:
70
69
  """Initialize the event handler registry.
71
70
 
@@ -9,8 +9,9 @@ from __future__ import annotations
9
9
  import logging
10
10
  import queue
11
11
  from collections.abc import Generator
12
- from typing import TYPE_CHECKING, final
12
+ from typing import final
13
13
 
14
+ from graphon.entities.graph_init_params import GraphInitParams
14
15
  from graphon.entities.workflow_start_reason import WorkflowStartReason
15
16
  from graphon.enums import NodeExecutionType
16
17
  from graphon.graph.graph import Graph
@@ -50,9 +51,6 @@ from .layers.base import GraphEngineLayer
50
51
  from .orchestration import Dispatcher, ExecutionCoordinator
51
52
  from .worker_management import WorkerPool
52
53
 
53
- if TYPE_CHECKING:
54
- from graphon.entities.graph_init_params import GraphInitParams
55
-
56
54
  logger = logging.getLogger(__name__)
57
55
 
58
56
 
@@ -1,7 +1,7 @@
1
1
  """Edge processing logic for graph traversal."""
2
2
 
3
3
  from collections.abc import Sequence
4
- from typing import TYPE_CHECKING, final
4
+ from typing import final
5
5
 
6
6
  from graphon.enums import NodeExecutionType
7
7
  from graphon.graph.edge import Edge
@@ -10,9 +10,7 @@ from graphon.graph_events.node import NodeRunStreamChunkEvent
10
10
  from graphon.runtime.graph_runtime_state import ResponseStreamCoordinatorProtocol
11
11
 
12
12
  from ..graph_state_manager import GraphStateManager
13
-
14
- if TYPE_CHECKING:
15
- from .skip_propagator import SkipPropagator
13
+ from .skip_propagator import SkipPropagator
16
14
 
17
15
 
18
16
  @final
@@ -29,7 +27,7 @@ class EdgeProcessor:
29
27
  graph: Graph,
30
28
  state_manager: GraphStateManager,
31
29
  response_coordinator: ResponseStreamCoordinatorProtocol,
32
- skip_propagator: "SkipPropagator",
30
+ skip_propagator: SkipPropagator,
33
31
  ) -> None:
34
32
  """Initialize the edge processor.
35
33
 
@@ -10,7 +10,7 @@ When limits are exceeded, the layer automatically aborts execution.
10
10
  import logging
11
11
  import time
12
12
  from enum import StrEnum
13
- from typing import final, override
13
+ from typing import assert_never, final, override
14
14
 
15
15
  from graphon.graph_engine.entities.commands import AbortCommand, CommandType
16
16
  from graphon.graph_engine.layers.base import GraphEngineLayer
@@ -170,5 +170,4 @@ class ExecutionLimitsLayer(GraphEngineLayer):
170
170
  f"{elapsed_time:.2f}s > {self.max_time}s"
171
171
  )
172
172
  case _:
173
- msg = f"Unsupported limit type: {limit_type}"
174
- raise ValueError(msg)
173
+ assert_never(limit_type)
@@ -4,7 +4,7 @@ import logging
4
4
  import queue
5
5
  import threading
6
6
  import time
7
- from typing import TYPE_CHECKING, final
7
+ from typing import final
8
8
 
9
9
  from graphon.graph_events.base import GraphNodeEventBase
10
10
  from graphon.graph_events.node import (
@@ -14,11 +14,9 @@ from graphon.graph_events.node import (
14
14
  )
15
15
 
16
16
  from ..event_management import EventManager
17
+ from ..event_management.event_handlers import EventHandler
17
18
  from .execution_coordinator import ExecutionCoordinator
18
19
 
19
- if TYPE_CHECKING:
20
- from ..event_management import EventHandler
21
-
22
20
  logger = logging.getLogger(__name__)
23
21
 
24
22
 
@@ -39,7 +37,7 @@ class Dispatcher:
39
37
  def __init__(
40
38
  self,
41
39
  event_queue: queue.Queue[GraphNodeEventBase],
42
- event_handler: "EventHandler",
40
+ event_handler: EventHandler,
43
41
  execution_coordinator: ExecutionCoordinator,
44
42
  event_emitter: EventManager | None = None,
45
43
  ) -> None:
@@ -3,13 +3,9 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from collections.abc import Callable
6
- from typing import TYPE_CHECKING
7
6
 
8
7
  from .in_memory import InMemoryReadyQueue
9
- from .protocol import ReadyQueueState
10
-
11
- if TYPE_CHECKING:
12
- from .protocol import ReadyQueue
8
+ from .protocol import ReadyQueue, ReadyQueueState
13
9
 
14
10
  _READY_QUEUE_BUILDERS: dict[str, tuple[Callable[[], ReadyQueue], str]] = {
15
11
  "InMemoryReadyQueue": (InMemoryReadyQueue, "1.0"),
@@ -1,14 +1,10 @@
1
- """Main ResponseStreamCoordinator implementation.
2
-
3
- This module contains the public ResponseStreamCoordinator class that manages
4
- response streaming sessions and ensures ordered streaming of responses.
5
- """
1
+ from __future__ import annotations
6
2
 
7
3
  import logging
8
4
  from collections import deque
9
5
  from collections.abc import Sequence
10
6
  from threading import RLock
11
- from typing import Literal, final
7
+ from typing import TYPE_CHECKING, Literal, final
12
8
  from uuid import uuid4
13
9
 
14
10
  from pydantic import BaseModel, Field
@@ -25,6 +21,9 @@ from graphon.runtime.variable_pool import VariablePool
25
21
  from .path import Path
26
22
  from .session import ResponseSession
27
23
 
24
+ if TYPE_CHECKING:
25
+ from graphon.graph.graph import Graph
26
+
28
27
  logger = logging.getLogger(__name__)
29
28
 
30
29
  # Type definitions
@@ -78,7 +77,9 @@ class ResponseStreamCoordinator:
78
77
  Ensures ordered streaming of responses based on upstream node outputs and constants.
79
78
  """
80
79
 
81
- def __init__(self, variable_pool: "VariablePool", graph: GraphProtocol) -> None:
80
+ def __init__(
81
+ self, variable_pool: VariablePool, graph: GraphProtocol | Graph
82
+ ) -> None:
82
83
  """Initialize coordinator with variable pool.
83
84
 
84
85
  Args:
@@ -1,7 +1,11 @@
1
1
  from .client import HttpClientMaxRetriesExceededError, HttpxHttpClient
2
2
  from .protocols import HttpClientProtocol, HttpResponseProtocol
3
3
  from .response import HttpHeaders, HttpResponse, HttpStatusError
4
- from .runtime import get_default_http_client, get_http_client, set_http_client
4
+ from .runtime import (
5
+ get_default_http_client,
6
+ get_http_client,
7
+ set_http_client,
8
+ )
5
9
 
6
10
  __all__ = [
7
11
  "HttpClientMaxRetriesExceededError",
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import email.message
3
4
  from collections.abc import Iterator, Mapping
4
5
  from http import HTTPStatus
5
6
  from typing import TYPE_CHECKING, Any
@@ -84,11 +85,11 @@ class HttpResponse:
84
85
  if self._cached_text is not None:
85
86
  return self._cached_text
86
87
 
87
- detected_encoding = charset_normalizer.from_bytes(self.content).best()
88
- if detected_encoding and detected_encoding.encoding:
88
+ charset = self._extract_charset_from_content_type()
89
+ if charset:
89
90
  try:
90
- self._cached_text = self.content.decode(detected_encoding.encoding)
91
- except (UnicodeDecodeError, TypeError, LookupError):
91
+ self._cached_text = self.content.decode(charset, errors="replace")
92
+ except (TypeError, LookupError):
92
93
  pass
93
94
  else:
94
95
  return self._cached_text
@@ -97,9 +98,27 @@ class HttpResponse:
97
98
  self._cached_text = self._fallback_text
98
99
  return self._cached_text
99
100
 
101
+ detected_encoding = charset_normalizer.from_bytes(self.content).best()
102
+ if detected_encoding and detected_encoding.encoding:
103
+ try:
104
+ self._cached_text = self.content.decode(detected_encoding.encoding)
105
+ except (UnicodeDecodeError, TypeError, LookupError):
106
+ pass
107
+ else:
108
+ return self._cached_text
109
+
100
110
  self._cached_text = self.content.decode("utf-8", errors="replace")
101
111
  return self._cached_text
102
112
 
113
+ def _extract_charset_from_content_type(self) -> str | None:
114
+ content_type = self.headers.get("content-type", "")
115
+ if not content_type:
116
+ return None
117
+
118
+ message = email.message.Message()
119
+ message["content-type"] = content_type
120
+ return message.get_content_charset(failobj=None)
121
+
103
122
  def raise_for_status(self) -> None:
104
123
  if not self.is_success:
105
124
  raise HttpStatusError(self)
@@ -0,0 +1,20 @@
1
+ from .client import HttpxHttpClient
2
+ from .protocols import HttpClientProtocol
3
+
4
+ _default_http_client: HttpClientProtocol = HttpxHttpClient()
5
+
6
+
7
+ def set_http_client(http_client: HttpClientProtocol) -> None:
8
+ """Compatibility wrapper for replacing the process default client."""
9
+ global _default_http_client # noqa: PLW0603
10
+ _default_http_client = http_client
11
+
12
+
13
+ def get_http_client() -> HttpClientProtocol:
14
+ """Return the configured process default HTTP client."""
15
+ return _default_http_client
16
+
17
+
18
+ def get_default_http_client() -> HttpClientProtocol:
19
+ """Return the process default HTTP client."""
20
+ return _default_http_client