vellum-ai 1.0.11__py3-none-any.whl → 1.1.1__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.
Files changed (125) hide show
  1. vellum/__init__.py +2 -2
  2. vellum/client/README.md +0 -55
  3. vellum/client/__init__.py +159 -877
  4. vellum/client/core/__init__.py +3 -0
  5. vellum/client/core/client_wrapper.py +2 -2
  6. vellum/client/core/http_response.py +47 -0
  7. vellum/client/raw_client.py +1561 -0
  8. vellum/client/reference.md +22 -696
  9. vellum/client/resources/__init__.py +0 -2
  10. vellum/client/resources/ad_hoc/client.py +55 -161
  11. vellum/client/resources/ad_hoc/raw_client.py +278 -0
  12. vellum/client/resources/container_images/client.py +62 -172
  13. vellum/client/resources/container_images/raw_client.py +400 -0
  14. vellum/client/resources/deployments/client.py +112 -437
  15. vellum/client/resources/deployments/raw_client.py +995 -0
  16. vellum/client/resources/document_indexes/client.py +108 -317
  17. vellum/client/resources/document_indexes/raw_client.py +847 -0
  18. vellum/client/resources/documents/client.py +88 -285
  19. vellum/client/resources/documents/raw_client.py +655 -0
  20. vellum/client/resources/folder_entities/client.py +54 -92
  21. vellum/client/resources/folder_entities/raw_client.py +277 -0
  22. vellum/client/resources/metric_definitions/client.py +48 -95
  23. vellum/client/resources/metric_definitions/raw_client.py +225 -0
  24. vellum/client/resources/ml_models/client.py +36 -40
  25. vellum/client/resources/ml_models/raw_client.py +103 -0
  26. vellum/client/resources/organizations/client.py +34 -39
  27. vellum/client/resources/organizations/raw_client.py +96 -0
  28. vellum/client/resources/prompts/client.py +50 -193
  29. vellum/client/resources/prompts/raw_client.py +346 -0
  30. vellum/client/resources/sandboxes/client.py +68 -141
  31. vellum/client/resources/sandboxes/raw_client.py +393 -0
  32. vellum/client/resources/test_suite_runs/client.py +58 -141
  33. vellum/client/resources/test_suite_runs/raw_client.py +355 -0
  34. vellum/client/resources/test_suites/client.py +73 -141
  35. vellum/client/resources/test_suites/raw_client.py +379 -0
  36. vellum/client/resources/workflow_deployments/client.py +203 -328
  37. vellum/client/resources/workflow_deployments/raw_client.py +931 -0
  38. vellum/client/resources/workflow_executions/client.py +36 -40
  39. vellum/client/resources/workflow_executions/raw_client.py +97 -0
  40. vellum/client/resources/workflow_sandboxes/client.py +60 -108
  41. vellum/client/resources/workflow_sandboxes/raw_client.py +300 -0
  42. vellum/client/resources/workflows/client.py +68 -133
  43. vellum/client/resources/workflows/raw_client.py +307 -0
  44. vellum/client/resources/workspace_secrets/client.py +46 -90
  45. vellum/client/resources/workspace_secrets/raw_client.py +220 -0
  46. vellum/client/resources/workspaces/client.py +34 -39
  47. vellum/client/resources/workspaces/raw_client.py +96 -0
  48. vellum/client/types/__init__.py +2 -0
  49. vellum/client/types/api_request_parent_context.py +1 -0
  50. vellum/client/types/external_parent_context.py +36 -0
  51. vellum/client/types/node_execution_fulfilled_event.py +1 -0
  52. vellum/client/types/node_execution_initiated_event.py +1 -0
  53. vellum/client/types/node_execution_paused_event.py +1 -0
  54. vellum/client/types/node_execution_rejected_event.py +1 -0
  55. vellum/client/types/node_execution_resumed_event.py +1 -0
  56. vellum/client/types/node_execution_span.py +1 -0
  57. vellum/client/types/node_execution_span_attributes.py +1 -0
  58. vellum/client/types/node_execution_streaming_event.py +1 -0
  59. vellum/client/types/node_parent_context.py +1 -0
  60. vellum/client/types/parent_context.py +2 -0
  61. vellum/client/types/prompt_deployment_parent_context.py +1 -0
  62. vellum/client/types/slim_workflow_execution_read.py +1 -0
  63. vellum/client/types/span_link.py +1 -0
  64. vellum/client/types/workflow_deployment_event_executions_response.py +1 -0
  65. vellum/client/types/workflow_deployment_parent_context.py +1 -0
  66. vellum/client/types/workflow_event_execution_read.py +1 -0
  67. vellum/client/types/workflow_execution_detail.py +1 -0
  68. vellum/client/types/workflow_execution_fulfilled_event.py +1 -0
  69. vellum/client/types/workflow_execution_initiated_event.py +1 -0
  70. vellum/client/types/workflow_execution_paused_event.py +1 -0
  71. vellum/client/types/workflow_execution_rejected_event.py +1 -0
  72. vellum/client/types/workflow_execution_resumed_event.py +1 -0
  73. vellum/client/types/workflow_execution_snapshotted_event.py +1 -0
  74. vellum/client/types/workflow_execution_span.py +1 -0
  75. vellum/client/types/workflow_execution_span_attributes.py +1 -0
  76. vellum/client/types/workflow_execution_streaming_event.py +1 -0
  77. vellum/client/types/workflow_parent_context.py +1 -0
  78. vellum/client/types/workflow_sandbox_parent_context.py +1 -0
  79. vellum/{resources/release_reviews/__init__.py → core/http_response.py} +1 -1
  80. vellum/{resources/release_reviews/client.py → raw_client.py} +1 -1
  81. vellum/resources/ad_hoc/raw_client.py +3 -0
  82. vellum/resources/container_images/raw_client.py +3 -0
  83. vellum/resources/deployments/raw_client.py +3 -0
  84. vellum/resources/document_indexes/raw_client.py +3 -0
  85. vellum/resources/documents/raw_client.py +3 -0
  86. vellum/resources/folder_entities/raw_client.py +3 -0
  87. vellum/resources/metric_definitions/raw_client.py +3 -0
  88. vellum/resources/ml_models/raw_client.py +3 -0
  89. vellum/resources/organizations/raw_client.py +3 -0
  90. vellum/resources/prompts/raw_client.py +3 -0
  91. vellum/resources/sandboxes/raw_client.py +3 -0
  92. vellum/resources/test_suite_runs/raw_client.py +3 -0
  93. vellum/resources/test_suites/raw_client.py +3 -0
  94. vellum/resources/workflow_deployments/raw_client.py +3 -0
  95. vellum/resources/workflow_executions/raw_client.py +3 -0
  96. vellum/resources/workflow_sandboxes/raw_client.py +3 -0
  97. vellum/resources/workflows/raw_client.py +3 -0
  98. vellum/resources/workspace_secrets/raw_client.py +3 -0
  99. vellum/resources/workspaces/raw_client.py +3 -0
  100. vellum/types/external_parent_context.py +3 -0
  101. vellum/workflows/emitters/vellum_emitter.py +3 -2
  102. vellum/workflows/events/types.py +6 -0
  103. vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py +5 -15
  104. vellum/workflows/nodes/displayable/tool_calling_node/node.py +6 -0
  105. vellum/workflows/nodes/displayable/tool_calling_node/utils.py +75 -0
  106. vellum/workflows/state/context.py +13 -2
  107. vellum/workflows/types/definition.py +2 -2
  108. vellum/workflows/types/tests/test_definition.py +2 -3
  109. vellum/workflows/utils/functions.py +1 -1
  110. vellum/workflows/utils/tests/test_functions.py +3 -3
  111. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/METADATA +1 -1
  112. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/RECORD +123 -81
  113. vellum_ee/workflows/display/exceptions.py +7 -0
  114. vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +2 -1
  115. vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +53 -2
  116. vellum_ee/workflows/display/nodes/vellum/tests/test_tool_calling_node.py +93 -0
  117. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_mcp_serialization.py +98 -0
  118. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_workflow_deployment_serialization.py +1 -1
  119. vellum_ee/workflows/display/utils/expressions.py +1 -1
  120. vellum_ee/workflows/display/workflows/base_workflow_display.py +2 -1
  121. vellum/client/resources/release_reviews/__init__.py +0 -2
  122. vellum/client/resources/release_reviews/client.py +0 -139
  123. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/LICENSE +0 -0
  124. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/WHEEL +0 -0
  125. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/entry_points.txt +0 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  from ..core.pydantic_utilities import UniversalBaseModel
