vellum-ai 0.14.87__py3-none-any.whl → 0.14.88__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.
@@ -16,10 +16,10 @@ class BaseClientWrapper:
16
16
 
17
17
  def get_headers(self) -> typing.Dict[str, str]:
18
18
  headers: typing.Dict[str, str] = {
19
- "User-Agent": "vellum-ai/0.14.87",
19
+ "User-Agent": "vellum-ai/0.14.88",
20
20
  "X-Fern-Language": "Python",
21
21
  "X-Fern-SDK-Name": "vellum-ai",
22
- "X-Fern-SDK-Version": "0.14.87",
22
+ "X-Fern-SDK-Version": "0.14.88",
23
23
  }
24
24
  headers["X-API-KEY"] = self.api_key
25
25
  return headers
@@ -103,7 +103,7 @@ def is_unresolved(value: Any) -> bool:
103
103
  return any(is_unresolved(getattr(value, field.name)) for field in dataclasses.fields(value))
104
104
 
105
105
  if isinstance(value, BaseModel):
106
- return any(is_unresolved(getattr(value, key)) for key in value.model_fields.keys())
106
+ return any(is_unresolved(getattr(value, key)) for key in value.__class__.model_fields.keys())
107
107
 
108
108
  if isinstance(value, Mapping):
109
109
  return any(is_unresolved(item) for item in value.values())
@@ -8,12 +8,14 @@ from vellum.client.types.function_call_chat_message_content import FunctionCallC
8
8
  from vellum.client.types.function_call_chat_message_content_value import FunctionCallChatMessageContentValue
9
9
  from vellum.client.types.string_chat_message_content import StringChatMessageContent
10
10
  from vellum.client.types.variable_prompt_block import VariablePromptBlock
11
+ from vellum.workflows.context import execution_context, get_parent_context
11
12
  from vellum.workflows.errors.types import WorkflowErrorCode
13
+ from vellum.workflows.events.workflow import is_workflow_event
12
14
  from vellum.workflows.exceptions import NodeException
13
15
  from vellum.workflows.nodes.bases import BaseNode
14
16
  from vellum.workflows.nodes.displayable.inline_prompt_node.node import InlinePromptNode
15
17
  from vellum.workflows.nodes.displayable.subworkflow_deployment_node.node import SubworkflowDeploymentNode
16
- from vellum.workflows.outputs.base import BaseOutput
18
+ from vellum.workflows.outputs.base import BaseOutput, BaseOutputs
17
19
  from vellum.workflows.ports.port import Port
18
20
  from vellum.workflows.references.lazy import LazyReference
19
21
  from vellum.workflows.state.context import WorkflowContext
@@ -21,6 +23,7 @@ from vellum.workflows.state.encoder import DefaultStateEncoder
21
23
  from vellum.workflows.types.core import EntityInputsInterface, MergeBehavior, Tool
22
24
  from vellum.workflows.types.definition import DeploymentDefinition
23
25
  from vellum.workflows.types.generics import is_workflow_class
26
+ from vellum.workflows.workflows.event_filters import all_workflow_event_filter
24
27
 
25
28
  CHAT_HISTORY_VARIABLE = "chat_history"
26
29
 
