vellum-ai 1.11.2__py3-none-any.whl → 1.13.5__py3-none-any.whl

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.

Potentially problematic release.


This version of vellum-ai might be problematic. Click here for more details.

Files changed (275) hide show
  1. vellum/__init__.py +18 -0
  2. vellum/client/README.md +1 -1
  3. vellum/client/core/client_wrapper.py +2 -2
  4. vellum/client/core/force_multipart.py +4 -2
  5. vellum/client/core/http_response.py +1 -1
  6. vellum/client/core/pydantic_utilities.py +7 -4
  7. vellum/client/errors/too_many_requests_error.py +1 -2
  8. vellum/client/reference.md +677 -76
  9. vellum/client/resources/container_images/client.py +299 -0
  10. vellum/client/resources/container_images/raw_client.py +286 -0
  11. vellum/client/resources/documents/client.py +20 -10
  12. vellum/client/resources/documents/raw_client.py +20 -10
  13. vellum/client/resources/events/raw_client.py +4 -4
  14. vellum/client/resources/integration_auth_configs/client.py +2 -0
  15. vellum/client/resources/integration_auth_configs/raw_client.py +2 -0
  16. vellum/client/resources/integration_providers/client.py +28 -2
  17. vellum/client/resources/integration_providers/raw_client.py +24 -0
  18. vellum/client/resources/integrations/client.py +52 -4
  19. vellum/client/resources/integrations/raw_client.py +61 -0
  20. vellum/client/resources/workflow_deployments/client.py +156 -0
  21. vellum/client/resources/workflow_deployments/raw_client.py +334 -0
  22. vellum/client/resources/workflows/client.py +212 -8
  23. vellum/client/resources/workflows/raw_client.py +343 -6
  24. vellum/client/types/__init__.py +18 -0
  25. vellum/client/types/api_actor_type_enum.py +1 -1
  26. vellum/client/types/check_workflow_execution_status_error.py +21 -0
  27. vellum/client/types/check_workflow_execution_status_response.py +29 -0
  28. vellum/client/types/code_execution_package_request.py +21 -0
  29. vellum/client/types/composio_execute_tool_request.py +5 -0
  30. vellum/client/types/composio_tool_definition.py +1 -0
  31. vellum/client/types/container_image_build_config.py +1 -0
  32. vellum/client/types/container_image_container_image_tag.py +1 -0
  33. vellum/client/types/dataset_row_push_request.py +3 -0
  34. vellum/client/types/document_document_to_document_index.py +1 -0
  35. vellum/client/types/integration_name.py +24 -0
  36. vellum/client/types/node_execution_fulfilled_body.py +1 -0
  37. vellum/client/types/node_execution_log_body.py +24 -0
  38. vellum/client/types/node_execution_log_event.py +47 -0
  39. vellum/client/types/prompt_deployment_release_prompt_deployment.py +1 -0
  40. vellum/client/types/runner_config_request.py +24 -0
  41. vellum/client/types/severity_enum.py +5 -0
  42. vellum/client/types/slim_composio_tool_definition.py +1 -0
  43. vellum/client/types/slim_document_document_to_document_index.py +2 -0
  44. vellum/client/types/type_checker_enum.py +5 -0
  45. vellum/client/types/vellum_audio.py +5 -1
  46. vellum/client/types/vellum_audio_request.py +5 -1
  47. vellum/client/types/vellum_document.py +5 -1
  48. vellum/client/types/vellum_document_request.py +5 -1
  49. vellum/client/types/vellum_image.py +5 -1
  50. vellum/client/types/vellum_image_request.py +5 -1
  51. vellum/client/types/vellum_node_execution_event.py +2 -0
  52. vellum/client/types/vellum_variable.py +5 -0
  53. vellum/client/types/vellum_variable_extensions.py +1 -0
  54. vellum/client/types/vellum_variable_type.py +1 -0
  55. vellum/client/types/vellum_video.py +5 -1
  56. vellum/client/types/vellum_video_request.py +5 -1
  57. vellum/client/types/workflow_deployment_release_workflow_deployment.py +1 -0
  58. vellum/client/types/workflow_event.py +2 -0
  59. vellum/client/types/workflow_execution_fulfilled_body.py +1 -0
  60. vellum/client/types/workflow_result_event_output_data_array.py +1 -1
  61. vellum/client/types/workflow_result_event_output_data_chat_history.py +1 -1
  62. vellum/client/types/workflow_result_event_output_data_error.py +1 -1
  63. vellum/client/types/workflow_result_event_output_data_function_call.py +1 -1
  64. vellum/client/types/workflow_result_event_output_data_json.py +1 -1
  65. vellum/client/types/workflow_result_event_output_data_number.py +1 -1
  66. vellum/client/types/workflow_result_event_output_data_search_results.py +1 -1
  67. vellum/client/types/workflow_result_event_output_data_string.py +1 -1
  68. vellum/client/types/workflow_sandbox_execute_node_response.py +8 -0
  69. vellum/plugins/vellum_mypy.py +37 -2
  70. vellum/types/check_workflow_execution_status_error.py +3 -0
  71. vellum/types/check_workflow_execution_status_response.py +3 -0
  72. vellum/types/code_execution_package_request.py +3 -0
  73. vellum/types/node_execution_log_body.py +3 -0
  74. vellum/types/node_execution_log_event.py +3 -0
  75. vellum/types/runner_config_request.py +3 -0
  76. vellum/types/severity_enum.py +3 -0
  77. vellum/types/type_checker_enum.py +3 -0
  78. vellum/types/workflow_sandbox_execute_node_response.py +3 -0
  79. vellum/utils/files/mixin.py +26 -0
  80. vellum/utils/files/tests/test_mixin.py +62 -0
  81. vellum/utils/tests/test_vellum_client.py +95 -0
  82. vellum/utils/uuid.py +19 -2
  83. vellum/utils/vellum_client.py +10 -3
  84. vellum/workflows/__init__.py +7 -1
  85. vellum/workflows/descriptors/base.py +86 -0
  86. vellum/workflows/descriptors/tests/test_utils.py +9 -0
  87. vellum/workflows/errors/tests/__init__.py +0 -0
  88. vellum/workflows/errors/tests/test_types.py +52 -0
  89. vellum/workflows/errors/types.py +1 -0
  90. vellum/workflows/events/node.py +24 -0
  91. vellum/workflows/events/tests/test_event.py +123 -0
  92. vellum/workflows/events/types.py +2 -1
  93. vellum/workflows/events/workflow.py +28 -2
  94. vellum/workflows/expressions/add.py +3 -0
  95. vellum/workflows/expressions/tests/test_add.py +24 -0
  96. vellum/workflows/graph/graph.py +26 -5
  97. vellum/workflows/graph/tests/test_graph.py +228 -1
  98. vellum/workflows/inputs/base.py +22 -6
  99. vellum/workflows/inputs/dataset_row.py +121 -16
  100. vellum/workflows/inputs/tests/test_inputs.py +3 -3
  101. vellum/workflows/integrations/tests/test_vellum_integration_service.py +84 -0
  102. vellum/workflows/integrations/vellum_integration_service.py +12 -1
  103. vellum/workflows/loaders/base.py +2 -0
  104. vellum/workflows/nodes/bases/base.py +37 -16
  105. vellum/workflows/nodes/bases/tests/test_base_node.py +104 -1
  106. vellum/workflows/nodes/core/inline_subworkflow_node/node.py +1 -0
  107. vellum/workflows/nodes/core/inline_subworkflow_node/tests/test_node.py +1 -1
  108. vellum/workflows/nodes/core/map_node/node.py +7 -5
  109. vellum/workflows/nodes/core/map_node/tests/test_node.py +33 -0
  110. vellum/workflows/nodes/core/retry_node/node.py +1 -0
  111. vellum/workflows/nodes/core/try_node/node.py +1 -0
  112. vellum/workflows/nodes/displayable/api_node/node.py +3 -2
  113. vellum/workflows/nodes/displayable/api_node/tests/test_api_node.py +38 -0
  114. vellum/workflows/nodes/displayable/bases/api_node/node.py +1 -1
  115. vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +18 -1
  116. vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +109 -2
  117. vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py +13 -2
  118. vellum/workflows/nodes/displayable/code_execution_node/node.py +9 -15
  119. vellum/workflows/nodes/displayable/code_execution_node/tests/test_node.py +65 -24
  120. vellum/workflows/nodes/displayable/code_execution_node/utils.py +3 -0
  121. vellum/workflows/nodes/displayable/final_output_node/node.py +24 -69
  122. vellum/workflows/nodes/displayable/final_output_node/tests/test_node.py +53 -3
  123. vellum/workflows/nodes/displayable/note_node/node.py +4 -1
  124. vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +16 -5
  125. vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py +47 -0
  126. vellum/workflows/nodes/displayable/tool_calling_node/node.py +74 -34
  127. vellum/workflows/nodes/displayable/tool_calling_node/tests/test_node.py +204 -8
  128. vellum/workflows/nodes/displayable/tool_calling_node/utils.py +92 -71
  129. vellum/workflows/nodes/mocks.py +47 -213
  130. vellum/workflows/nodes/tests/test_mocks.py +0 -177
  131. vellum/workflows/nodes/utils.py +23 -8
  132. vellum/workflows/outputs/base.py +36 -3
  133. vellum/workflows/references/environment_variable.py +1 -11
  134. vellum/workflows/references/lazy.py +8 -0
  135. vellum/workflows/references/state_value.py +24 -1
  136. vellum/workflows/references/tests/test_lazy.py +58 -0
  137. vellum/workflows/references/trigger.py +8 -3
  138. vellum/workflows/references/workflow_input.py +8 -0
  139. vellum/workflows/resolvers/resolver.py +13 -3
  140. vellum/workflows/resolvers/tests/test_resolver.py +31 -0
  141. vellum/workflows/runner/runner.py +159 -14
  142. vellum/workflows/runner/tests/__init__.py +0 -0
  143. vellum/workflows/runner/tests/test_runner.py +170 -0
  144. vellum/workflows/sandbox.py +7 -8
  145. vellum/workflows/state/base.py +89 -30
  146. vellum/workflows/state/context.py +74 -3
  147. vellum/workflows/state/tests/test_state.py +269 -1
  148. vellum/workflows/tests/test_dataset_row.py +8 -7
  149. vellum/workflows/tests/test_sandbox.py +97 -8
  150. vellum/workflows/triggers/__init__.py +2 -1
  151. vellum/workflows/triggers/base.py +160 -28
  152. vellum/workflows/triggers/chat_message.py +141 -0
  153. vellum/workflows/triggers/integration.py +12 -0
  154. vellum/workflows/triggers/manual.py +3 -1
  155. vellum/workflows/triggers/schedule.py +3 -1
  156. vellum/workflows/triggers/tests/test_chat_message.py +257 -0
  157. vellum/workflows/types/core.py +18 -0
  158. vellum/workflows/types/definition.py +6 -13
  159. vellum/workflows/types/generics.py +12 -0
  160. vellum/workflows/types/tests/test_utils.py +12 -0
  161. vellum/workflows/types/utils.py +32 -2
  162. vellum/workflows/types/workflow_metadata.py +124 -0
  163. vellum/workflows/utils/functions.py +152 -16
  164. vellum/workflows/utils/pydantic_schema.py +19 -1
  165. vellum/workflows/utils/tests/test_functions.py +123 -8
  166. vellum/workflows/utils/tests/test_validate.py +79 -0
  167. vellum/workflows/utils/tests/test_vellum_variables.py +62 -2
  168. vellum/workflows/utils/uuids.py +90 -0
  169. vellum/workflows/utils/validate.py +108 -0
  170. vellum/workflows/utils/vellum_variables.py +96 -16
  171. vellum/workflows/workflows/base.py +177 -35
  172. vellum/workflows/workflows/tests/test_base_workflow.py +51 -0
  173. {vellum_ai-1.11.2.dist-info → vellum_ai-1.13.5.dist-info}/METADATA +6 -1
  174. {vellum_ai-1.11.2.dist-info → vellum_ai-1.13.5.dist-info}/RECORD +274 -227
  175. vellum_cli/__init__.py +21 -0
  176. vellum_cli/config.py +16 -2
  177. vellum_cli/pull.py +2 -0
  178. vellum_cli/push.py +23 -10
  179. vellum_cli/tests/conftest.py +8 -13
  180. vellum_cli/tests/test_image_push.py +4 -11
  181. vellum_cli/tests/test_pull.py +83 -68
  182. vellum_cli/tests/test_push.py +251 -2
  183. vellum_ee/assets/node-definitions.json +225 -12
  184. vellum_ee/scripts/generate_node_definitions.py +15 -3
  185. vellum_ee/workflows/display/base.py +4 -3
  186. vellum_ee/workflows/display/nodes/base_node_display.py +44 -11
  187. vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +93 -0
  188. vellum_ee/workflows/display/nodes/types.py +1 -0
  189. vellum_ee/workflows/display/nodes/vellum/__init__.py +0 -2
  190. vellum_ee/workflows/display/nodes/vellum/base_adornment_node.py +5 -2
  191. vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +1 -1
  192. vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +10 -2
  193. vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py +17 -14
  194. vellum_ee/workflows/display/nodes/vellum/map_node.py +2 -0
  195. vellum_ee/workflows/display/nodes/vellum/note_node.py +18 -3
  196. vellum_ee/workflows/display/nodes/vellum/subworkflow_deployment_node.py +37 -14
  197. vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +62 -2
  198. vellum_ee/workflows/display/nodes/vellum/tests/test_final_output_node.py +136 -0
  199. vellum_ee/workflows/display/nodes/vellum/tests/test_note_node.py +44 -7
  200. vellum_ee/workflows/display/nodes/vellum/tests/test_prompt_node.py +5 -13
  201. vellum_ee/workflows/display/nodes/vellum/tests/test_subworkflow_deployment_node.py +27 -17
  202. vellum_ee/workflows/display/nodes/vellum/tests/test_tool_calling_node.py +145 -22
  203. vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +107 -2
  204. vellum_ee/workflows/display/nodes/vellum/utils.py +54 -12
  205. vellum_ee/workflows/display/tests/test_base_workflow_display.py +13 -16
  206. vellum_ee/workflows/display/tests/test_json_schema_validation.py +190 -0
  207. vellum_ee/workflows/display/tests/test_mocks.py +912 -0
  208. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_adornments_serialization.py +14 -2
  209. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_attributes_serialization.py +109 -0
  210. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_outputs_serialization.py +3 -0
  211. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_ports_serialization.py +187 -1
  212. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +34 -325
  213. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +42 -393
  214. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +13 -315
  215. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_default_state_serialization.py +2 -122
  216. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_error_node_serialization.py +24 -115
  217. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_generic_node_serialization.py +4 -93
  218. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_guardrail_node_serialization.py +7 -80
  219. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_prompt_node_serialization.py +9 -101
  220. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +77 -308
  221. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_map_node_serialization.py +62 -324
  222. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_serialization.py +3 -82
  223. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py +4 -142
  224. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_search_node_serialization.py +1 -61
  225. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_set_state_node_serialization.py +4 -4
  226. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py +205 -134
  227. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py +34 -146
  228. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py +2 -0
  229. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_composio_serialization.py +8 -6
  230. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_serialization.py +137 -266
  231. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_tool_wrapper_serialization.py +84 -0
  232. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_mcp_serialization.py +55 -16
  233. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py +15 -1
  234. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_tool_wrapper_serialization.py +71 -0
  235. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_vellum_integration_serialization.py +119 -0
  236. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_workflow_deployment_serialization.py +1 -1
  237. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py +0 -2
  238. vellum_ee/workflows/display/tests/workflow_serialization/test_chat_message_dict_reference_serialization.py +22 -1
  239. vellum_ee/workflows/display/tests/workflow_serialization/test_chat_message_trigger_serialization.py +412 -0
  240. vellum_ee/workflows/display/tests/workflow_serialization/test_code_tool_node_reference_error.py +106 -0
  241. vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py +9 -41
  242. vellum_ee/workflows/display/tests/workflow_serialization/test_duplicate_trigger_name_validation.py +208 -0
  243. vellum_ee/workflows/display/tests/workflow_serialization/test_final_output_node_not_referenced_by_workflow_outputs.py +45 -0
  244. vellum_ee/workflows/display/tests/workflow_serialization/test_infinite_loop_validation.py +66 -0
  245. vellum_ee/workflows/display/tests/workflow_serialization/test_int_input_serialization.py +40 -0
  246. vellum_ee/workflows/display/tests/workflow_serialization/test_integration_trigger_serialization.py +8 -14
  247. vellum_ee/workflows/display/tests/workflow_serialization/test_integration_trigger_validation.py +173 -0
  248. vellum_ee/workflows/display/tests/workflow_serialization/test_integration_trigger_with_entrypoint_node_id.py +16 -13
  249. vellum_ee/workflows/display/tests/workflow_serialization/test_list_vellum_document_serialization.py +5 -1
  250. vellum_ee/workflows/display/tests/workflow_serialization/test_manual_trigger_serialization.py +12 -2
  251. vellum_ee/workflows/display/tests/workflow_serialization/test_multi_trigger_same_node_serialization.py +111 -0
  252. vellum_ee/workflows/display/tests/workflow_serialization/test_no_triggers_no_entrypoint_validation.py +64 -0
  253. vellum_ee/workflows/display/tests/workflow_serialization/test_partial_workflow_meta_display_override.py +55 -0
  254. vellum_ee/workflows/display/tests/workflow_serialization/test_sandbox_dataset_mocks_serialization.py +268 -0
  255. vellum_ee/workflows/display/tests/workflow_serialization/test_sandbox_invalid_pdf_data_url.py +49 -0
  256. vellum_ee/workflows/display/tests/workflow_serialization/test_sandbox_validation_errors.py +112 -0
  257. vellum_ee/workflows/display/tests/workflow_serialization/test_scheduled_trigger_serialization.py +25 -16
  258. vellum_ee/workflows/display/tests/workflow_serialization/test_terminal_node_in_unused_graphs_serialization.py +53 -0
  259. vellum_ee/workflows/display/utils/exceptions.py +34 -0
  260. vellum_ee/workflows/display/utils/expressions.py +463 -52
  261. vellum_ee/workflows/display/utils/metadata.py +98 -33
  262. vellum_ee/workflows/display/utils/tests/test_metadata.py +31 -0
  263. vellum_ee/workflows/display/utils/triggers.py +153 -0
  264. vellum_ee/workflows/display/utils/vellum.py +59 -5
  265. vellum_ee/workflows/display/workflows/base_workflow_display.py +656 -254
  266. vellum_ee/workflows/display/workflows/get_vellum_workflow_display_class.py +26 -0
  267. vellum_ee/workflows/display/workflows/tests/test_workflow_display.py +77 -29
  268. vellum_ee/workflows/server/namespaces.py +18 -0
  269. vellum_ee/workflows/tests/test_display_meta.py +2 -0
  270. vellum_ee/workflows/tests/test_serialize_module.py +174 -7
  271. vellum_ee/workflows/tests/test_server.py +0 -3
  272. vellum_ee/workflows/display/nodes/vellum/function_node.py +0 -14
  273. {vellum_ai-1.11.2.dist-info → vellum_ai-1.13.5.dist-info}/LICENSE +0 -0
  274. {vellum_ai-1.11.2.dist-info → vellum_ai-1.13.5.dist-info}/WHEEL +0 -0
  275. {vellum_ai-1.11.2.dist-info → vellum_ai-1.13.5.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,11 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
+ from vellum.workflows import BaseWorkflow
4
+ from vellum.workflows.nodes import MapNode
5
+ from vellum.workflows.nodes.bases import BaseNode
6
+ from vellum.workflows.nodes.displayable.inline_prompt_node.node import InlinePromptNode
7
+ from vellum.workflows.outputs import BaseOutputs
8
+ from vellum.workflows.state.base import BaseState
3
9
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
4
10
 
5
11
  from tests.workflows.basic_map_node.workflow import SimpleMapExample
@@ -31,6 +37,7 @@ def test_serialize_workflow():
31
37
  "required": True,
32
38
  "default": None,
33
39
  "extensions": {"color": None},
40
+ "schema": {"type": "array", "items": {"type": "string"}},
34
41
  },