4
4
  from .api_request_parent_context import ApiRequestParentContext
5
+ from .external_parent_context import ExternalParentContext
5
6
  from .node_parent_context import NodeParentContext
6
7
  from .prompt_deployment_parent_context import PromptDeploymentParentContext
7
8
  from .span_link import SpanLink
@@ -2,6 +2,7 @@
2
2
 
3
3
  from ..core.pydantic_utilities import UniversalBaseModel
4
4
  from .api_request_parent_context import ApiRequestParentContext
5
+ from .external_parent_context import ExternalParentContext
5
6
  from .node_parent_context import NodeParentContext
6
7
  from .prompt_deployment_parent_context import PromptDeploymentParentContext
7
8
  from .span_link import SpanLink
@@ -2,6 +2,7 @@
2
2
 
3
3
  from ..core.pydantic_utilities import UniversalBaseModel
4
4
  from .api_request_parent_context import ApiRequestParentContext
5
+ from .external_parent_context import ExternalParentContext
5
6
  from .node_parent_context import NodeParentContext
6
7
  from .prompt_deployment_parent_context import PromptDeploymentParentContext
7
8
  from .span_link import SpanLink
@@ -2,6 +2,7 @@
2
2
 
3
3
  from ..core.pydantic_utilities import UniversalBaseModel
