vellum-ai 0.13.23__py3-none-any.whl → 0.13.24__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.
- vellum/client/core/client_wrapper.py +1 -1
- vellum/client/types/execute_api_response.py +3 -1
- vellum/workflows/nodes/displayable/code_execution_node/node.py +2 -2
- vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py +57 -10
- {vellum_ai-0.13.23.dist-info → vellum_ai-0.13.24.dist-info}/METADATA +1 -1
- {vellum_ai-0.13.23.dist-info → vellum_ai-0.13.24.dist-info}/RECORD +9 -9
- {vellum_ai-0.13.23.dist-info → vellum_ai-0.13.24.dist-info}/LICENSE +0 -0
- {vellum_ai-0.13.23.dist-info → vellum_ai-0.13.24.dist-info}/WHEEL +0 -0
- {vellum_ai-0.13.23.dist-info → vellum_ai-0.13.24.dist-info}/entry_points.txt +0 -0
@@ -18,7 +18,7 @@ class BaseClientWrapper:
|
|
18
18
|
headers: typing.Dict[str, str] = {
|
19
19
|
"X-Fern-Language": "Python",
|
20
20
|
"X-Fern-SDK-Name": "vellum-ai",
|
21
|
-
"X-Fern-SDK-Version": "0.13.
|
21
|
+
"X-Fern-SDK-Version": "0.13.24",
|
22
22
|
}
|
23
23
|
headers["X_API_KEY"] = self.api_key
|
24
24
|
return headers
|
@@ -11,7 +11,9 @@ import pydantic
|
|
11
11
|
class ExecuteApiResponse(UniversalBaseModel):
|
12
12
|
status_code: int
|
13
13
|
text: str
|
14
|
-
json_: typing_extensions.Annotated[
|
14
|
+
json_: typing_extensions.Annotated[
|
15
|
+
typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="json")
|
16
|
+
] = None
|
15
17
|
headers: typing.Dict[str, str]
|
16
18
|
|
17
19
|
if IS_PYDANTIC_V2:
|
@@ -170,11 +170,11 @@ class CodeExecutionNode(BaseNode[StateType], Generic[StateType, _OutputType], me
|
|
170
170
|
value=cast(Dict[str, Any], input_value),
|
171
171
|
)
|
172
172
|
)
|
173
|
-
elif isinstance(input_value, float):
|
173
|
+
elif isinstance(input_value, (float, int)):
|
174
174
|
compiled_inputs.append(
|
175
175
|
NumberInput(
|
176
176
|
name=input_name,
|
177
|
-
value=input_value,
|
177
|
+
value=float(input_value),
|
178
178
|
)
|
179
179
|
)
|
180
180
|
elif isinstance(input_value, FunctionCall):
|
@@ -6,6 +6,7 @@ from vellum import CodeExecutorResponse, NumberVellumValue, StringInput
|
|
6
6
|
from vellum.client.types.code_execution_package import CodeExecutionPackage
|
7
7
|
from vellum.client.types.code_executor_secret_input import CodeExecutorSecretInput
|
8
8
|
from vellum.client.types.function_call import FunctionCall
|
9
|
+
from vellum.client.types.number_input import NumberInput
|
9
10
|
from vellum.workflows.exceptions import NodeException
|
10
11
|
from vellum.workflows.inputs.base import BaseInputs
|
11
12
|
from vellum.workflows.nodes.displayable.code_execution_node import CodeExecutionNode
|
@@ -13,7 +14,7 @@ from vellum.workflows.references.vellum_secret import VellumSecretReference
|
|
13
14
|
from vellum.workflows.state.base import BaseState, StateMeta
|
14
15
|
|
15
16
|
|
16
|
-
def
|
17
|
+
def test_run_node__happy_path(vellum_client):
|
17
18
|
"""Confirm that CodeExecutionNodes output the expected text and results when run."""
|
18
19
|
|
19
20
|
# GIVEN a node that subclasses CodeExecutionNode
|
@@ -79,7 +80,7 @@ def main(word: str) -> int:
|
|
79
80
|
)
|
80
81
|
|
81
82
|
|
82
|
-
def
|
83
|
+
def test_run_node__code_attribute(vellum_client):
|
83
84
|
"""Confirm that CodeExecutionNodes can use the `code` attribute to specify the code to execute."""
|
84
85
|
|
85
86
|
# GIVEN a node that subclasses CodeExecutionNode
|
@@ -147,7 +148,7 @@ def main(word: str) -> int:
|
|
147
148
|
)
|
148
149
|
|
149
150
|
|
150
|
-
def
|
151
|
+
def test_run_node__code_and_filepath_defined(vellum_client):
|
151
152
|
"""Confirm that CodeExecutionNodes raise an error if both `code` and `filepath` are defined."""
|
152
153
|
|
153
154
|
# GIVEN a node that subclasses CodeExecutionNode
|
@@ -198,7 +199,7 @@ def main(word: str) -> int:
|
|
198
199
|
assert exc_info.value.message == "Cannot specify both `code` and `filepath` for a CodeExecutionNode"
|
199
200
|
|
200
201
|
|
201
|
-
def
|
202
|
+
def test_run_node__code_and_filepath_not_defined(vellum_client):
|
202
203
|
"""Confirm that CodeExecutionNodes raise an error if neither `code` nor `filepath` are defined."""
|
203
204
|
|
204
205
|
# GIVEN a node that subclasses CodeExecutionNode
|
@@ -241,7 +242,7 @@ def test_run_workflow__code_and_filepath_not_defined(vellum_client):
|
|
241
242
|
assert exc_info.value.message == "Must specify either `code` or `filepath` for a CodeExecutionNode"
|
242
243
|
|
243
244
|
|
244
|
-
def
|
245
|
+
def test_run_node__vellum_secret(vellum_client):
|
245
246
|
"""Confirm that CodeExecutionNodes can use Vellum Secrets"""
|
246
247
|
|
247
248
|
# GIVEN a node that subclasses CodeExecutionNode that references a Vellum Secret
|
@@ -303,7 +304,53 @@ def main(word: str) -> int:
|
|
303
304
|
)
|
304
305
|
|
305
306
|
|
306
|
-
def
|
307
|
+
def test_run_node__int_input(vellum_client):
|
308
|
+
"""Confirm that CodeExecutionNodes can use int's as inputs"""
|
309
|
+
|
310
|
+
# GIVEN a node that subclasses CodeExecutionNode that references an int
|
311
|
+
class State(BaseState):
|
312
|
+
pass
|
313
|
+
|
314
|
+
fixture = os.path.abspath(os.path.join(__file__, "../fixtures/main.py"))
|
315
|
+
|
316
|
+
class ExampleCodeExecutionNode(CodeExecutionNode[State, int]):
|
317
|
+
filepath = fixture
|
318
|
+
runtime = "PYTHON_3_11_6"
|
319
|
+
packages = [
|
320
|
+
CodeExecutionPackage(
|
321
|
+
name="openai",
|
322
|
+
version="1.0.0",
|
323
|
+
)
|
324
|
+
]
|
325
|
+
|
326
|
+
code_inputs = {
|
327
|
+
"counter": 1,
|
328
|
+
}
|
329
|
+
|
330
|
+
# AND we know what the Code Execution Node will respond with
|
331
|
+
mock_code_execution = CodeExecutorResponse(
|
332
|
+
log="",
|
333
|
+
output=NumberVellumValue(value=0),
|
334
|
+
)
|
335
|
+
vellum_client.execute_code.return_value = mock_code_execution
|
336
|
+
|
337
|
+
# WHEN we run the node
|
338
|
+
node = ExampleCodeExecutionNode(state=State())
|
339
|
+
outputs = node.run()
|
340
|
+
|
341
|
+
# THEN the node should have produced the outputs we expect
|
342
|
+
assert outputs == {"result": 0, "log": ""}
|
343
|
+
|
344
|
+
# AND we should have invoked the Code with the correct inputs
|
345
|
+
assert vellum_client.execute_code.call_args_list[0].kwargs["input_values"] == [
|
346
|
+
NumberInput(
|
347
|
+
name="counter",
|
348
|
+
value=1.0,
|
349
|
+
)
|
350
|
+
]
|
351
|
+
|
352
|
+
|
353
|
+
def test_run_node__run_inline(vellum_client):
|
307
354
|
"""Confirm that CodeExecutionNodes run the code inline instead of through Vellum under certain conditions."""
|
308
355
|
|
309
356
|
# GIVEN a node that subclasses CodeExecutionNode
|
@@ -330,7 +377,7 @@ def main(word: str) -> int:
|
|
330
377
|
vellum_client.execute_code.assert_not_called()
|
331
378
|
|
332
379
|
|
333
|
-
def
|
380
|
+
def test_run_node__run_inline__incorrect_output_type():
|
334
381
|
"""Confirm that CodeExecutionNodes raise an error if the output type is incorrect during inline execution."""
|
335
382
|
|
336
383
|
# GIVEN a node that subclasses CodeExecutionNode that returns a string but is defined to return an int
|
@@ -354,7 +401,7 @@ def main(word: str) -> int:
|
|
354
401
|
assert exc_info.value.message == "Expected an output of type 'int', but received 'str'"
|
355
402
|
|
356
403
|
|
357
|
-
def
|
404
|
+
def test_run_node__run_inline__valid_dict_to_pydantic():
|
358
405
|
"""Confirm that CodeExecutionNodes can convert a dict to a Pydantic model during inline execution."""
|
359
406
|
|
360
407
|
# GIVEN a node that subclasses CodeExecutionNode that returns a dict matching a Pydantic model
|
@@ -380,7 +427,7 @@ def main(word: str) -> int:
|
|
380
427
|
assert outputs == {"result": FunctionCall(name="hello", arguments={}), "log": ""}
|
381
428
|
|
382
429
|
|
383
|
-
def
|
430
|
+
def test_run_node__run_inline__invalid_dict_to_pydantic():
|
384
431
|
"""Confirm that CodeExecutionNodes raise an error if the Pydantic validation fails during inline execution."""
|
385
432
|
|
386
433
|
# GIVEN a node that subclasses CodeExecutionNode that returns a dict not matching a Pydantic model
|
@@ -416,7 +463,7 @@ name
|
|
416
463
|
)
|
417
464
|
|
418
465
|
|
419
|
-
def
|
466
|
+
def test_run_node__run_inline__valid_dict_to_pydantic_any_type():
|
420
467
|
"""Confirm that CodeExecutionNodes can convert a dict to a Pydantic model during inline execution."""
|
421
468
|
|
422
469
|
# GIVEN a node that subclasses CodeExecutionNode that returns a dict matching Any
|
@@ -115,7 +115,7 @@ vellum/client/README.md,sha256=JkCJjmMZl4jrPj46pkmL9dpK4gSzQQmP5I7z4aME4LY,4749
|
|
115
115
|
vellum/client/__init__.py,sha256=j6zi0NZ4BMC6JrwckvzMWuG5x8KoOvO4KqsLhvVCa68,117624
|
116
116
|
vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
|
117
117
|
vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
118
|
-
vellum/client/core/client_wrapper.py,sha256=
|
118
|
+
vellum/client/core/client_wrapper.py,sha256=CHUMF1rAO0mKKIpxyLeUmpjLICY4ZwyiCpiYCjAnHwE,1869
|
119
119
|
vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
120
120
|
vellum/client/core/file.py,sha256=X9IbmkZmB2bB_DpmZAO3crWdXagOakAyn6UCOCImCPg,2322
|
121
121
|
vellum/client/core/http_client.py,sha256=R0pQpCppnEtxccGvXl4uJ76s7ro_65Fo_erlNNLp_AI,19228
|
@@ -270,7 +270,7 @@ vellum/client/types/error_vellum_value_request.py,sha256=o0aSn34dRcpnAwAfwW_sgwP
|
|
270
270
|
vellum/client/types/execute_api_request_bearer_token.py,sha256=agAhp9lzfzZcYGZdzg2jHAEHCaHlqzbgp6qeeNebcto,183
|
271
271
|
vellum/client/types/execute_api_request_body.py,sha256=MArsO_-H41lU8Lz0dB78MVcFupjWtRV7UBEljY3Dnwk,169
|
272
272
|
vellum/client/types/execute_api_request_headers_value.py,sha256=bHtGwOpknQDcQo6qtMKqJxaYpvbinDfwx2uaPzyuZ9s,184
|
273
|
-
vellum/client/types/execute_api_response.py,sha256=
|
273
|
+
vellum/client/types/execute_api_response.py,sha256=1_wGY1eIF6Drwx5FEwnwBRLUxonXX7dOjhkvQakE-bw,842
|
274
274
|
vellum/client/types/execute_prompt_event.py,sha256=wq_TZBDJcmXQhSj25jR9nMTnN-mP8Ku5Vq3rLqmwE5Q,521
|
275
275
|
vellum/client/types/execute_prompt_response.py,sha256=n6ODveXcO8uWG-kr_B9wXziHH8JUaVTUcUAZKifClEo,334
|
276
276
|
vellum/client/types/execute_workflow_response.py,sha256=0Q-NGPv5jpxjq6xNlHa3qUNK7yOmkU8h6Z2vQb6bHsU,1022
|
@@ -1369,11 +1369,11 @@ vellum/workflows/nodes/displayable/bases/tests/test_utils.py,sha256=eqdqbKNRWVMD
|
|
1369
1369
|
vellum/workflows/nodes/displayable/bases/types.py,sha256=C37B2Qh2YP7s7pUjd-EYKc2Zl1TbnCgI_mENuUSb8bo,1706
|
1370
1370
|
vellum/workflows/nodes/displayable/bases/utils.py,sha256=ckMUenSsNkiYmSw6FmjSMHYaCk8Y8_sUjL6lkFFEqts,5412
|
1371
1371
|
vellum/workflows/nodes/displayable/code_execution_node/__init__.py,sha256=0FLWMMktpzSnmBMizQglBpcPrP80fzVsoJwJgf822Cg,76
|
1372
|
-
vellum/workflows/nodes/displayable/code_execution_node/node.py,sha256=
|
1372
|
+
vellum/workflows/nodes/displayable/code_execution_node/node.py,sha256=wgtqPljUqan9SILMysPCdSmZ0HoCpTTTNNaW0y9nQQI,9082
|
1373
1373
|
vellum/workflows/nodes/displayable/code_execution_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1374
1374
|
vellum/workflows/nodes/displayable/code_execution_node/tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1375
1375
|
vellum/workflows/nodes/displayable/code_execution_node/tests/fixtures/main.py,sha256=5QsbmkzSlSbcbWTG_JmIqcP-JNJzOPTKxGzdHos19W4,79
|
1376
|
-
vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py,sha256=
|
1376
|
+
vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py,sha256=y_j4PieOpRYFmTqIEg1IPg-x-y_ezOcjcWCWPXYp1hI,14582
|
1377
1377
|
vellum/workflows/nodes/displayable/code_execution_node/utils.py,sha256=hF9tdCpta7WN1ANz467Q9LNlISOSmp79jDIkR5d2iQM,3542
|
1378
1378
|
vellum/workflows/nodes/displayable/conditional_node/__init__.py,sha256=AS_EIqFdU1F9t8aLmbZU-rLh9ry6LCJ0uj0D8F0L5Uw,72
|
1379
1379
|
vellum/workflows/nodes/displayable/conditional_node/node.py,sha256=Qjfl33gZ3JEgxBA1EgzSUebboGvsARthIxxcQyvx5Gg,1152
|
@@ -1464,8 +1464,8 @@ vellum/workflows/vellum_client.py,sha256=ODrq_TSl-drX2aezXegf7pizpWDVJuTXH-j6528
|
|
1464
1464
|
vellum/workflows/workflows/__init__.py,sha256=KY45TqvavCCvXIkyCFMEc0dc6jTMOUci93U2DUrlZYc,66
|
1465
1465
|
vellum/workflows/workflows/base.py,sha256=uYT0TQnEDtVaH3pErq785FhxxEEmk7C5ZGfuSO3QK8c,18537
|
1466
1466
|
vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnadGsrSZGa7t7LpJA,2008
|
1467
|
-
vellum_ai-0.13.
|
1468
|
-
vellum_ai-0.13.
|
1469
|
-
vellum_ai-0.13.
|
1470
|
-
vellum_ai-0.13.
|
1471
|
-
vellum_ai-0.13.
|
1467
|
+
vellum_ai-0.13.24.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
|
1468
|
+
vellum_ai-0.13.24.dist-info/METADATA,sha256=6i1_pGA_JzLwbgGSvPKSioG96wTBmf5XnTrvtVKPcZM,5335
|
1469
|
+
vellum_ai-0.13.24.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
1470
|
+
vellum_ai-0.13.24.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
|
1471
|
+
vellum_ai-0.13.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|