35
42
  ],
36
43
  input_variables,
@@ -54,333 +61,10 @@ def test_serialize_workflow():
54
61
 
55
62
  # AND its raw data should be what we expect
56
63
  workflow_raw_data = serialized_workflow["workflow_raw_data"]
57
- assert len(workflow_raw_data["edges"]) == 2
58
- assert len(workflow_raw_data["nodes"]) == 3
59
64
 
60
65
  # AND each node should be serialized correctly
61
- entrypoint_node = workflow_raw_data["nodes"][0]
62
- assert entrypoint_node == {
63
- "id": "c0aa464d-1685-4f15-a051-31b426fec92e",
64
- "type": "ENTRYPOINT",
65
- "inputs": [],
66
- "data": {
67
- "label": "Entrypoint Node",
68
- "source_handle_id": "844d992e-60ab-4af2-a8ff-52cd858386f7",
69
- },
70
- "base": None,
71
- "definition": None,
72
- "display_data": {
73
- "position": {"x": 0.0, "y": -50.0},
74
- },
75
- }
76
66
 
77
- map_node = workflow_raw_data["nodes"][1]
78
- assert not DeepDiff(
79
- {
80
- "id": "f2f94af1-fcbe-497c-80ce-80952c8903c8",
81
- "type": "MAP",
82
- "inputs": [
83
- {
84
- "id": "0acef1e7-caa1-4d9f-bb69-6981729af18d",
85
- "key": "items",
86
- "value": {
87
- "rules": [
88
- {
89
- "type": "INPUT_VARIABLE",
90
- "data": {"input_variable_id": "db2eb237-38e4-417a-8bfc-5bda0f3165ca"},
91
- }
92
- ],
93
- "combinator": "OR",
94
- },
95
- }
96
- ],
97
- "data": {
98
- "label": "Map Fruits Node",
99
- "error_output_id": None,
100
- "source_handle_id": "aff8a80e-7ce7-43d2-9c9e-9d137efd3b33",
101
- "target_handle_id": "e16e9d55-5f26-4d89-8c7a-939f1f463d80",
102
- "variant": "INLINE",
103
- "workflow_raw_data": {
104
- "nodes": [
105
- {
106
- "id": "ff9bfe6e-839d-4d40-b8fc-313b3bbd0ab0",
107
- "type": "ENTRYPOINT",
108
- "inputs": [],
109
- "data": {
110
- "label": "Entrypoint Node",
111
- "source_handle_id": "520d3616-8369-4e79-9da5-3febae299c2a",
112
- },
113
- "display_data": {"position": {"x": 0.0, "y": -50.0}},
114
- "base": None,
115
- "definition": None,
116
- },
117
- {
118
- "id": "9dffa9e5-00e3-4d20-8ab8-ad0412f35bf2",
119
- "label": "Iteration",
120
- "type": "GENERIC",
121
- "should_file_merge": True,
122
- "display_data": {"position": {"x": 200.0, "y": -50.0}},
123
- "base": {
124
- "name": "BaseNode",
125
- "module": ["vellum", "workflows", "nodes", "bases", "base"],
126
- },
127
- "definition": {
128
- "name": "Iteration",
129
- "module": ["tests", "workflows", "basic_map_node", "workflow"],
130
- },
131
- "trigger": {
132
- "id": "40631b74-8a35-4cb1-897d-3c93f8d5b625",
133
- "merge_behavior": "AWAIT_ATTRIBUTES",
134
- },
135
- "ports": [
136
- {"id": "8d5d36aa-f7c2-49bf-b4d5-cda6f6cd18f9", "type": "DEFAULT", "name": "default"}
137
- ],
138
- "adornments": None,
139
- "attributes": [
140
- {
141
- "id": "52a43441-9162-40b1-96c6-445250af1c34",
142
- "name": "item",
143
- "value": {
144
- "type": "WORKFLOW_INPUT",
145
- "input_variable_id": "b29bb546-9bc8-4136-857d-8c7a464ba9d4",
146
- },
147
- },
148
- {
149
- "id": "dadea752-95db-4e5f-a0d4-f3920376ee8f",
150
- "name": "index",
151
- "value": {
152
- "type": "WORKFLOW_INPUT",
153
- "input_variable_id": "17e7ca49-668f-450d-a792-e1f97d13db67",
154
- },
155
- },
156
- ],
157
- "outputs": [
158
- {
159
- "id": "3d97725d-a423-4072-9a73-7b6517edc76e",
160
- "name": "count",
161
- "type": "NUMBER",
162
- "value": None,
163
- }
164
- ],
165
- },
166
- {
167
- "id": "6f4883b2-70b1-4e1c-ae15-7d0f5aec810b",
168
- "type": "TERMINAL",
169
- "data": {
170
- "label": "Final Output",
171
- "name": "count",
172
- "target_handle_id": "9d74571f-b7f5-4c1d-8b7c-b9c648738a4d",
173
- "output_id": "2a957315-fae0-4366-8a35-f0b315c5eade",
174
- "output_type": "NUMBER",
175
- "node_input_id": "05f2e4cc-0e36-4c6b-a535-be38281e5280",
176
- },
177
- "inputs": [
178
- {
179
- "id": "05f2e4cc-0e36-4c6b-a535-be38281e5280",
180
- "key": "node_input",
181
- "value": {
182
- "rules": [
183
- {
184
- "type": "NODE_OUTPUT",
185
- "data": {
186
- "node_id": "9dffa9e5-00e3-4d20-8ab8-ad0412f35bf2",
187
- "output_id": "3d97725d-a423-4072-9a73-7b6517edc76e",
188
- },
189
- }
190
- ],
191
- "combinator": "OR",
192
- },
193
- }
194
- ],
195
- "display_data": {"position": {"x": 400.0, "y": -50.0}},
196
- "base": {
197
- "name": "FinalOutputNode",
198
- "module": [
199
- "vellum",
200
- "workflows",
201
- "nodes",
202
- "displayable",
203
- "final_output_node",
204
- "node",
205
- ],
206
- },
207
- "definition": None,
208
- },
209
- ],
210
- "edges": [
211
- {
212
- "id": "8b52ffcb-1ccf-41eb-ad89-705c6abc2369",
213
- "source_node_id": "ff9bfe6e-839d-4d40-b8fc-313b3bbd0ab0",
214
- "source_handle_id": "520d3616-8369-4e79-9da5-3febae299c2a",
215
- "target_node_id": "9dffa9e5-00e3-4d20-8ab8-ad0412f35bf2",
216
- "target_handle_id": "40631b74-8a35-4cb1-897d-3c93f8d5b625",
217
- "type": "DEFAULT",
218
- },
219
- {
220
- "id": "14152688-6996-4d64-9231-a6e66a4827eb",
221
- "source_node_id": "9dffa9e5-00e3-4d20-8ab8-ad0412f35bf2",
222
- "source_handle_id": "8d5d36aa-f7c2-49bf-b4d5-cda6f6cd18f9",
223
- "target_node_id": "6f4883b2-70b1-4e1c-ae15-7d0f5aec810b",
224
- "target_handle_id": "9d74571f-b7f5-4c1d-8b7c-b9c648738a4d",
225
- "type": "DEFAULT",
226
- },
227
- ],
228
- "display_data": {"viewport": {"x": 0.0, "y": 0.0, "zoom": 1.0}},
229
- "definition": {
230
- "name": "IterationSubworkflow",
231
- "module": [
232
- "tests",
233
- "workflows",
234
- "basic_map_node",
235
- "workflow",
236
- ],
237
- },
238
- "output_values": [
239
- {
240
- "output_variable_id": "2a957315-fae0-4366-8a35-f0b315c5eade",
241
- "value": {
242
- "type": "NODE_OUTPUT",
243
- "node_id": "9dffa9e5-00e3-4d20-8ab8-ad0412f35bf2",
244
- "node_output_id": "3d97725d-a423-4072-9a73-7b6517edc76e",
245
- },
246
- }
247
- ],
248
- },
249
- "input_variables": [
250
- {
251
- "id": "b29bb546-9bc8-4136-857d-8c7a464ba9d4",
252
- "key": "item",
253
- "type": "JSON",
254
- "required": True,
255
- "default": None,
256
- "extensions": {"color": None},
257
- },
258
- {
259
- "id": "17e7ca49-668f-450d-a792-e1f97d13db67",
260
- "key": "index",
261
- "type": "NUMBER",
262
- "required": True,
263
- "default": None,
264
- "extensions": {"color": None},
265
- },
266
- {
267
- "id": "0acef1e7-caa1-4d9f-bb69-6981729af18d",
268
- "key": "items",
269
- "type": "JSON",
270
- "required": True,
271
- "default": None,
272
- "extensions": {"color": None},
273
- },
274
- ],
275
- "output_variables": [{"id": "2a957315-fae0-4366-8a35-f0b315c5eade", "key": "count", "type": "NUMBER"}],
276
- "concurrency": None,
277
- "items_input_id": "0acef1e7-caa1-4d9f-bb69-6981729af18d",
278
- "item_input_id": "b29bb546-9bc8-4136-857d-8c7a464ba9d4",
279
- "index_input_id": "17e7ca49-668f-450d-a792-e1f97d13db67",
280
- },
281
- "display_data": {"position": {"x": 200.0, "y": -50.0}},
282
- "base": {
283
- "name": "MapNode",
284
- "module": ["vellum", "workflows", "nodes", "core", "map_node", "node"],
285
- },
286
- "definition": {
287
- "name": "MapFruitsNode",
288
- "module": ["tests", "workflows", "basic_map_node", "workflow"],
289
- },
290
- "trigger": {
291
- "id": "e16e9d55-5f26-4d89-8c7a-939f1f463d80",
292
- "merge_behavior": "AWAIT_ATTRIBUTES",
293
- },
294
- "ports": [{"id": "aff8a80e-7ce7-43d2-9c9e-9d137efd3b33", "name": "default", "type": "DEFAULT"}],
295
- },
296
- map_node,
297
- ignore_order=True,
298
- )
299
-
300
- assert not DeepDiff(
301
- {
302
- "id": "bacc5d55-07d4-4a0a-a69e-831524480de5",
303
- "type": "TERMINAL",
304
- "data": {
305
- "label": "Final Output",
306
- "name": "final_value",
307
- "target_handle_id": "720dd872-2f3d-47b9-8245-89387f04f300",
308
- "output_id": "145b0b68-224b-4f83-90e6-eea3457e6c3e",
309
- "output_type": "JSON",
310
- "node_input_id": "57fe72e9-cc9f-48f2-b5ea-25ac52637a33",
311
- },
312
- "inputs": [
313
- {
314
- "id": "57fe72e9-cc9f-48f2-b5ea-25ac52637a33",
315
- "key": "node_input",
316
- "value": {
317
- "rules": [
318
- {
319
- "type": "NODE_OUTPUT",
320
- "data": {
321
- "node_id": "f2f94af1-fcbe-497c-80ce-80952c8903c8",
322
- "output_id": "2a957315-fae0-4366-8a35-f0b315c5eade",
323
- },
324
- }
325
- ],
326
- "combinator": "OR",
327
- },
328
- }
329
- ],
330
- "display_data": {"position": {"x": 400.0, "y": -50.0}},
331
- "base": {
332
- "module": [
333
- "vellum",
334
- "workflows",
335
- "nodes",
336
- "displayable",
337
- "final_output_node",
338
- "node",
339
- ],
340
- "name": "FinalOutputNode",
341
- },
342
- "definition": None,
343
- },
344
- workflow_raw_data["nodes"][2],
345
- # TODO: Fix output ID not referencing map node workflow output
346
- # https://app.shortcut.com/vellum/story/5667/fix-output-display-reference-on-map-nodes
347
- exclude_regex_paths=r"root\['inputs'\]\[0\]\['value'\]\['rules'\]\[0\]\['data'\]\['output_id'\]",
348
- )
349
-
350
- # AND each edge should be serialized correctly
351
- serialized_edges = workflow_raw_data["edges"]
352
- assert not DeepDiff(
353
- [
354
- {
355
- "id": "528eb20a-9db4-4c01-87c0-39b9f5f09753",
356
- "source_node_id": "c0aa464d-1685-4f15-a051-31b426fec92e",
357
- "source_handle_id": "844d992e-60ab-4af2-a8ff-52cd858386f7",
358
- "target_node_id": "f2f94af1-fcbe-497c-80ce-80952c8903c8",
359
- "target_handle_id": "e16e9d55-5f26-4d89-8c7a-939f1f463d80",
360
- "type": "DEFAULT",
361
- },
362
- {
363
- "id": "47a34f6e-d139-4702-aa46-6212bb8a150f",
364
- "source_node_id": "f2f94af1-fcbe-497c-80ce-80952c8903c8",
365
- "source_handle_id": "aff8a80e-7ce7-43d2-9c9e-9d137efd3b33",
366
- "target_node_id": "bacc5d55-07d4-4a0a-a69e-831524480de5",
367
- "target_handle_id": "720dd872-2f3d-47b9-8245-89387f04f300",
368
- "type": "DEFAULT",
369
- },
370
- ],
371
- serialized_edges,
372
- ignore_order=True,
373
- )
374
-
375
- # AND the display data should be what we expect
376
- display_data = workflow_raw_data["display_data"]
377
- assert display_data == {
378
- "viewport": {
379
- "x": 0.0,
380
- "y": 0.0,
381
- "zoom": 1.0,
382
- }
383
- }
67
+ map_node = next(n for n in workflow_raw_data["nodes"] if (n.get("base") or {}).get("name") == "MapNode")
384
68
 