4
4
  from .api_request_parent_context import ApiRequestParentContext
5
+ from .external_parent_context import ExternalParentContext
5
6
  from .node_parent_context import NodeParentContext
6
7
  from .prompt_deployment_parent_context import PromptDeploymentParentContext
7
8
  from .span_link import SpanLink
@@ -8,6 +8,7 @@ import pydantic
8
8
 
9
9
  class WorkflowExecutionSpanAttributes(UniversalBaseModel):
10
10
  label: str
11
+ workflow_id: str
11
12
 
12
13
  if IS_PYDANTIC_V2:
13
14
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -2,6 +2,7 @@
2
2
 
3
3
  from ..core.pydantic_utilities import UniversalBaseModel
4
4
  from .api_request_parent_context import ApiRequestParentContext
5
+ from .external_parent_context import ExternalParentContext
5
6
  from .node_parent_context import NodeParentContext
6
7
  from .prompt_deployment_parent_context import PromptDeploymentParentContext
7
8
  from .span_link import SpanLink
@@ -27,6 +27,7 @@ class WorkflowParentContext(UniversalBaseModel):
27
27
 
28
28
 
29
29
  from .api_request_parent_context import ApiRequestParentContext # noqa: E402
30
+ from .external_parent_context import ExternalParentContext # noqa: E402
30
31
  from .node_parent_context import NodeParentContext # noqa: E402
31
32
  from .prompt_deployment_parent_context import PromptDeploymentParentContext # noqa: E402
32
33
  from .span_link import SpanLink # noqa: E402
@@ -28,6 +28,7 @@ class WorkflowSandboxParentContext(UniversalBaseModel):
28
28
 
29
29
 
30
30
  from .api_request_parent_context import ApiRequestParentContext # noqa: E402
