vellum-ai 0.14.88__py3-none-any.whl → 0.14.89__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 (31) hide show
  1. vellum/client/README.md +33 -10
  2. vellum/client/__init__.py +141 -40
  3. vellum/client/core/client_wrapper.py +18 -5
  4. vellum/client/reference.md +241 -318
  5. vellum/client/resources/ad_hoc/client.py +76 -24
  6. vellum/client/resources/container_images/client.py +14 -6
  7. vellum/client/resources/deployments/client.py +28 -4
  8. vellum/client/resources/document_indexes/client.py +30 -38
  9. vellum/client/resources/documents/client.py +8 -30
  10. vellum/client/resources/folder_entities/client.py +4 -0
  11. vellum/client/resources/metric_definitions/client.py +16 -4
  12. vellum/client/resources/ml_models/client.py +2 -0
  13. vellum/client/resources/organizations/client.py +2 -0
  14. vellum/client/resources/prompts/client.py +26 -6
  15. vellum/client/resources/release_reviews/client.py +2 -0
  16. vellum/client/resources/sandboxes/client.py +10 -10
  17. vellum/client/resources/test_suite_runs/client.py +6 -0
  18. vellum/client/resources/test_suites/client.py +96 -58
  19. vellum/client/resources/workflow_deployments/client.py +16 -0
  20. vellum/client/resources/workflow_sandboxes/client.py +4 -0
  21. vellum/client/resources/workflows/client.py +0 -30
  22. vellum/client/resources/workspace_secrets/client.py +4 -0
  23. vellum/client/resources/workspaces/client.py +2 -0
  24. vellum/workflows/nodes/displayable/tool_calling_node/node.py +1 -5
  25. vellum/workflows/nodes/displayable/tool_calling_node/state.py +9 -0
  26. vellum/workflows/nodes/displayable/tool_calling_node/utils.py +50 -41
  27. {vellum_ai-0.14.88.dist-info → vellum_ai-0.14.89.dist-info}/METADATA +1 -1
  28. {vellum_ai-0.14.88.dist-info → vellum_ai-0.14.89.dist-info}/RECORD +31 -30
  29. {vellum_ai-0.14.88.dist-info → vellum_ai-0.14.89.dist-info}/LICENSE +0 -0
  30. {vellum_ai-0.14.88.dist-info → vellum_ai-0.14.89.dist-info}/WHEEL +0 -0
  31. {vellum_ai-0.14.88.dist-info → vellum_ai-0.14.89.dist-info}/entry_points.txt +0 -0
@@ -59,6 +59,7 @@ class TestSuitesClient:
59
59
  from vellum import Vellum
60
60
 
61
61
  client = Vellum(
62
+ api_version="YOUR_API_VERSION",
62
63
  api_key="YOUR_API_KEY",
63
64
  )
64
65
  client.test_suites.list_test_suite_test_cases(
@@ -139,40 +140,29 @@ class TestSuitesClient:
139
140
 
140
141
  Examples
141
142
  --------
142
- from vellum import (
143
- NamedTestCaseArrayVariableValueRequest,
144
- NamedTestCaseStringVariableValueRequest,
145
- StringVellumValueRequest,
146
- Vellum,
147
- )
143
+ from vellum import NamedTestCaseStringVariableValueRequest, Vellum
148
144
 
149
145
  client = Vellum(
146
+ api_version="YOUR_API_VERSION",
150
147
  api_key="YOUR_API_KEY",
151
148
  )
152
149
  client.test_suites.upsert_test_suite_test_case(
153
150
  id_="id",
154
- label="Test Case 1",
155
151
  input_values=[
156
152
  NamedTestCaseStringVariableValueRequest(
157
- value="What are your favorite colors?",
158
- name="var_1",
159
- )
153
+ name="x",
154
+ ),
155
+ NamedTestCaseStringVariableValueRequest(
156
+ name="x",
157
+ ),
160
158
  ],
161
159
  evaluation_values=[
162
- NamedTestCaseArrayVariableValueRequest(
163
- value=[
164
- StringVellumValueRequest(
165
- value="Red",
166
- ),
167
- StringVellumValueRequest(
168
- value="Green",
169
- ),
170
- StringVellumValueRequest(
171
- value="Blue",
172
- ),
173
- ],
174
- name="var_2",
175
- )
160
+ NamedTestCaseStringVariableValueRequest(
161
+ name="x",
162
+ ),
163
+ NamedTestCaseStringVariableValueRequest(
164
+ name="x",
165
+ ),
176
166
  ],
177
167
  )