385
69
  # AND the definition should be what we expect
386
70
  definition = workflow_raw_data["definition"]
@@ -397,3 +81,57 @@ def test_serialize_workflow():
397
81
  # AND the map node's items input ID should match the subworkflow's items input ID
398
82
  items_input_id = map_node["data"]["items_input_id"]
399
83
  assert map_node["inputs"][0]["id"] == items_input_id
84
+
85
+
86
+ def test_serialize_workflow__dynamic_field_reference_items():
87
+ """Tests that a map node with items set to a dynamic field reference serializes correctly."""
88
+
89
+ # GIVEN a prompt node with json output
90
+ class MyPromptNode(InlinePromptNode):
91
+ ml_model = "gpt-4o"
92
+ blocks = []
93
+
94
+ # AND a simple subworkflow for the map node
95
+ class IterationNode(BaseNode):
96
+ item = MapNode.SubworkflowInputs.item
97
+
98
+ class Outputs(BaseOutputs):
99
+ value: str
100
+
101
+ def run(self) -> Outputs:
102
+ return self.Outputs(value=str(self.item))
103
+
104
+ class IterationSubworkflow(BaseWorkflow[MapNode.SubworkflowInputs, BaseState]):
105
+ graph = IterationNode
106
+
107
+ class Outputs(BaseOutputs):
108
+ value = IterationNode.Outputs.value
109
+
110
+ # AND a map node with items set to a dynamic field reference
111
+ class DynamicItemsMapNode(MapNode):
112
+ items = MyPromptNode.Outputs.json["items"]
113
+ subworkflow = IterationSubworkflow
114
+
115
+ # AND a workflow using these nodes
116
+ class DynamicFieldReferenceWorkflow(BaseWorkflow):
117
+ graph = MyPromptNode >> DynamicItemsMapNode
118
+
119
+ class Outputs(BaseOutputs):
120
+ result = DynamicItemsMapNode.Outputs.value
121
+
122
+ # WHEN we serialize the workflow
123
+ workflow_display = get_workflow_display(workflow_class=DynamicFieldReferenceWorkflow)
124
+ serialized_workflow: dict = workflow_display.serialize()
125
+
126
+ # THEN the map node should be serialized
127
+ workflow_raw_data = serialized_workflow["workflow_raw_data"]
128
+ map_node = next(n for n in workflow_raw_data["nodes"] if n.get("type") == "MAP")
129
+
130
+ # AND the attributes should contain the items with a BINARY_EXPRESSION
131
+ attributes = map_node["attributes"]
132
+ items_attribute = next(attr for attr in attributes if attr["name"] == "items")
133
+ items_value = items_attribute["value"]
134
+ assert items_value["type"] == "BINARY_EXPRESSION"
135
+ assert items_value["operator"] == "accessField"
136
+ assert items_value["rhs"]["type"] == "CONSTANT_VALUE"
137
+ assert items_value["rhs"]["value"]["value"] == "items"
@@ -36,8 +36,6 @@ def test_serialize_workflow__await_all():
36
36
 