31
+ from .external_parent_context import ExternalParentContext # noqa: E402
31
32
  from .node_parent_context import NodeParentContext # noqa: E402
32
33
  from .prompt_deployment_parent_context import PromptDeploymentParentContext # noqa: E402
33
34
  from .span_link import SpanLink # noqa: E402
@@ -1,3 +1,3 @@
1
1
  # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
2
 
3
- from vellum.client.resources.release_reviews import *
3
+ from vellum.client.core.http_response import *
@@ -1,3 +1,3 @@
1
1
  # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
2
 
3
- from vellum.client.resources.release_reviews.client import *
3
+ from vellum.client.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.ad_hoc.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.container_images.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.deployments.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.document_indexes.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.documents.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.folder_entities.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.metric_definitions.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.ml_models.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.organizations.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.prompts.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.sandboxes.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.test_suite_runs.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.test_suites.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workflow_deployments.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workflow_executions.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workflow_sandboxes.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workflows.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workspace_secrets.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.resources.workspaces.raw_client import *
@@ -0,0 +1,3 @@
1
+ # WARNING: This file will be removed in a future release. Please import from "vellum.client" instead.
2
+
3
+ from vellum.client.types.external_parent_context import *
@@ -41,7 +41,7 @@ class VellumEmitter(BaseWorkflowEmitter):
41
41
  super().__init__()
42
42
  self._timeout = timeout
43
43
  self._max_retries = max_retries
44
- self._events_endpoint = "events" # TODO: make this configurable with the correct url
44
+ self._events_endpoint = "v1/events" # TODO: make this configurable with the correct url
45
45
 
46
46
  def emit_event(self, event: WorkflowEvent) -> None:
