graphon 0.2.1__tar.gz → 0.3.0__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.1 → graphon-0.3.0}/PKG-INFO +8 -5
  2. {graphon-0.2.1 → graphon-0.3.0}/README.md +7 -4
  3. {graphon-0.2.1 → graphon-0.3.0}/pyproject.toml +1 -1
  4. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/file_manager.py +26 -7
  5. graphon-0.3.0/src/graphon/file/runtime.py +63 -0
  6. graphon-0.3.0/src/graphon/file/tool_file_parser.py +59 -0
  7. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph/graph.py +6 -0
  8. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/event_management/event_handlers.py +9 -10
  9. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/graph_engine.py +2 -4
  10. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/graph_traversal/edge_processor.py +3 -5
  11. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/orchestration/dispatcher.py +3 -5
  12. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/ready_queue/factory.py +1 -5
  13. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/response_coordinator/coordinator.py +8 -7
  14. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/http/__init__.py +5 -1
  15. graphon-0.3.0/src/graphon/http/runtime.py +20 -0
  16. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/README.md +26 -8
  17. graphon-0.3.0/src/graphon/model_runtime/__init__.py +21 -0
  18. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/llm_entities.py +61 -30
  19. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/ai_model.py +5 -5
  20. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/large_language_model.py +2 -1
  21. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/moderation_model.py +4 -1
  22. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/rerank_model.py +2 -1
  23. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/speech2text_model.py +4 -1
  24. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/text_embedding_model.py +16 -6
  25. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/tokenizers/gpt2_tokenizer.py +0 -7
  26. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/base/tts_model.py +2 -1
  27. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/model_provider_factory.py +11 -49
  28. graphon-0.3.0/src/graphon/model_runtime/protocols/__init__.py +25 -0
  29. graphon-0.3.0/src/graphon/model_runtime/protocols/llm_runtime.py +118 -0
  30. graphon-0.3.0/src/graphon/model_runtime/protocols/moderation_runtime.py +19 -0
  31. graphon-0.3.0/src/graphon/model_runtime/protocols/provider_runtime.py +47 -0
  32. graphon-0.3.0/src/graphon/model_runtime/protocols/rerank_runtime.py +38 -0
  33. graphon-0.3.0/src/graphon/model_runtime/protocols/runtime.py +29 -0
  34. graphon-0.3.0/src/graphon/model_runtime/protocols/speech_to_text_runtime.py +19 -0
  35. graphon-0.3.0/src/graphon/model_runtime/protocols/text_embedding_runtime.py +43 -0
  36. graphon-0.3.0/src/graphon/model_runtime/protocols/tts_runtime.py +30 -0
  37. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/slim/prepared_llm.py +16 -28
  38. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/slim/runtime.py +443 -59
  39. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/utils/encoders.py +1 -1
  40. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/node.py +44 -16
  41. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/code/code_node.py +64 -40
  42. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/document_extractor/node.py +231 -101
  43. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/__init__.py +2 -1
  44. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/node.py +88 -17
  45. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/human_input/entities.py +19 -1
  46. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/human_input/human_input_node.py +31 -32
  47. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/if_else/entities.py +1 -1
  48. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/if_else/if_else_node.py +4 -42
  49. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/file_saver.py +20 -1
  50. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/llm_utils.py +11 -0
  51. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/node.py +23 -12
  52. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/loop/loop_node.py +17 -9
  53. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/parameter_extractor/parameter_extractor_node.py +108 -14
  54. graphon-0.3.0/src/graphon/nodes/question_classifier/__init__.py +11 -0
  55. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/question_classifier/entities.py +17 -2
  56. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/question_classifier/question_classifier_node.py +141 -35
  57. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/runtime.py +47 -0
  58. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/template_transform/template_transform_node.py +21 -21
  59. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/tool/tool_node.py +29 -25
  60. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v1/node.py +31 -15
  61. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/node.py +16 -20
  62. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/protocols/__init__.py +21 -1
  63. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/runtime/graph_runtime_state.py +14 -15
  64. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/runtime/variable_pool.py +88 -47
  65. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/utils/condition/processor.py +31 -20
  66. graphon-0.3.0/src/graphon/variables/factory.py +441 -0
  67. graphon-0.2.1/src/graphon/file/runtime.py +0 -110
  68. graphon-0.2.1/src/graphon/file/tool_file_parser.py +0 -9
  69. graphon-0.2.1/src/graphon/http/runtime.py +0 -17
  70. graphon-0.2.1/src/graphon/model_runtime/README_CN.md +0 -64
  71. graphon-0.2.1/src/graphon/model_runtime/runtime.py +0 -179
  72. graphon-0.2.1/src/graphon/nodes/question_classifier/__init__.py +0 -4
  73. graphon-0.2.1/src/graphon/utils/condition/__init__.py +0 -0
  74. graphon-0.2.1/src/graphon/variables/factory.py +0 -274
  75. {graphon-0.2.1 → graphon-0.3.0}/LICENSE +0 -0
  76. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/__init__.py +0 -0
  77. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/__init__.py +0 -0
  78. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/base_node_data.py +0 -0
  79. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/exc.py +0 -0
  80. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/graph_config.py +0 -0
  81. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/graph_init_params.py +0 -0
  82. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/pause_reason.py +0 -0
  83. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/workflow_execution.py +0 -0
  84. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/workflow_node_execution.py +0 -0
  85. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/entities/workflow_start_reason.py +0 -0
  86. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/enums.py +0 -0
  87. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/errors.py +0 -0
  88. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/__init__.py +0 -0
  89. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/constants.py +0 -0
  90. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/enums.py +0 -0
  91. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/file_factory.py +0 -0
  92. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/helpers.py +0 -0
  93. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/models.py +0 -0
  94. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/file/protocols.py +0 -0
  95. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph/__init__.py +0 -0
  96. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph/edge.py +0 -0
  97. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph/graph_template.py +0 -0
  98. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph/validation.py +0 -0
  99. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/__init__.py +0 -0
  100. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/_engine_utils.py +0 -0
  101. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_channels/README.md +0 -0
  102. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_channels/__init__.py +0 -0
  103. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_channels/in_memory_channel.py +0 -0
  104. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_channels/protocol.py +0 -0
  105. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_channels/redis_channel.py +0 -0
  106. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_processing/__init__.py +0 -0
  107. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_processing/command_handlers.py +0 -0
  108. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/command_processing/command_processor.py +0 -0
  109. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/config.py +0 -0
  110. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/domain/__init__.py +0 -0
  111. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/domain/graph_execution.py +0 -0
  112. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/domain/node_execution.py +0 -0
  113. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/entities/__init__.py +0 -0
  114. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/entities/commands.py +0 -0
  115. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/error_handler.py +0 -0
  116. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/event_management/__init__.py +0 -0
  117. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/event_management/event_manager.py +0 -0
  118. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/graph_state_manager.py +0 -0
  119. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/graph_traversal/__init__.py +0 -0
  120. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/graph_traversal/skip_propagator.py +0 -0
  121. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/layers/README.md +0 -0
  122. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/layers/__init__.py +0 -0
  123. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/layers/base.py +0 -0
  124. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/layers/debug_logging.py +0 -0
  125. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/layers/execution_limits.py +0 -0
  126. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/manager.py +0 -0
  127. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/orchestration/__init__.py +0 -0
  128. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/orchestration/execution_coordinator.py +0 -0
  129. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/ready_queue/__init__.py +0 -0
  130. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/ready_queue/in_memory.py +0 -0
  131. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/ready_queue/protocol.py +0 -0
  132. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/response_coordinator/__init__.py +0 -0
  133. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/response_coordinator/path.py +0 -0
  134. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/response_coordinator/session.py +0 -0
  135. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/worker.py +0 -0
  136. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/worker_management/__init__.py +0 -0
  137. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_engine/worker_management/worker_pool.py +0 -0
  138. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/__init__.py +0 -0
  139. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/agent.py +0 -0
  140. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/base.py +0 -0
  141. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/graph.py +0 -0
  142. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/human_input.py +0 -0
  143. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/iteration.py +0 -0
  144. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/loop.py +0 -0
  145. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/graph_events/node.py +0 -0
  146. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/http/client.py +0 -0
  147. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/http/protocols.py +0 -0
  148. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/http/response.py +0 -0
  149. {graphon-0.2.1/src/graphon/model_runtime → graphon-0.3.0/src/graphon/model_runtime/callbacks}/__init__.py +0 -0
  150. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/callbacks/base_callback.py +0 -0
  151. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/callbacks/logging_callback.py +0 -0
  152. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/__init__.py +0 -0
  153. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/common_entities.py +0 -0
  154. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/defaults.py +0 -0
  155. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/message_entities.py +0 -0
  156. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/model_entities.py +0 -0
  157. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/provider_entities.py +0 -0
  158. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/rerank_entities.py +0 -0
  159. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/entities/text_embedding_entities.py +0 -0
  160. {graphon-0.2.1/src/graphon/model_runtime/callbacks → graphon-0.3.0/src/graphon/model_runtime/errors}/__init__.py +0 -0
  161. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/errors/invoke.py +0 -0
  162. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/errors/validate.py +0 -0
  163. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/memory/__init__.py +0 -0
  164. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/memory/prompt_message_memory.py +0 -0
  165. {graphon-0.2.1/src/graphon/model_runtime/errors → graphon-0.3.0/src/graphon/model_runtime/model_providers}/__init__.py +0 -0
  166. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/model_providers/_position.yaml +0 -0
  167. {graphon-0.2.1/src/graphon/model_runtime/model_providers → graphon-0.3.0/src/graphon/model_runtime/model_providers/base}/__init__.py +0 -0
  168. {graphon-0.2.1/src/graphon/model_runtime/model_providers/base → graphon-0.3.0/src/graphon/model_runtime/model_providers/base/tokenizers}/__init__.py +0 -0
  169. {graphon-0.2.1/src/graphon/model_runtime/model_providers/base/tokenizers → graphon-0.3.0/src/graphon/model_runtime/schema_validators}/__init__.py +0 -0
  170. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/schema_validators/common_validator.py +0 -0
  171. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/schema_validators/model_credential_schema_validator.py +0 -0
  172. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/schema_validators/provider_credential_schema_validator.py +0 -0
  173. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/slim/__init__.py +0 -0
  174. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/slim/config.py +0 -0
  175. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/model_runtime/slim/package_loader.py +0 -0
  176. {graphon-0.2.1/src/graphon/model_runtime/schema_validators → graphon-0.3.0/src/graphon/model_runtime/utils}/__init__.py +0 -0
  177. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/__init__.py +0 -0
  178. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/agent.py +0 -0
  179. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/base.py +0 -0
  180. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/iteration.py +0 -0
  181. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/loop.py +0 -0
  182. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/node_events/node.py +0 -0
  183. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/__init__.py +0 -0
  184. {graphon-0.2.1/src/graphon/model_runtime/utils → graphon-0.3.0/src/graphon/nodes/answer}/__init__.py +0 -0
  185. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/answer/answer_node.py +0 -0
  186. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/answer/entities.py +0 -0
  187. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/__init__.py +0 -0
  188. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/entities.py +0 -0
  189. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/template.py +0 -0
  190. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/usage_tracking_mixin.py +0 -0
  191. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/base/variable_template_parser.py +0 -0
  192. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/code/__init__.py +0 -0
  193. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/code/entities.py +0 -0
  194. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/code/exc.py +0 -0
  195. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/code/limits.py +0 -0
  196. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/document_extractor/__init__.py +0 -0
  197. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/document_extractor/entities.py +0 -0
  198. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/document_extractor/exc.py +0 -0
  199. {graphon-0.2.1/src/graphon/nodes/answer → graphon-0.3.0/src/graphon/nodes/end}/__init__.py +0 -0
  200. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/end/end_node.py +0 -0
  201. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/end/entities.py +0 -0
  202. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/config.py +0 -0
  203. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/entities.py +0 -0
  204. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/exc.py +0 -0
  205. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/http_request/executor.py +0 -0
  206. {graphon-0.2.1/src/graphon/nodes/end → graphon-0.3.0/src/graphon/nodes/human_input}/__init__.py +0 -0
  207. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/human_input/enums.py +0 -0
  208. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/if_else/__init__.py +0 -0
  209. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/iteration/__init__.py +0 -0
  210. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/iteration/entities.py +0 -0
  211. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/iteration/exc.py +0 -0
  212. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/iteration/iteration_node.py +0 -0
  213. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/iteration/iteration_start_node.py +0 -0
  214. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/list_operator/__init__.py +0 -0
  215. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/list_operator/entities.py +0 -0
  216. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/list_operator/exc.py +0 -0
  217. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/list_operator/node.py +0 -0
  218. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/__init__.py +0 -0
  219. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/entities.py +0 -0
  220. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/exc.py +0 -0
  221. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/protocols.py +0 -0
  222. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/llm/runtime_protocols.py +0 -0
  223. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/loop/__init__.py +0 -0
  224. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/loop/entities.py +0 -0
  225. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/loop/loop_end_node.py +0 -0
  226. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/loop/loop_start_node.py +0 -0
  227. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/parameter_extractor/__init__.py +0 -0
  228. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/parameter_extractor/entities.py +0 -0
  229. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/parameter_extractor/exc.py +0 -0
  230. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/parameter_extractor/prompts.py +0 -0
  231. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/protocols.py +0 -0
  232. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/question_classifier/exc.py +0 -0
  233. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/question_classifier/template_prompts.py +0 -0
  234. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/start/__init__.py +0 -0
  235. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/start/entities.py +0 -0
  236. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/start/start_node.py +0 -0
  237. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/template_transform/__init__.py +0 -0
  238. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/template_transform/entities.py +0 -0
  239. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/tool/__init__.py +0 -0
  240. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/tool/entities.py +0 -0
  241. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/tool/exc.py +0 -0
  242. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/tool_runtime_entities.py +0 -0
  243. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_aggregator/__init__.py +0 -0
  244. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_aggregator/entities.py +0 -0
  245. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_aggregator/variable_aggregator_node.py +0 -0
  246. {graphon-0.2.1/src/graphon/nodes/human_input → graphon-0.3.0/src/graphon/nodes/variable_assigner}/__init__.py +0 -0
  247. {graphon-0.2.1/src/graphon/nodes/variable_assigner → graphon-0.3.0/src/graphon/nodes/variable_assigner/common}/__init__.py +0 -0
  248. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/common/exc.py +0 -0
  249. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/common/helpers.py +0 -0
  250. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v1/__init__.py +0 -0
  251. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v1/node_data.py +0 -0
  252. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/__init__.py +0 -0
  253. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/entities.py +0 -0
  254. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/enums.py +0 -0
  255. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/exc.py +0 -0
  256. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/nodes/variable_assigner/v2/helpers.py +0 -0
  257. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/prompt_entities.py +0 -0
  258. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/py.typed +0 -0
  259. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/runtime/__init__.py +0 -0
  260. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/runtime/graph_runtime_state_protocol.py +0 -0
  261. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/runtime/read_only_wrappers.py +0 -0
  262. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/template_rendering.py +0 -0
  263. {graphon-0.2.1/src/graphon/nodes/variable_assigner/common → graphon-0.3.0/src/graphon/utils}/__init__.py +0 -0
  264. {graphon-0.2.1/src/graphon/utils → graphon-0.3.0/src/graphon/utils/condition}/__init__.py +0 -0
  265. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/utils/condition/entities.py +0 -0
  266. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/utils/json_in_md_parser.py +0 -0
  267. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variable_loader.py +0 -0
  268. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/__init__.py +0 -0
  269. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/consts.py +0 -0
  270. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/exc.py +0 -0
  271. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/input_entities.py +0 -0
  272. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/segment_group.py +0 -0
  273. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/segments.py +0 -0
  274. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/types.py +0 -0
  275. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/utils.py +0 -0
  276. {graphon-0.2.1 → graphon-0.3.0}/src/graphon/variables/variables.py +0 -0
  277. {graphon-0.2.1 → graphon-0.3.0}/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.1