37
37
  # AND its raw data should be what we expect
38
38
  workflow_raw_data = serialized_workflow["workflow_raw_data"]
39
- assert len(workflow_raw_data["edges"]) == 6
40
- assert len(workflow_raw_data["nodes"]) == 6
41
39
 
42
40
  # AND each node should be serialized correctly
43
41
  entrypoint_node = next(node for node in workflow_raw_data["nodes"] if node["type"] == "ENTRYPOINT")
@@ -93,71 +91,10 @@ def test_serialize_workflow__await_all():
93
91
  ignore_order_func=lambda x: x.path() == "root['data']['target_handles']",
94
92
  )
95
93
 
96
- final_output_node = next(node for node in workflow_raw_data["nodes"] if node["type"] == "TERMINAL")
97
- assert final_output_node == {
98
- "id": "8187ce10-62b7-4a2c-8c0f-297387915467",
99
- "type": "TERMINAL",
100
- "data": {
101
- "label": "Final Output",
102
- "name": "value",
103
- "target_handle_id": "ff55701c-16d3-4348-a633-6a298e71377d",
104
- "output_id": "959ba00d-d30b-402e-8676-76efc4c3d2ae",
105
- "output_type": "STRING",
106
- "node_input_id": "fed9d343-6504-460c-968b-d3f9658193d0",
107
- },
108
- "base": {
109
- "module": [
110
- "vellum",
111
- "workflows",
112
- "nodes",
113
- "displayable",
114
- "final_output_node",
115
- "node",
116
- ],
117
- "name": "FinalOutputNode",
118
- },
119
- "definition": None,
120
- "inputs": [
121
- {
122
- "id": "fed9d343-6504-460c-968b-d3f9658193d0",
123
- "key": "node_input",
124
- "value": {
125
- "rules": [
126
- {
127
- "type": "NODE_OUTPUT",
128
- "data": {
129
- "node_id": "6c34a839-552b-436d-ba6a-501f663883c8",
130
- "output_id": "f6148c39-9ec1-4b10-9d24-d19bec9eeea8",
131
- },
132
- }
133
- ],
134
- "combinator": "OR",
135
- },
136
- }
137
- ],
138
- "display_data": {"position": {"x": 800.0, "y": -50.0}},
139
- }
140
-
141
- # AND each edge should be serialized correctly
142
- serialized_edges = workflow_raw_data["edges"]
94
+ # AND each edge feeding into the merge node should be serialized correctly
95
+ merge_target_edges = [edge for edge in workflow_raw_data["edges"] if edge["target_node_id"] == merge_node["id"]]
143
96
  assert not DeepDiff(
144
97
  [
145
- {
146
- "id": "ea747507-68d5-4c72-8d00-a464ff7a55f1",
147
- "source_node_id": "dc8aecd0-49ba-4464-a45f-29d3bfd686e4",
148
- "source_handle_id": "017d40f5-8326-4e42-a409-b08995defaa8",
149
- "target_node_id": "0871708d-8f05-4bc8-b3fb-a8624dae51de",
150
- "target_handle_id": "01543a95-6bcb-46e2-a16c-570008972b88",
151
- "type": "DEFAULT",
152
- },
153
- {
154
- "id": "2c28f06b-4f4a-4531-8cf9-860089ce1cc2",
155
- "source_node_id": "dc8aecd0-49ba-4464-a45f-29d3bfd686e4",
156
- "source_handle_id": "017d40f5-8326-4e42-a409-b08995defaa8",
157
- "target_node_id": "0306d2a2-8e2a-49d1-bc4d-4026fbd98c4c",
158
- "target_handle_id": "5b10f22e-ae81-4ca5-a682-12d3c3ec73c1",
159
- "type": "DEFAULT",
160
- },
161
98
  {
162
99
  "id": "3870f290-8da7-43a8-b875-60510c060380",
163
100
  "source_node_id": "0306d2a2-8e2a-49d1-bc4d-4026fbd98c4c",
@@ -174,24 +111,8 @@ def test_serialize_workflow__await_all():
174
111
  "target_handle_id": "6da3e50a-8c6d-4de1-8ee9-da26f7c9552f",
175
112
  "type": "DEFAULT",
176
113
  },
177
- {
178
- "id": "5344fbf3-6a71-4890-93a6-c6a2c5a4e50c",
179
- "source_node_id": "f07c263c-65a3-4b58-83c1-f4a29123f167",
180
- "source_handle_id": "da1bdfe9-8e99-4d06-842f-a76af95a713a",
181
- "target_node_id": "6c34a839-552b-436d-ba6a-501f663883c8",
182
- "target_handle_id": "413c3699-a37b-49cd-93fd-fe6d041a0119",
183
- "type": "DEFAULT",
184
- },
185
- {
186
- "id": "3d031c93-09b1-4937-9f98-c30a7ba6823d",
187
- "source_node_id": "6c34a839-552b-436d-ba6a-501f663883c8",
188
- "source_handle_id": "48beca40-00f3-4273-b2ea-5e1ac6494839",
189
- "target_node_id": "8187ce10-62b7-4a2c-8c0f-297387915467",
190
- "target_handle_id": "ff55701c-16d3-4348-a633-6a298e71377d",
191
- "type": "DEFAULT",
192
- },
193
114
  ],
194
- serialized_edges,
115
+ merge_target_edges,
195
116
  ignore_order=True,
196
117
  )
197
118