47
47
  """
@@ -90,7 +90,8 @@ class VellumEmitter(BaseWorkflowEmitter):
90
90
  base_url = client._client_wrapper.get_environment().default
91
91
  response = client._client_wrapper.httpx_client.request(
92
92
  method="POST",
93
- path=f"{base_url}/{self._events_endpoint}", # TODO: will be replaced with the correct url
93
+ base_url=base_url,
94
+ path=self._events_endpoint, # TODO: will be replaced with the correct url
94
95
  json=event_data,
95
96
  headers=client._client_wrapper.get_headers(),
96
97
  request_options={"timeout_in_seconds": self._timeout},
@@ -80,6 +80,11 @@ class UnknownParentContext(BaseParentContext):
80
80
  type: Literal["UNKNOWN"] = "UNKNOWN"
81
81
 
82
82
 
83
+ # Setting external parent context for external workflows
84
+ class ExternalParentContext(BaseParentContext):
85
+ type: Literal["EXTERNAL"] = "EXTERNAL"
86
+
87
+
83
88
  def _cast_parent_context_discriminator(v: Any) -> Any:
84
89
  if v in PARENT_CONTEXT_TYPES:
85
90
  return v
@@ -138,6 +143,7 @@ ParentContext = Annotated[
138
143
  PromptDeploymentParentContext,
139
144
  WorkflowSandboxParentContext,
140
145
  APIRequestParentContext,
146
+ ExternalParentContext,
141
147
  UnknownParentContext,
142
148
  ],
143
149
  ParentContextDiscriminator(),
@@ -1,4 +1,3 @@
1
- from unittest import mock
2
1
  from uuid import uuid4
3
2
  from typing import Any, Iterator, List
4
3
 
@@ -64,17 +63,8 @@ def test_text_prompt_deployment_node__basic(vellum_client):
64
63
  assert text_output.value == "Hello, world!"
65
64
 
66
65
  # AND we should have made the expected call to stream the prompt execution
67
- vellum_client.execute_prompt_stream.assert_called_once_with(
68
- expand_meta=None,
69
- expand_raw=None,
70
- external_id=None,
71
- inputs=[],
72
- metadata=None,
73
- prompt_deployment_id=None,
74
- prompt_deployment_name="my-deployment",
75
- raw_overrides=None,
76
- release_tag="LATEST",
77
- request_options={
78
- "additional_body_parameters": {"execution_context": {"parent_context": None, "trace_id": mock.ANY}}
79
- },
80
- )
66
+ vellum_client.execute_prompt_stream.assert_called_once()
67
+ _, call_kwargs = vellum_client.execute_prompt_stream.call_args
68
+ exec_ctx = call_kwargs["request_options"]["additional_body_parameters"]["execution_context"]
69
+ assert exec_ctx["parent_context"] is not None
70
+ assert exec_ctx["parent_context"]["type"] == "EXTERNAL"
@@ -15,6 +15,7 @@ from vellum.workflows.nodes.displayable.tool_calling_node.utils import (
15
15
  create_else_node,
16
16
  create_function_node,
17
17
  create_mcp_tool_node,
18
+ create_router_node,
18
19
  create_tool_router_node,
19
20
  get_function_name,
20
21
  get_mcp_tool_name,
@@ -145,6 +146,11 @@ class ToolCallingNode(BaseNode[StateType], Generic[StateType]):
145
146
  max_prompt_iterations=self.max_prompt_iterations,
146
147
  )
147
148
 
149
+ self.router_node = create_router_node(
150
+ functions=self.functions,
151
+ tool_router_node=self.tool_router_node,
152
+ )
153
+
148
154
  self._function_nodes = {}
149
155
  for function in self.functions:
150
156
  if isinstance(function, MCPServer):
@@ -112,6 +112,18 @@ class ToolRouterNode(InlinePromptNode[ToolCallingState]):
112
112
  yield output
113
113
 
114
114
 
115
+ class RouterNode(BaseNode[ToolCallingState]):
116
+ """Router node that handles routing to function nodes based on outputs."""
117
+
118
+ class Trigger(BaseNode.Trigger):
119
+ merge_behavior = MergeBehavior.AWAIT_ATTRIBUTES
120
+
121
+ def run(self) -> Iterator[BaseOutput]:
122
+ # Router node doesn't process outputs or create chat messages
123
+ # It just handles the routing logic via its ports
124
+ yield from []
125
+
126
+
115
127
  class DynamicSubworkflowDeploymentNode(SubworkflowDeploymentNode[ToolCallingState], FunctionCallNodeMixin):
116
128
  """Node that executes a deployment definition with function call output."""
117
129
 
@@ -423,6 +435,69 @@ def create_tool_router_node(
423
435
  return node
424
436
 
425
437
 
438
+ def create_router_node(
439
+ functions: List[Tool],
440
+ tool_router_node: Type[ToolRouterNode],
441
+ ) -> Type[RouterNode]:
442
+ """Create a RouterNode with the same ports as ToolRouterNode."""
443
+
444
+ if functions and len(functions) > 0:
445
+ # Create dynamic ports and convert functions in a single loop
446
+ Ports = type("Ports", (), {})
447
+
448
+ def create_port_condition(fn_name):
449
+ return Port.on_if(
450
+ LazyReference(
451
+ lambda: (
452
+ ToolCallingState.current_prompt_output_index.less_than(
453
+ tool_router_node.Outputs.results.length()
454
+ )
455
+ & tool_router_node.Outputs.results[ToolCallingState.current_prompt_output_index]["type"].equals(
456
+ "FUNCTION_CALL"
457
+ )
458
+ & tool_router_node.Outputs.results[ToolCallingState.current_prompt_output_index]["value"][
459
+ "name"
460
+ ].equals(fn_name)
461
+ )
462
+ )
463
+ )
464
+
465
+ for function in functions:
466
+ if isinstance(function, ComposioToolDefinition):
467
+ function_name = get_function_name(function)
468
+ port = create_port_condition(function_name)
469
+ setattr(Ports, function_name, port)
470
+ elif isinstance(function, MCPServer):
471
+ tool_functions: List[MCPToolDefinition] = hydrate_mcp_tool_definitions(function)
472
+ for tool_function in tool_functions:
473
+ name = get_mcp_tool_name(tool_function)
474
+ port = create_port_condition(name)
475
+ setattr(Ports, name, port)
476
+ else:
477
+ function_name = get_function_name(function)
478
+ port = create_port_condition(function_name)
479
+ setattr(Ports, function_name, port)
480
+
481
+ # Add the else port for when no function conditions match
482
+ setattr(Ports, "default", Port.on_else())
483
+ else:
484
+ # If no functions exist, create a simple Ports class with just a default port
485
+ Ports = type("Ports", (), {"default": Port(default=True)})
486
+
487
+ node = cast(
488
+ Type[RouterNode],
489
+ type(
490
+ "RouterNode",
491
+ (RouterNode,),
492
+ {
493
+ "Ports": Ports,
494
+ "__module__": __name__,
495
+ },
496
+ ),
497
+ )
498
+ return node
499
+
500
+
426
501
  def create_function_node(
427
502
  function: ToolBase,
428
503
  tool_router_node: Type[ToolRouterNode],
@@ -1,9 +1,11 @@
1
1
  from functools import cached_property
2
2
  from queue import Queue
3
+ from uuid import uuid4
3
4
  from typing import TYPE_CHECKING, Dict, List, Optional, Type
4
5
 
5
6
  from vellum import Vellum
6
7
  from vellum.workflows.context import ExecutionContext, get_execution_context
8
+ from vellum.workflows.events.types import ExternalParentContext
7
9
  from vellum.workflows.nodes.mocks import MockNodeExecution, MockNodeExecutionArg
8
10
  from vellum.workflows.outputs.base import BaseOutputs
9
11
  from vellum.workflows.references.constant import ConstantValueReference
@@ -25,8 +27,17 @@ class WorkflowContext:
25
27
  self._event_queue: Optional[Queue["WorkflowEvent"]] = None
26
28
  self._node_output_mocks_map: Dict[Type[BaseOutputs], List[MockNodeExecution]] = {}
27
29
  self._execution_context = get_execution_context()
28
- if not self._execution_context.parent_context and execution_context:
29
- self._execution_context = execution_context
30
+
31
+ if execution_context is not None:
32
+
33
+ self._execution_context.trace_id = execution_context.trace_id
34
+
35
+ if execution_context.parent_context is not None:
36
+ self._execution_context.parent_context = execution_context.parent_context
37
+
38
+ if self._execution_context.parent_context is None:
39
+ self._execution_context.parent_context = ExternalParentContext(span_id=uuid4())
40
+
30
41
  self._generated_files = generated_files
31
42
 
32
43
  @cached_property
@@ -8,7 +8,6 @@ from pydantic import BeforeValidator
8
8
 
9
9
  from vellum.client.core.pydantic_utilities import UniversalBaseModel
10
10
  from vellum.client.types.code_resource_definition import CodeResourceDefinition as ClientCodeResourceDefinition
11
- from vellum.client.types.vellum_secret import VellumSecret
12
11
  from vellum.workflows.constants import AuthorizationType
13
12
  from vellum.workflows.references.environment_variable import EnvironmentVariableReference
14
13
 
@@ -120,12 +119,13 @@ class ComposioToolDefinition(UniversalBaseModel):
120
119
 
121
120
 
122
121
  class MCPServer(UniversalBaseModel):
122
+ type: Literal["MCP_SERVER"] = "MCP_SERVER"
123
123
  name: str
124
124
  url: str
125
125
  authorization_type: AuthorizationType = AuthorizationType.BEARER_TOKEN
126
126
  bearer_token_value: Optional[Union[str, EnvironmentVariableReference]] = None
127
127
  api_key_header_key: Optional[str] = None
128
- api_key_header_value: Optional[Union[str, VellumSecret]] = None
128
+ api_key_header_value: Optional[Union[str, EnvironmentVariableReference]] = None
129
129
 
130
130
  model_config = {"arbitrary_types_allowed": True}
131
131
 
@@ -1,7 +1,6 @@
1
1
  import pytest
2
2
  from uuid import UUID
3
3
 
4
- from vellum.client.types.vellum_secret import VellumSecret
5
4
  from vellum.workflows.constants import AuthorizationType
6
5
  from vellum.workflows.references.environment_variable import EnvironmentVariableReference
7
6
  from vellum.workflows.types.definition import ComposioToolDefinition, DeploymentDefinition, MCPServer, MCPToolDefinition
@@ -98,7 +97,7 @@ def test_mcp_tool_definition_creation_api_key():
98
97
  url="https://api.githubcopilot.com/mcp/",
99
98
  authorization_type=AuthorizationType.API_KEY,
100
99
  api_key_header_key="Authorization",
101
- api_key_header_value=VellumSecret(name="GITHUB_PERSONAL_ACCESS_TOKEN"),
100
+ api_key_header_value=EnvironmentVariableReference(name="GITHUB_PERSONAL_ACCESS_TOKEN"),
102
101
  ),
103
102
  parameters={
104
103
  "type": "object",
@@ -115,7 +114,7 @@ def test_mcp_tool_definition_creation_api_key():
115
114
  assert mcp_tool.server.url == "https://api.githubcopilot.com/mcp/"
116
115
  assert mcp_tool.server.authorization_type == AuthorizationType.API_KEY
117
116
  assert mcp_tool.server.api_key_header_key == "Authorization"
118
- assert isinstance(mcp_tool.server.api_key_header_value, VellumSecret)
117
+ assert isinstance(mcp_tool.server.api_key_header_value, EnvironmentVariableReference)
119
118
  assert mcp_tool.server.api_key_header_value.name == "GITHUB_PERSONAL_ACCESS_TOKEN"
120
119
  assert mcp_tool.parameters == {
121
120
  "type": "object",
@@ -221,7 +221,7 @@ def compile_workflow_deployment_function_definition(
221
221
  deployment = deployment_config["deployment"]
222
222
  release_tag = deployment_config["release_tag"]
223
223
 
224
- workflow_deployment_release = vellum_client.release_reviews.retrieve_workflow_deployment_release(
224
+ workflow_deployment_release = vellum_client.workflow_deployments.retrieve_workflow_deployment_release(
225
225
  deployment, release_tag
226
226
  )
227
227
 
@@ -448,7 +448,7 @@ def test_compile_workflow_deployment_function_definition__just_name():
448
448
  mock_release = Mock()
449
449
  mock_release.workflow_version.input_variables = []
450
450
  mock_release.description = "This is a test deployment"
451
- mock_client.release_reviews.retrieve_workflow_deployment_release.return_value = mock_release
451
+ mock_client.workflow_deployments.retrieve_workflow_deployment_release.return_value = mock_release
452
452
 
453
453
  deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
454
454
 
@@ -494,7 +494,7 @@ def test_compile_workflow_deployment_function_definition__all_args():
494
494
 
495
495
  mock_release.workflow_version.input_variables = mock_inputs
496
496
  mock_release.description = "This is a test deployment"
497
- mock_client.release_reviews.retrieve_workflow_deployment_release.return_value = mock_release
497
+ mock_client.workflow_deployments.retrieve_workflow_deployment_release.return_value = mock_release
498
498
 
499
499
  deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
500
500
 
@@ -562,7 +562,7 @@ def test_compile_workflow_deployment_function_definition__defaults():
562
562
 
563
563
  mock_release.workflow_version.input_variables = mock_inputs
564
564
  mock_release.description = "This is a test deployment"
565
- mock_client.release_reviews.retrieve_workflow_deployment_release.return_value = mock_release
565
+ mock_client.workflow_deployments.retrieve_workflow_deployment_release.return_value = mock_release
566
566
 
567
567
  deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
568
568
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 1.0.11
3
+ Version: 1.1.1
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0