3
+ Version: 0.3.0
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.1"
3
+ version = "0.3.0"
4
4
  description = 'Graph execution engine for agentic AI workflows.'
5
5
  readme = 'README.md'
6
6
  license = 'Apache-2.0'
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import base64
4
4
  from collections.abc import Callable, Mapping
5
- from operator import attrgetter
6
5
 
7
6
  from graphon.model_runtime.entities.message_entities import (
8
7
  AudioPromptMessageContent,
@@ -40,15 +39,35 @@ def _get_file_transfer_method_value(file: File) -> str:
40
39
  return file.transfer_method.value
41
40
 
42
41
 
43
- _FILE_ATTRIBUTE_GETTERS: Mapping[FileAttribute, Callable[[File], object]] = {
42
+ def _get_file_size(file: File) -> int:
43
+ return file.size
44
+
45
+
46
+ def _get_file_name(file: File) -> str | None:
47
+ return file.filename
48
+
49
+
50
+ def _get_file_mime_type(file: File) -> str | None:
51
+ return file.mime_type
52
+
53
+
54
+ def _get_file_extension(file: File) -> str | None:
55
+ return file.extension
56
+
57
+
58
+ def _get_file_related_id(file: File) -> str | None:
59
+ return file.related_id
60
+
61
+
62
+ _FILE_ATTRIBUTE_GETTERS: Mapping[FileAttribute, Callable[[File], str | int | None]] = {
44
63
  FileAttribute.TYPE: _get_file_type_value,
45
- FileAttribute.SIZE: attrgetter("size"),
46
- FileAttribute.NAME: attrgetter("filename"),
47
- FileAttribute.MIME_TYPE: attrgetter("mime_type"),
64
+ FileAttribute.SIZE: _get_file_size,
65
+ FileAttribute.NAME: _get_file_name,
66
+ FileAttribute.MIME_TYPE: _get_file_mime_type,
48
67
  FileAttribute.TRANSFER_METHOD: _get_file_transfer_method_value,
49
68
  FileAttribute.URL: _to_url,
50
- FileAttribute.EXTENSION: attrgetter("extension"),
51
- FileAttribute.RELATED_ID: attrgetter("related_id"),
69
+ FileAttribute.EXTENSION: _get_file_extension,
70
+ FileAttribute.RELATED_ID: _get_file_related_id,
52
71
  }
53
72
  _PROMPT_CONTENT_CLASS_BY_FILE_TYPE: Mapping[
54
73
  FileType,
@@ -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
  *,
@@ -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
 
@@ -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",
@@ -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
@@ -1,6 +1,8 @@
1
1
  # Model Runtime
2
2
 
3
- This module provides the interface for invoking and authenticating various models, and offers Dify a unified information and credentials form rule for model providers.
3
+ This module provides the interfaces for invoking and authenticating various
4
+ models, and offers Dify a unified information and credentials form rule for
5
+ model providers.
4
6
 
5
7
  - On one hand, it decouples models from upstream and downstream processes, facilitating horizontal expansion for developers,
6
8
  - On the other hand, it allows for direct display of providers and models in the frontend interface by simply defining them in the backend, eliminating the need to modify frontend logic.
@@ -32,19 +34,35 @@ This module provides the interface for invoking and authenticating various model
32
34
 
33
35
  ## Structure
34
36
 
35
- Model Runtime is divided into three layers:
37
+ Model Runtime is divided into protocol and implementation layers:
36
38
 
37
- - The outermost layer is the factory method
39
+ - Provider/runtime protocols
38
40
 
39
- It provides methods for obtaining all providers, all model lists, getting provider instances, and authenticating provider/model credentials.
41
+ Shared provider concerns live in `protocols/provider_runtime.py`, while each
42
+ model capability has its own protocol module such as
43
+ `protocols/llm_runtime.py`, `protocols/text_embedding_runtime.py`, and
44
+ `protocols/tts_runtime.py`. Downstream runtimes can implement only the
45
+ capabilities they need instead of satisfying a single monolithic interface.
40
46
 
41
- - The second layer is the provider layer
47
+ - Aggregate runtime protocol
42
48
 
43
- It provides the current provider's model list, model instance obtaining, provider credential authentication, and provider configuration rule information, **allowing horizontal expansion** to support different providers.
49
+ `protocols/runtime.py` composes the individual capability protocols into
50
+ `ModelRuntime` for adapters that intentionally implement the full surface
51
+ area.
44
52
 
45
- - The bottom layer is the model layer
53
+ - Provider factory
46
54
 
47
- It offers direct invocation of various model types, predefined model configuration information, getting predefined/remote model lists, model credential authentication methods. Different models provide additional special methods, like LLM's pre-computed tokens method, cost information obtaining method, etc., **allowing horizontal expansion** for different models under the same provider (within supported model types).
55
+ `model_providers/model_provider_factory.py` now depends only on
56
+ `ModelProviderRuntime`. It handles provider discovery, provider/model schema
57
+ lookup, credential validation, provider icon lookup, and provider-level model
58
+ list projection without assuming any invocation capability.
59
+
60
+ - Model wrappers
61
+
62
+ Capability wrappers such as `LargeLanguageModel`, `TextEmbeddingModel`,
63
+ `RerankModel`, `Speech2TextModel`, `ModerationModel`, and `TTSModel` depend
64
+ only on their matching capability protocol. Instantiate those wrappers
65
+ directly when you need invocation behavior.
48
66
 
49
67
  ## Documentation
50
68
 
@@ -0,0 +1,21 @@
1
+ from graphon.model_runtime.protocols import (
2
+ LLMModelRuntime,
3
+ ModelProviderRuntime,
4
+ ModelRuntime,
5
+ ModerationModelRuntime,
6
+ RerankModelRuntime,
7
+ SpeechToTextModelRuntime,
8
+ TextEmbeddingModelRuntime,
9
+ TTSModelRuntime,
10
+ )
11
+
12
+ __all__ = [
13
+ "LLMModelRuntime",
14
+ "ModelProviderRuntime",
15
+ "ModelRuntime",
16
+ "ModerationModelRuntime",
17
+ "RerankModelRuntime",
18
+ "SpeechToTextModelRuntime",
19
+ "TTSModelRuntime",
20
+ "TextEmbeddingModelRuntime",
21
+ ]
@@ -5,7 +5,16 @@ from decimal import Decimal
5
5
  from enum import StrEnum
6
6
  from typing import Any, Self, TypedDict
7
7
 
8
- from pydantic import BaseModel, Field
8
+ from pydantic import (
9
+ BaseModel,
10
+ ConfigDict,
11
+ Field,
12
+ StrictFloat,
13
+ StrictInt,
14
+ TypeAdapter,
15
+ field_validator,
16
+ model_validator,
17
+ )
9
18
 
10
19
  from graphon.model_runtime.entities.message_entities import (
11
20
  AssistantPromptMessage,
@@ -42,6 +51,41 @@ class LLMUsageMetadata(TypedDict, total=False):
42
51
  time_to_generate: float
43
52
 
44
53
 
54
+ class _LLMUsageMetadataInput(BaseModel):
55
+ model_config = ConfigDict(extra="ignore")
56
+
57
+ prompt_tokens: StrictInt = 0
58
+ completion_tokens: StrictInt = 0
59
+ total_tokens: StrictInt = 0
60
+ prompt_unit_price: Decimal = Decimal(0)
61
+ completion_unit_price: Decimal = Decimal(0)
62
+ total_price: Decimal = Decimal(0)
63
+ currency: str = "USD"
64
+ prompt_price_unit: Decimal = Decimal(0)
65
+ completion_price_unit: Decimal = Decimal(0)
66
+ prompt_price: Decimal = Decimal(0)
67
+ completion_price: Decimal = Decimal(0)
68
+ latency: StrictInt | StrictFloat = 0.0
69
+ time_to_first_token: StrictInt | StrictFloat | None = None
70
+ time_to_generate: StrictInt | StrictFloat | None = None
71
+
72
+ @field_validator("currency", mode="before")
73
+ @classmethod
74
+ def _normalize_currency(cls, value: object) -> str:
75
+ return str(value)
76
+
77
+ @model_validator(mode="after")
78
+ def _derive_total_tokens(self) -> _LLMUsageMetadataInput:
79
+ if self.total_tokens == 0 and (
80
+ self.prompt_tokens > 0 or self.completion_tokens > 0
81
+ ):
82
+ self.total_tokens = self.prompt_tokens + self.completion_tokens
83
+ return self
84
+
85
+
86
+ _LLM_USAGE_METADATA_INPUT_ADAPTER = TypeAdapter(_LLMUsageMetadataInput)
87
+
88
+
45
89
  class LLMUsage(ModelUsage):
46
90
  """Model class for llm usage."""
47
91
 
@@ -80,7 +124,7 @@ class LLMUsage(ModelUsage):
80
124
  )
81
125
 
82
126
  @classmethod
83
- def from_metadata(cls, metadata: LLMUsageMetadata) -> LLMUsage:
127
+ def from_metadata(cls, metadata: Mapping[str, object]) -> LLMUsage:
84
128
  """Create LLMUsage instance from metadata dictionary with default values.
85
129
 
86
130
  Args:
@@ -90,35 +134,22 @@ class LLMUsage(ModelUsage):
90
134
  LLMUsage instance with values from metadata or defaults
91
135
 
92
136
  """
93
- prompt_tokens = metadata.get("prompt_tokens", 0)
94
- completion_tokens = metadata.get("completion_tokens", 0)
95
- total_tokens = metadata.get("total_tokens", 0)
96
-
97
- # If total_tokens is not provided but prompt and completion tokens are,
98
- # calculate total_tokens
99
- if total_tokens == 0 and (prompt_tokens > 0 or completion_tokens > 0):
100
- total_tokens = prompt_tokens + completion_tokens
101
-
102
- return cls(
103
- prompt_tokens=prompt_tokens,
104
- completion_tokens=completion_tokens,
105
- total_tokens=total_tokens,
106
- prompt_unit_price=Decimal(str(metadata.get("prompt_unit_price", 0))),
107
- completion_unit_price=Decimal(
108
- str(metadata.get("completion_unit_price", 0)),
109
- ),
110
- total_price=Decimal(str(metadata.get("total_price", 0))),
111
- currency=metadata.get("currency", "USD"),
112
- prompt_price_unit=Decimal(str(metadata.get("prompt_price_unit", 0))),
113
- completion_price_unit=Decimal(
114
- str(metadata.get("completion_price_unit", 0)),
115
- ),
116
- prompt_price=Decimal(str(metadata.get("prompt_price", 0))),
117
- completion_price=Decimal(str(metadata.get("completion_price", 0))),
118
- latency=metadata.get("latency", 0.0),
119
- time_to_first_token=metadata.get("time_to_first_token"),
120
- time_to_generate=metadata.get("time_to_generate"),
137
+ normalized_metadata = _LLM_USAGE_METADATA_INPUT_ADAPTER.validate_python(
138
+ metadata,
139
+ )
140
+ payload = normalized_metadata.model_dump(mode="python")
141
+ payload["latency"] = float(normalized_metadata.latency)
142
+ payload["time_to_first_token"] = (
143
+ float(normalized_metadata.time_to_first_token)
144
+ if normalized_metadata.time_to_first_token is not None
145
+ else None
146
+ )
147
+ payload["time_to_generate"] = (
148
+ float(normalized_metadata.time_to_generate)
149
+ if normalized_metadata.time_to_generate is not None
150
+ else None
121
151
  )
152
+ return cls.model_validate(payload)
122
153
 
123
154
  def plus(self, other: LLMUsage) -> LLMUsage:
124
155
  """Add two LLMUsage instances together.