178
168
  """
@@ -247,6 +237,7 @@ class TestSuitesClient:
247
237
  )
248
238
 
249
239
  client = Vellum(
240
+ api_version="YOUR_API_VERSION",
250
241
  api_key="YOUR_API_KEY",
251
242
  )
252
243
  response = client.test_suites.test_suite_test_cases_bulk(
@@ -257,16 +248,43 @@ class TestSuitesClient:
257
248
  data=CreateTestSuiteTestCaseRequest(
258
249
  input_values=[
259
250
  NamedTestCaseStringVariableValueRequest(
260
- name="name",
261
- )
251
+ name="x",
252
+ ),
253
+ NamedTestCaseStringVariableValueRequest(
254
+ name="x",
255
+ ),
262
256
  ],
263
257
  evaluation_values=[
264
258
  NamedTestCaseStringVariableValueRequest(
265
- name="name",
266
- )
259
+ name="x",
260
+ ),
261
+ NamedTestCaseStringVariableValueRequest(
262
+ name="x",
263
+ ),
267
264
  ],
268
265
  ),
269
- )
266
+ ),
267
+ TestSuiteTestCaseCreateBulkOperationRequest(
268
+ id="id",
269
+ data=CreateTestSuiteTestCaseRequest(
270
+ input_values=[
271
+ NamedTestCaseStringVariableValueRequest(
272
+ name="x",
273
+ ),
274
+ NamedTestCaseStringVariableValueRequest(
275
+ name="x",
276
+ ),
277
+ ],
278
+ evaluation_values=[
279
+ NamedTestCaseStringVariableValueRequest(
280
+ name="x",
281
+ ),
282
+ NamedTestCaseStringVariableValueRequest(
283
+ name="x",
284
+ ),
285
+ ],
286
+ ),
287
+ ),
270
288
  ],
271
289
  )
272
290
  for chunk in response:
@@ -330,6 +348,7 @@ class TestSuitesClient:
330
348
  from vellum import Vellum
331
349
 
332
350
  client = Vellum(
351
+ api_version="YOUR_API_VERSION",
333
352
  api_key="YOUR_API_KEY",
334
353
  )
335
354
  client.test_suites.delete_test_suite_test_case(
@@ -393,6 +412,7 @@ class AsyncTestSuitesClient:
393
412
  from vellum import AsyncVellum
394
413
 
395
414
  client = AsyncVellum(
415
+ api_version="YOUR_API_VERSION",
396
416
  api_key="YOUR_API_KEY",
397
417
  )
398
418
 
@@ -481,14 +501,10 @@ class AsyncTestSuitesClient:
481
501
  --------
482
502
  import asyncio
483
503
 
484
- from vellum import (
485
- AsyncVellum,
486
- NamedTestCaseArrayVariableValueRequest,
487
- NamedTestCaseStringVariableValueRequest,
488
- StringVellumValueRequest,
489
- )
504
+ from vellum import AsyncVellum, NamedTestCaseStringVariableValueRequest
490
505
 
491
506
  client = AsyncVellum(
507
+ api_version="YOUR_API_VERSION",
492
508
  api_key="YOUR_API_KEY",
493
509
  )
494
510
 
@@ -496,28 +512,21 @@ class AsyncTestSuitesClient:
496
512
  async def main() -> None:
497
513
  await client.test_suites.upsert_test_suite_test_case(
498
514
  id_="id",
499
- label="Test Case 1",
500
515
  input_values=[
501
516
  NamedTestCaseStringVariableValueRequest(
502
- value="What are your favorite colors?",
503
- name="var_1",
504
- )
517
+ name="x",
518
+ ),
519
+ NamedTestCaseStringVariableValueRequest(
520
+ name="x",
521
+ ),
505
522
  ],
506
523
  evaluation_values=[
507
- NamedTestCaseArrayVariableValueRequest(
508
- value=[
509
- StringVellumValueRequest(
510
- value="Red",
511
- ),
512
- StringVellumValueRequest(
513
- value="Green",
514
- ),
515
- StringVellumValueRequest(
516
- value="Blue",
517
- ),
518
- ],
519
- name="var_2",
520
- )
524
+ NamedTestCaseStringVariableValueRequest(
525
+ name="x",
526
+ ),
527
+ NamedTestCaseStringVariableValueRequest(
528
+ name="x",
529
+ ),
521
530
  ],
522
531
  )
523
532
 
@@ -597,6 +606,7 @@ class AsyncTestSuitesClient:
597
606
  )
598
607
 
599
608
  client = AsyncVellum(
609
+ api_version="YOUR_API_VERSION",
600
610
  api_key="YOUR_API_KEY",
601
611
  )
602
612
 
@@ -610,16 +620,43 @@ class AsyncTestSuitesClient:
610
620
  data=CreateTestSuiteTestCaseRequest(
611
621
  input_values=[
612
622
  NamedTestCaseStringVariableValueRequest(
613
- name="name",
614
- )
623
+ name="x",
624
+ ),
625
+ NamedTestCaseStringVariableValueRequest(
626
+ name="x",
627
+ ),
615
628
  ],
616
629
  evaluation_values=[
617
630
  NamedTestCaseStringVariableValueRequest(
618
- name="name",
619
- )
631
+ name="x",
632
+ ),
633
+ NamedTestCaseStringVariableValueRequest(
634
+ name="x",
635
+ ),
636
+ ],
637
+ ),
638
+ ),
639
+ TestSuiteTestCaseCreateBulkOperationRequest(
640
+ id="id",
641
+ data=CreateTestSuiteTestCaseRequest(
642
+ input_values=[
643
+ NamedTestCaseStringVariableValueRequest(
644
+ name="x",
645
+ ),
646
+ NamedTestCaseStringVariableValueRequest(
647
+ name="x",
648
+ ),
649
+ ],
650
+ evaluation_values=[
651
+ NamedTestCaseStringVariableValueRequest(
652
+ name="x",
653
+ ),
654
+ NamedTestCaseStringVariableValueRequest(
655
+ name="x",
656
+ ),
620
657
  ],
621
658
  ),
622
- )
659
+ ),
623
660
  ],
624
661
  )
625
662
  async for chunk in response:
@@ -688,6 +725,7 @@ class AsyncTestSuitesClient:
688
725
  from vellum import AsyncVellum
689
726
 
690
727
  client = AsyncVellum(
728
+ api_version="YOUR_API_VERSION",
691
729
  api_key="YOUR_API_KEY",
692
730
  )
693
731
 
@@ -65,6 +65,7 @@ class WorkflowDeploymentsClient:
65
65
  from vellum import Vellum
66
66
 
67
67
  client = Vellum(
68
+ api_version="YOUR_API_VERSION",
68
69
  api_key="YOUR_API_KEY",
69
70
  )
70
71
  client.workflow_deployments.list()
@@ -117,6 +118,7 @@ class WorkflowDeploymentsClient:
117
118
  from vellum import Vellum
118
119
 
119
120
  client = Vellum(
121
+ api_version="YOUR_API_VERSION",
120
122
  api_key="YOUR_API_KEY",
121
123
  )
122
124
  client.workflow_deployments.retrieve(
@@ -178,6 +180,7 @@ class WorkflowDeploymentsClient:
178
180
  from vellum import Vellum
179
181
 
180
182
  client = Vellum(
183
+ api_version="YOUR_API_VERSION",
181
184
  api_key="YOUR_API_KEY",
182
185
  )
183
186
  client.workflow_deployments.list_workflow_deployment_event_executions(
@@ -232,6 +235,7 @@ class WorkflowDeploymentsClient:
232
235
  from vellum import Vellum
233
236
 
234
237
  client = Vellum(
238
+ api_version="YOUR_API_VERSION",
235
239
  api_key="YOUR_API_KEY",
236
240
  )
237
241
  client.workflow_deployments.workflow_deployment_event_execution(
@@ -287,6 +291,7 @@ class WorkflowDeploymentsClient:
287
291
  from vellum import Vellum
288
292
 
289
293
  client = Vellum(
294
+ api_version="YOUR_API_VERSION",
290
295
  api_key="YOUR_API_KEY",
291
296
  )
292
297
  client.workflow_deployments.workflow_deployment_history_item_retrieve(
@@ -356,6 +361,7 @@ class WorkflowDeploymentsClient:
356
361
  from vellum import Vellum
357
362
 
358
363
  client = Vellum(
364
+ api_version="YOUR_API_VERSION",
359
365
  api_key="YOUR_API_KEY",
360
366
  )
361
367
  client.workflow_deployments.list_workflow_release_tags(
@@ -415,6 +421,7 @@ class WorkflowDeploymentsClient:
415
421
  from vellum import Vellum
416
422
 
417
423
  client = Vellum(
424
+ api_version="YOUR_API_VERSION",
418
425
  api_key="YOUR_API_KEY",
419
426
  )
420
427
  client.workflow_deployments.retrieve_workflow_release_tag(
@@ -477,6 +484,7 @@ class WorkflowDeploymentsClient:
477
484
  from vellum import Vellum
478
485
 
479
486
  client = Vellum(
487
+ api_version="YOUR_API_VERSION",
480
488
  api_key="YOUR_API_KEY",
481
489
  )
482
490
  client.workflow_deployments.update_workflow_release_tag(
@@ -557,6 +565,7 @@ class AsyncWorkflowDeploymentsClient:
557
565
  from vellum import AsyncVellum
558
566
 
559
567
  client = AsyncVellum(
568
+ api_version="YOUR_API_VERSION",
560
569
  api_key="YOUR_API_KEY",
561
570
  )
562
571
 
@@ -619,6 +628,7 @@ class AsyncWorkflowDeploymentsClient:
619
628
  from vellum import AsyncVellum
620
629
 
621
630
  client = AsyncVellum(
631
+ api_version="YOUR_API_VERSION",
622
632
  api_key="YOUR_API_KEY",
623
633
  )
624
634
 
@@ -688,6 +698,7 @@ class AsyncWorkflowDeploymentsClient:
688
698
  from vellum import AsyncVellum
689
699
 
690
700
  client = AsyncVellum(
701
+ api_version="YOUR_API_VERSION",
691
702
  api_key="YOUR_API_KEY",
692
703
  )
693
704
 
@@ -750,6 +761,7 @@ class AsyncWorkflowDeploymentsClient:
750
761
  from vellum import AsyncVellum
751
762
 
752
763
  client = AsyncVellum(
764
+ api_version="YOUR_API_VERSION",
753
765
  api_key="YOUR_API_KEY",
754
766
  )
755
767
 
@@ -813,6 +825,7 @@ class AsyncWorkflowDeploymentsClient:
813
825
  from vellum import AsyncVellum
814
826
 
815
827
  client = AsyncVellum(
828
+ api_version="YOUR_API_VERSION",
816
829
  api_key="YOUR_API_KEY",
817
830
  )
818
831
 
@@ -890,6 +903,7 @@ class AsyncWorkflowDeploymentsClient:
890
903
  from vellum import AsyncVellum
891
904
 
892
905
  client = AsyncVellum(
906
+ api_version="YOUR_API_VERSION",
893
907
  api_key="YOUR_API_KEY",
894
908
  )
895
909
 
@@ -957,6 +971,7 @@ class AsyncWorkflowDeploymentsClient:
957
971
  from vellum import AsyncVellum
958
972
 
959
973
  client = AsyncVellum(
974
+ api_version="YOUR_API_VERSION",
960
975
  api_key="YOUR_API_KEY",
961
976
  )
962
977
 
@@ -1027,6 +1042,7 @@ class AsyncWorkflowDeploymentsClient:
1027
1042
  from vellum import AsyncVellum
1028
1043
 
1029
1044
  client = AsyncVellum(
1045
+ api_version="YOUR_API_VERSION",
1030
1046
  api_key="YOUR_API_KEY",
1031
1047
  )
1032
1048
 
@@ -69,6 +69,7 @@ class WorkflowSandboxesClient:
69
69
  from vellum import Vellum
70
70
 
71
71
  client = Vellum(
72
+ api_version="YOUR_API_VERSION",
72
73
  api_key="YOUR_API_KEY",
73
74
  )
74
75
  client.workflow_sandboxes.deploy_workflow(
@@ -145,6 +146,7 @@ class WorkflowSandboxesClient:
145
146
  from vellum import Vellum
146
147
 
147
148
  client = Vellum(
149
+ api_version="YOUR_API_VERSION",
148
150
  api_key="YOUR_API_KEY",
149
151
  )
150
152
  client.workflow_sandboxes.list_workflow_sandbox_examples()
@@ -231,6 +233,7 @@ class AsyncWorkflowSandboxesClient:
231
233
  from vellum import AsyncVellum
232
234
 
233
235
  client = AsyncVellum(
236
+ api_version="YOUR_API_VERSION",
234
237
  api_key="YOUR_API_KEY",
235
238
  )
236
239
 
@@ -315,6 +318,7 @@ class AsyncWorkflowSandboxesClient:
315
318
  from vellum import AsyncVellum
316
319
 
317
320
  client = AsyncVellum(
321
+ api_version="YOUR_API_VERSION",
318
322
  api_key="YOUR_API_KEY",
319
323
  )
320
324
 
@@ -123,17 +123,6 @@ class WorkflowsClient:
123
123
  -------
124
124
  WorkflowPushResponse
125
125
 
126
-
127
- Examples
128
- --------
129
- from vellum import Vellum
130
-
131
- client = Vellum(
132
- api_key="YOUR_API_KEY",
133
- )
134
- client.workflows.push(
135
- exec_config="exec_config",
136
- )
137
126
  """