@@ -210,26 +213,60 @@ def create_function_node(
210
213
  elif is_workflow_class(function):
211
214
  # Create a class-level wrapper that calls the original function
212
215
  def execute_inline_workflow_function(self) -> BaseNode.Outputs:
213
- outputs = self.state.meta.node_outputs.get(tool_router_node.Outputs.text)
214
-
215
- outputs = json.loads(outputs)
216
- arguments = outputs["arguments"]
216
+ function_call_output = self.state.meta.node_outputs.get(tool_router_node.Outputs.results)
217
+ if function_call_output and len(function_call_output) > 0:
218
+ function_call = function_call_output[0]
219
+ arguments = function_call.value.arguments
220
+ else:
221
+ arguments = {}
217
222
 
218
223
  # Call the function based on its type
219
224
  inputs_instance = function.get_inputs_class()(**arguments)
220
- workflow = function(context=WorkflowContext.create_from(self._context))
221
- terminal_event = workflow.run(
222
- inputs=inputs_instance,
223
- )
224
- if terminal_event.name == "workflow.execution.paused":
225
+
226
+ with execution_context(parent_context=get_parent_context()):
227
+ workflow = function(
228
+ parent_state=self.state,
229
+ context=WorkflowContext.create_from(self._context),
230
+ )
231
+ subworkflow_stream = workflow.stream(
232
+ inputs=inputs_instance,
233
+ event_filter=all_workflow_event_filter,
234
+ node_output_mocks=self._context._get_all_node_output_mocks(),
235
+ )
236
+
237
+ outputs: Optional[BaseOutputs] = None
238
+ exception: Optional[NodeException] = None
239
+
240
+ for event in subworkflow_stream:
241
+ self._context._emit_subworkflow_event(event)
242
+ if exception:
243
+ continue
244
+
245
+ if not is_workflow_event(event):
246
+ continue
247
+ if event.workflow_definition != function:
248
+ continue
249
+
250
+ if event.name == "workflow.execution.fulfilled":
251
+ outputs = event.outputs
252
+ elif event.name == "workflow.execution.rejected":
253
+ exception = NodeException.of(event.error)
254
+ elif event.name == "workflow.execution.paused":
255
+ exception = NodeException(
256
+ code=WorkflowErrorCode.INVALID_OUTPUTS,
257
+ message="Subworkflow unexpectedly paused",
258
+ )
259
+
260
+ if exception:
261
+ raise exception
262
+
263
+ if outputs is None:
225
264
  raise NodeException(
265
+ message="Expected to receive outputs from inline subworkflow",
226
266
  code=WorkflowErrorCode.INVALID_OUTPUTS,
227
- message="Subworkflow unexpectedly paused",
228
267
  )
229
- elif terminal_event.name == "workflow.execution.fulfilled":
230
- result = terminal_event.outputs
231
- elif terminal_event.name == "workflow.execution.rejected":
232
- raise NodeException(message=terminal_event.error.message, code=terminal_event.error.code)
268
+
269
+ result = outputs
233
270
 
234
271
  self.state.chat_history.append(
235
272
  ChatMessage(
@@ -82,7 +82,7 @@ def _compile_default_value(default: Any) -> Any:
82
82
  if isinstance(default, BaseModel):
83
83
  return {
84
84
  field_name: _compile_default_value(getattr(default, field_name))
85
- for field_name in default.model_fields.keys()
85
+ for field_name in default.__class__.model_fields.keys()
86
86
  }
87
87
 
88
88
  return default
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 0.14.87
3
+ Version: 0.14.88
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0
@@ -144,7 +144,7 @@ vellum/client/README.md,sha256=47bNYmRLSISR1ING58kXXZ88nFLPGFv0bAspBtuXG3g,4306
144
144
  vellum/client/__init__.py,sha256=tKLc-F8I8_62RSZg7J7Lvo1dUQ_or7DGsDhbMyhWfGA,120958
145
145
  vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
146
146
  vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
147
- vellum/client/core/client_wrapper.py,sha256=ReGrzx3YGXetWtARuAHO8Rr64rj4PwB7DtupM9EEfkE,1916
147
+ vellum/client/core/client_wrapper.py,sha256=DiS34kxSaOHT-5h1HVeW53M67W2ZNWcKRBYI_HgjX_0,1916
148
148
  vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
149
149
  vellum/client/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
150
150
  vellum/client/core/http_client.py,sha256=cKs2w0ybDBk1wHQf-fTALm_MmvaMe3cZKcYJxqmCxkE,19539
@@ -1523,7 +1523,7 @@ vellum/workflows/descriptors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
1523
1523
  vellum/workflows/descriptors/base.py,sha256=X47a4TClHknsnjs53DkiXnop_5uLGVor487oxhHuGo4,14902
1524
1524
  vellum/workflows/descriptors/exceptions.py,sha256=gUy4UD9JFUKSeQnQpeuDSLiRqWjWiIsxLahB7p_q3JY,54
1525
1525
  vellum/workflows/descriptors/tests/test_utils.py,sha256=HJ5DoRz0sJvViGxyZ_FtytZjxN2J8xTkGtaVwCy6Q90,6928
1526
- vellum/workflows/descriptors/utils.py,sha256=gmVXJjf2yWmvlYey41J2FZHeSou0JuCHKb3826K_Jok,3838
1526
+ vellum/workflows/descriptors/utils.py,sha256=1siECBf6AI54gwwUwkF6mP9rYsRryUGaOYBbMpQaceM,3848
1527
1527
  vellum/workflows/edges/__init__.py,sha256=wSkmAnz9xyi4vZwtDbKxwlplt2skD7n3NsxkvR_pUus,50
1528
1528
  vellum/workflows/edges/edge.py,sha256=N0SnY3gKVuxImPAdCbPMPlHJIXbkQ3fwq_LbJRvVMFc,677
1529
1529
  vellum/workflows/emitters/__init__.py,sha256=YyOgaoLtVW8eFNEWODzCYb0HzL0PoSeNRf4diJ1Y0dk,80
@@ -1683,7 +1683,7 @@ vellum/workflows/nodes/displayable/tool_calling_node/node.py,sha256=7MqEtw-RejpJ
1683
1683
  vellum/workflows/nodes/displayable/tool_calling_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1684
1684
  vellum/workflows/nodes/displayable/tool_calling_node/tests/test_node.py,sha256=3cCCIz-quneCVl3w8XnGxzyHx-nn_jGTKCbSH9jkYT0,7824
1685
1685
  vellum/workflows/nodes/displayable/tool_calling_node/tests/test_utils.py,sha256=eu6WTyENhGLg9pGp_j69rysZjf_qiQXske1YdZn9PzU,1718
1686
- vellum/workflows/nodes/displayable/tool_calling_node/utils.py,sha256=6_SL3yOCh798MpPSuqGkIaLFeah6B7lj1bXI7_1hZ3s,11860
1686
+ vellum/workflows/nodes/displayable/tool_calling_node/utils.py,sha256=fYlfv0UZFgJ8A6wv586NawOztrA-6SFsZ4WyxhZFxl8,13292
1687
1687
  vellum/workflows/nodes/experimental/README.md,sha256=eF6DfIL8t-HbF9-mcofOMymKrraiBHDLKTlnBa51ZiE,284
1688
1688
  vellum/workflows/nodes/experimental/__init__.py,sha256=k7VQEyvgEdnrEZ-icXx3fiByPnyMOnMXNGGuqacyyik,91
1689
1689
  vellum/workflows/nodes/experimental/openai_chat_completion_node/__init__.py,sha256=lsyD9laR9p7kx5-BXGH2gUTM242UhKy8SMV0SR6S2iE,90
@@ -1741,7 +1741,7 @@ vellum/workflows/types/tests/test_definition.py,sha256=5wh_WEnE51epkoo-4PE-JbPlg
1741
1741
  vellum/workflows/types/tests/test_utils.py,sha256=UnZog59tR577mVwqZRqqWn2fScoOU1H6up0EzS8zYhw,2536
1742
1742
  vellum/workflows/types/utils.py,sha256=mTctHITBybpt4855x32oCKALBEcMNLn-9cCmfEKgJHQ,6498
1743
1743
  vellum/workflows/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1744
- vellum/workflows/utils/functions.py,sha256=ZN0rrIBF4R_KNt1CbRPVNGR36xEMUa1T7FkgZioou-Y,7185
1744
+ vellum/workflows/utils/functions.py,sha256=Gi08SYaTfLF04slbY_YcfP5erIMwtFgtYa59vhWez9k,7195
1745
1745
  vellum/workflows/utils/names.py,sha256=QLUqfJ1tmSEeUwBKTTiv_Qk3QGbInC2RSmlXfGXc8Wo,380
1746
1746
  vellum/workflows/utils/pydantic_schema.py,sha256=eR_bBtY-T0pttJP-ARwagSdCOnwPUtiT3cegm2lzDTQ,1310
1747
1747
  vellum/workflows/utils/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -1758,8 +1758,8 @@ vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnad
1758
1758
  vellum/workflows/workflows/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1759
1759
  vellum/workflows/workflows/tests/test_base_workflow.py,sha256=ptMntHzVyy8ZuzNgeTuk7hREgKQ5UBdgq8VJFSGaW4Y,20832
1760
1760
  vellum/workflows/workflows/tests/test_context.py,sha256=VJBUcyWVtMa_lE5KxdhgMu0WYNYnUQUDvTF7qm89hJ0,2333
1761
- vellum_ai-0.14.87.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1762
- vellum_ai-0.14.87.dist-info/METADATA,sha256=PwSEW73LUo3jQfScYBT8yLOMUmskjprvWGDFbtHN47c,5556
1763
- vellum_ai-0.14.87.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1764
- vellum_ai-0.14.87.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1765
- vellum_ai-0.14.87.dist-info/RECORD,,
1761
+ vellum_ai-0.14.88.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1762
+ vellum_ai-0.14.88.dist-info/METADATA,sha256=LkjU4RYrX6PB9kecW9GnNtnIvCpBmvP_8H4r34jJesY,5556
1763
+ vellum_ai-0.14.88.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1764
+ vellum_ai-0.14.88.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1765
+ vellum_ai-0.14.88.dist-info/RECORD,,