138
127
  _response = self._client_wrapper.httpx_client.request(
139
128
  "v1/workflows/push",
@@ -272,25 +261,6 @@ class AsyncWorkflowsClient:
272
261
  -------
273
262
  WorkflowPushResponse
274
263
 
275
-
276
- Examples
277
- --------
278
- import asyncio
279
-
280
- from vellum import AsyncVellum
281
-
282
- client = AsyncVellum(
283
- api_key="YOUR_API_KEY",
284
- )
285
-
286
-
287
- async def main() -> None:
288
- await client.workflows.push(
289
- exec_config="exec_config",
290
- )
291
-
292
-
293
- asyncio.run(main())
294
264
  """
295
265
  _response = await self._client_wrapper.httpx_client.request(
296
266
  "v1/workflows/push",
@@ -40,6 +40,7 @@ class WorkspaceSecretsClient:
40
40
  from vellum import Vellum
41
41
 
42
42
  client = Vellum(
43
+ api_version="YOUR_API_VERSION",
43
44
  api_key="YOUR_API_KEY",
44
45
  )
45
46
  client.workspace_secrets.retrieve(
@@ -99,6 +100,7 @@ class WorkspaceSecretsClient:
99
100
  from vellum import Vellum
100
101
 
101
102
  client = Vellum(
103
+ api_version="YOUR_API_VERSION",
102
104
  api_key="YOUR_API_KEY",
103
105
  )
104
106
  client.workspace_secrets.partial_update(
@@ -164,6 +166,7 @@ class AsyncWorkspaceSecretsClient:
164
166
  from vellum import AsyncVellum
165
167
 
166
168
  client = AsyncVellum(
169
+ api_version="YOUR_API_VERSION",
167
170
  api_key="YOUR_API_KEY",
168
171
  )
169
172
 
@@ -231,6 +234,7 @@ class AsyncWorkspaceSecretsClient:
231
234
  from vellum import AsyncVellum
232
235
 
233
236
  client = AsyncVellum(
237
+ api_version="YOUR_API_VERSION",
234
238
  api_key="YOUR_API_KEY",
235
239
  )
236
240
 
@@ -33,6 +33,7 @@ class WorkspacesClient:
33
33
  from vellum import Vellum
34
34
 
35
35
  client = Vellum(
36
+ api_version="YOUR_API_VERSION",
36
37
  api_key="YOUR_API_KEY",
37
38
  )
38
39
  client.workspaces.workspace_identity()
@@ -83,6 +84,7 @@ class AsyncWorkspacesClient:
83
84
  from vellum import AsyncVellum
84
85
 
85
86
  client = AsyncVellum(
87
+ api_version="YOUR_API_VERSION",
86
88
  api_key="YOUR_API_KEY",
87
89
  )
88
90
 
@@ -8,13 +8,13 @@ from vellum.workflows.exceptions import NodeException
8
8
  from vellum.workflows.graph.graph import Graph
9
9
  from vellum.workflows.inputs.base import BaseInputs
10
10
  from vellum.workflows.nodes.bases import BaseNode
11
+ from vellum.workflows.nodes.displayable.tool_calling_node.state import ToolCallingState
11
12
  from vellum.workflows.nodes.displayable.tool_calling_node.utils import (
12
13
  create_function_node,
13
14
  create_tool_router_node,
14
15
  get_function_name,
15
16
  )
16
17
  from vellum.workflows.outputs.base import BaseOutput, BaseOutputs
17
- from vellum.workflows.state.base import BaseState
18
18
  from vellum.workflows.state.context import WorkflowContext
19
19
  from vellum.workflows.types.core import EntityInputsInterface, Tool
20
20
  from vellum.workflows.workflows.event_filters import all_workflow_event_filter
@@ -61,10 +61,6 @@ class ToolCallingNode(BaseNode):
61
61
 
62
62
  with execution_context(parent_context=get_parent_context()):
63
63
 
64
- class ToolCallingState(BaseState):
65
- chat_history: List[ChatMessage] = []
66
- prompt_iterations: int = 0
67
-
68
64
  from vellum.workflows.workflows.base import BaseWorkflow
69
65
 
70
66
  class ToolCallingWorkflow(BaseWorkflow[BaseInputs, ToolCallingState]):
@@ -0,0 +1,9 @@
1
+ from typing import List
2
+
3
+ from vellum import ChatMessage
4
+ from vellum.workflows.state.base import BaseState
5
+
6
+
7
+ class ToolCallingState(BaseState):
8
+ chat_history: List[ChatMessage] = []
9
+ prompt_iterations: int = 0
@@ -6,6 +6,7 @@ from pydash import snake_case
6
6
  from vellum import ChatMessage, PromptBlock
7
7
  from vellum.client.types.function_call_chat_message_content import FunctionCallChatMessageContent
8
8
  from vellum.client.types.function_call_chat_message_content_value import FunctionCallChatMessageContentValue
9
+ from vellum.client.types.prompt_output import PromptOutput
9
10
  from vellum.client.types.string_chat_message_content import StringChatMessageContent
10
11
  from vellum.client.types.variable_prompt_block import VariablePromptBlock
11
12
  from vellum.workflows.context import execution_context, get_parent_context
@@ -15,6 +16,7 @@ from vellum.workflows.exceptions import NodeException
15
16
  from vellum.workflows.nodes.bases import BaseNode
16
17
  from vellum.workflows.nodes.displayable.inline_prompt_node.node import InlinePromptNode
17
18
  from vellum.workflows.nodes.displayable.subworkflow_deployment_node.node import SubworkflowDeploymentNode
19
+ from vellum.workflows.nodes.displayable.tool_calling_node.state import ToolCallingState
18
20
  from vellum.workflows.outputs.base import BaseOutput, BaseOutputs
19
21
  from vellum.workflows.ports.port import Port
20
22
  from vellum.workflows.references.lazy import LazyReference
@@ -34,7 +36,7 @@ class FunctionNode(BaseNode):
34
36
  pass
35
37
 
36
38
 
37
- class ToolRouterNode(InlinePromptNode):
39
+ class ToolRouterNode(InlinePromptNode[ToolCallingState]):
38
40
  max_prompt_iterations: Optional[int] = 5
39
41
 
40
42
  class Trigger(InlinePromptNode.Trigger):
@@ -76,6 +78,48 @@ class ToolRouterNode(InlinePromptNode):
76
78
  yield output
77
79
 
78
80
 
81
+ class DynamicSubworkflowDeploymentNode(SubworkflowDeploymentNode[ToolCallingState]):
82
+ """Node that executes a deployment definition with function call output."""
83
+
84
+ function_call_output: List[PromptOutput]
85
+
86
+ def run(self) -> Iterator[BaseOutput]:
87
+ if self.function_call_output and len(self.function_call_output) > 0:
88
+ function_call = self.function_call_output[0]
89
+ if function_call.type == "FUNCTION_CALL" and function_call.value is not None:
90
+ arguments = function_call.value.arguments
91
+ else:
92
+ arguments = {}
93
+ else:
94
+ arguments = {}
95
+
96
+ # Mypy doesn't like instance assignments of class attributes. It's safe in our case tho bc it's what
97
+ # we do in the `__init__` method. Long term, instead of the function_call_output attribute above, we
98
+ # want to do:
99
+ # ```python
100
+ # subworkflow_inputs = tool_router_node.Outputs.results[0]['value']['arguments'].if_(
101
+ # tool_router_node.Outputs.results[0]['type'].equals('FUNCTION_CALL'),
102
+ # {},
103
+ # )
104
+ # ```
105
+ self.subworkflow_inputs = arguments # type:ignore[misc]
106
+
107
+ # Call the parent run method to execute the subworkflow
108
+ outputs = {}
109
+ for output in super().run():
110
+ if output.is_fulfilled:
111
+ outputs[output.name] = output.value
112
+ yield output
113
+
114
+ # Add the result to the chat history
115
+ self.state.chat_history.append(
116
+ ChatMessage(
117
+ role="FUNCTION",
118
+ content=StringChatMessageContent(value=json.dumps(outputs, cls=DefaultStateEncoder)),
119
+ )
120
+ )
121
+
122
+
79
123
  def create_tool_router_node(
80
124
  ml_model: str,
81
125
  blocks: List[PromptBlock],
@@ -162,48 +206,13 @@ def create_function_node(
162
206
  deployment = function.deployment_id or function.deployment_name
163
207
  release_tag = function.release_tag
164
208
 
165
- def execute_workflow_deployment_function(self) -> BaseNode.Outputs:
166
- function_call_output = self.state.meta.node_outputs.get(tool_router_node.Outputs.results)
167
- if function_call_output and len(function_call_output) > 0:
168
- function_call = function_call_output[0]
169
- arguments = function_call.value.arguments
170
- else:
171
- arguments = {}
172
-
173
- subworkflow_node = type(
174
- f"DynamicSubworkflowNode_{deployment}",
175
- (SubworkflowDeploymentNode,),
176
- {
177
- "deployment": deployment,
178
- "release_tag": release_tag,
179
- "subworkflow_inputs": arguments,
180
- "__module__": __name__,
181
- },
182
- )
183
-
184
- node_instance = subworkflow_node(
185
- context=WorkflowContext.create_from(self._context),
186
- state=self.state,
187
- )
188
-
189
- outputs = {}
190
- for output in node_instance.run():
191
- outputs[output.name] = output.value
192
-
193
- self.state.chat_history.append(
194
- ChatMessage(
195
- role="FUNCTION",
196
- content=StringChatMessageContent(value=json.dumps(outputs, cls=DefaultStateEncoder)),
197
- )
198
- )
199
-
200
- return self.Outputs()
201
-
202
209
  node = type(
203
- f"WorkflowDeploymentNode_{deployment}",
204
- (FunctionNode,),
210
+ f"DynamicSubworkflowDeploymentNode_{deployment}",
211
+ (DynamicSubworkflowDeploymentNode,),
205
212
  {
206
- "run": execute_workflow_deployment_function,
213
+ "deployment": deployment,
214
+ "release_tag": release_tag,
215
+ "function_call_output": tool_router_node.Outputs.results,
207
216
  "__module__": __name__,
208
217
  },
209
218
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 0.14.88
3
+ Version: 0.14.89
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0