vellum-ai 0.12.5__py3-none-any.whl → 0.12.6__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/client/core/client_wrapper.py +1 -1
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +13 -4
- vellum/workflows/nodes/displayable/inline_prompt_node/tests/test_node.py +55 -0
- vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py +1 -1
- {vellum_ai-0.12.5.dist-info → vellum_ai-0.12.6.dist-info}/METADATA +1 -1
- {vellum_ai-0.12.5.dist-info → vellum_ai-0.12.6.dist-info}/RECORD +9 -9
- {vellum_ai-0.12.5.dist-info → vellum_ai-0.12.6.dist-info}/LICENSE +0 -0
- {vellum_ai-0.12.5.dist-info → vellum_ai-0.12.6.dist-info}/WHEEL +0 -0
- {vellum_ai-0.12.5.dist-info → vellum_ai-0.12.6.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.12.
|
21
|
+
"X-Fern-SDK-Version": "0.12.6",
|
22
22
|
}
|
23
23
|
headers["X_API_KEY"] = self.api_key
|
24
24
|
return headers
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import json
|
2
2
|
from uuid import uuid4
|
3
|
-
from typing import ClassVar, Generic, Iterator, List, Optional, Tuple, cast
|
3
|
+
from typing import Callable, ClassVar, Generic, Iterator, List, Optional, Tuple, Union, cast
|
4
4
|
|
5
5
|
from vellum import (
|
6
6
|
AdHocExecutePromptEvent,
|
@@ -24,9 +24,10 @@ from vellum.workflows.exceptions import NodeException
|
|
24
24
|
from vellum.workflows.nodes.displayable.bases.base_prompt_node import BasePromptNode
|
25
25
|
from vellum.workflows.nodes.displayable.bases.inline_prompt_node.constants import DEFAULT_PROMPT_PARAMETERS
|
26
26
|
from vellum.workflows.types.generics import StateType
|
27
|
+
from vellum.workflows.utils.functions import compile_function_definition
|
27
28
|
|
28
29
|
|
29
|
-
class BaseInlinePromptNode(BasePromptNode, Generic[StateType]):
|
30
|
+
class BaseInlinePromptNode(BasePromptNode[StateType], Generic[StateType]):
|
30
31
|
"""
|
31
32
|
Used to execute a Prompt defined inline.
|
32
33
|
|
@@ -45,7 +46,7 @@ class BaseInlinePromptNode(BasePromptNode, Generic[StateType]):
|
|
45
46
|
blocks: ClassVar[List[PromptBlock]]
|
46
47
|
|
47
48
|
# The functions/tools that a Prompt has access to
|
48
|
-
functions: Optional[List[FunctionDefinition]] =
|
49
|
+
functions: Optional[List[Union[FunctionDefinition, Callable]]] = None
|
49
50
|
|
50
51
|
parameters: PromptParameters = DEFAULT_PROMPT_PARAMETERS
|
51
52
|
expand_meta: Optional[AdHocExpandMeta] = OMIT
|
@@ -59,6 +60,14 @@ class BaseInlinePromptNode(BasePromptNode, Generic[StateType]):
|
|
59
60
|
"execution_context": {"parent_context": parent_context},
|
60
61
|
**request_options.get("additional_body_parameters", {}),
|
61
62
|
}
|
63
|
+
normalized_functions = (
|
64
|
+
[
|
65
|
+
function if isinstance(function, FunctionDefinition) else compile_function_definition(function)
|
66
|
+
for function in self.functions
|
67
|
+
]
|
68
|
+
if self.functions
|
69
|
+
else None
|
70
|
+
)
|
62
71
|
|
63
72
|
return self._context.vellum_client.ad_hoc.adhoc_execute_prompt_stream(
|
64
73
|
ml_model=self.ml_model,
|
@@ -66,7 +75,7 @@ class BaseInlinePromptNode(BasePromptNode, Generic[StateType]):
|
|
66
75
|
input_variables=input_variables,
|
67
76
|
parameters=self.parameters,
|
68
77
|
blocks=self.blocks,
|
69
|
-
functions=
|
78
|
+
functions=normalized_functions,
|
70
79
|
expand_meta=self.expand_meta,
|
71
80
|
request_options=self.request_options,
|
72
81
|
)
|
@@ -5,10 +5,14 @@ from typing import Any, Iterator, List
|
|
5
5
|
from vellum.client.core.pydantic_utilities import UniversalBaseModel
|
6
6
|
from vellum.client.types.execute_prompt_event import ExecutePromptEvent
|
7
7
|
from vellum.client.types.fulfilled_execute_prompt_event import FulfilledExecutePromptEvent
|
8
|
+
from vellum.client.types.function_call import FunctionCall
|
9
|
+
from vellum.client.types.function_call_vellum_value import FunctionCallVellumValue
|
10
|
+
from vellum.client.types.function_definition import FunctionDefinition
|
8
11
|
from vellum.client.types.initiated_execute_prompt_event import InitiatedExecutePromptEvent
|
9
12
|
from vellum.client.types.prompt_output import PromptOutput
|
10
13
|
from vellum.client.types.prompt_request_json_input import PromptRequestJsonInput
|
11
14
|
from vellum.client.types.string_vellum_value import StringVellumValue
|
15
|
+
from vellum.workflows.nodes.displayable.bases.inline_prompt_node.node import BaseInlinePromptNode
|
12
16
|
from vellum.workflows.nodes.displayable.inline_prompt_node.node import InlinePromptNode
|
13
17
|
|
14
18
|
|
@@ -62,3 +66,54 @@ def test_inline_prompt_node__json_inputs(vellum_adhoc_prompt_client):
|
|
62
66
|
PromptRequestJsonInput(key="a_pydantic", type="JSON", value={"example": "example"}),
|
63
67
|
]
|
64
68
|
assert len(mock_api.call_args.kwargs["input_variables"]) == 4
|
69
|
+
|
70
|
+
|
71
|
+
def test_inline_prompt_node__function_definitions(vellum_adhoc_prompt_client):
|
72
|
+
# GIVEN a function definition
|
73
|
+
def my_function(foo: str, bar: int) -> None:
|
74
|
+
pass
|
75
|
+
|
76
|
+
# AND a prompt node with a accepting that function definition
|
77
|
+
class MyNode(BaseInlinePromptNode):
|
78
|
+
ml_model = "gpt-4o"
|
79
|
+
functions = [my_function]
|
80
|
+
prompt_inputs = {}
|
81
|
+
blocks = []
|
82
|
+
|
83
|
+
# AND a known response from invoking an inline prompt
|
84
|
+
expected_outputs: List[PromptOutput] = [
|
85
|
+
FunctionCallVellumValue(value=FunctionCall(name="my_function", arguments={"foo": "hello", "bar": 1})),
|
86
|
+
]
|
87
|
+
|
88
|
+
def generate_prompt_events(*args: Any, **kwargs: Any) -> Iterator[ExecutePromptEvent]:
|
89
|
+
execution_id = str(uuid4())
|
90
|
+
events: List[ExecutePromptEvent] = [
|
91
|
+
InitiatedExecutePromptEvent(execution_id=execution_id),
|
92
|
+
FulfilledExecutePromptEvent(
|
93
|
+
execution_id=execution_id,
|
94
|
+
outputs=expected_outputs,
|
95
|
+
),
|
96
|
+
]
|
97
|
+
yield from events
|
98
|
+
|
99
|
+
vellum_adhoc_prompt_client.adhoc_execute_prompt_stream.side_effect = generate_prompt_events
|
100
|
+
|
101
|
+
# WHEN the node is run
|
102
|
+
list(MyNode().run())
|
103
|
+
|
104
|
+
# THEN the prompt is executed with the correct inputs
|
105
|
+
mock_api = vellum_adhoc_prompt_client.adhoc_execute_prompt_stream
|
106
|
+
assert mock_api.call_count == 1
|
107
|
+
assert mock_api.call_args.kwargs["functions"] == [
|
108
|
+
FunctionDefinition(
|
109
|
+
name="my_function",
|
110
|
+
parameters={
|
111
|
+
"type": "object",
|
112
|
+
"properties": {
|
113
|
+
"foo": {"type": "string"},
|
114
|
+
"bar": {"type": "integer"},
|
115
|
+
},
|
116
|
+
"required": ["foo", "bar"],
|
117
|
+
},
|
118
|
+
),
|
119
|
+
]
|
@@ -75,7 +75,7 @@ def test_inline_text_prompt_node__basic(vellum_adhoc_prompt_client):
|
|
75
75
|
vellum_adhoc_prompt_client.adhoc_execute_prompt_stream.assert_called_once_with(
|
76
76
|
blocks=[],
|
77
77
|
expand_meta=Ellipsis,
|
78
|
-
functions=
|
78
|
+
functions=None,
|
79
79
|
input_values=[],
|
80
80
|
input_variables=[],
|
81
81
|
ml_model="gpt-4o",
|
@@ -76,7 +76,7 @@ vellum/client/README.md,sha256=JkCJjmMZl4jrPj46pkmL9dpK4gSzQQmP5I7z4aME4LY,4749
|
|
76
76
|
vellum/client/__init__.py,sha256=o4m7iRZWEV8rP3GkdaztHAjNmjxjWERlarviFoHzuKI,110927
|
77
77
|
vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
|
78
78
|
vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
79
|
-
vellum/client/core/client_wrapper.py,sha256=
|
79
|
+
vellum/client/core/client_wrapper.py,sha256=Djd_7GxqAd6z6spaztPvuwOWM8nCLYHOM1pxOFHfmrc,1868
|
80
80
|
vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
81
81
|
vellum/client/core/file.py,sha256=X9IbmkZmB2bB_DpmZAO3crWdXagOakAyn6UCOCImCPg,2322
|
82
82
|
vellum/client/core/http_client.py,sha256=R0pQpCppnEtxccGvXl4uJ76s7ro_65Fo_erlNNLp_AI,19228
|
@@ -1297,7 +1297,7 @@ vellum/workflows/nodes/displayable/bases/base_prompt_node/__init__.py,sha256=Org
|
|
1297
1297
|
vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py,sha256=EvylK1rGKpd4iiooEW9O5A9Q8DMTtBwETe_GtQT8M-E,2139
|
1298
1298
|
vellum/workflows/nodes/displayable/bases/inline_prompt_node/__init__.py,sha256=Hl35IAoepRpE-j4cALaXVJIYTYOF3qszyVbxTj4kS1s,82
|
1299
1299
|
vellum/workflows/nodes/displayable/bases/inline_prompt_node/constants.py,sha256=fnjiRWLoRlC4Puo5oQcpZD5Hd-EesxsAo9l5tGAkpZQ,270
|
1300
|
-
vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py,sha256=
|
1300
|
+
vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py,sha256=fypgmZHgaDtGqSBC8rjYiyryJ0H58LPt_CafLfAprO0,6341
|
1301
1301
|
vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py,sha256=zdpNJoawB5PedsCCfgOGDDoWuif0jNtlV-K9sFL6cNQ,4968
|
1302
1302
|
vellum/workflows/nodes/displayable/bases/search_node.py,sha256=pqiui8G6l_9FLE1HH4rCdFC73Bl7_AIBAmQQMjqe190,3570
|
1303
1303
|
vellum/workflows/nodes/displayable/code_execution_node/__init__.py,sha256=0FLWMMktpzSnmBMizQglBpcPrP80fzVsoJwJgf822Cg,76
|
@@ -1316,7 +1316,7 @@ vellum/workflows/nodes/displayable/guardrail_node/node.py,sha256=7Ep7Ff7FtFry3Jw
|
|
1316
1316
|
vellum/workflows/nodes/displayable/inline_prompt_node/__init__.py,sha256=gSUOoEZLlrx35-tQhSAd3An8WDwBqyiQh-sIebLU9wU,74
|
1317
1317
|
vellum/workflows/nodes/displayable/inline_prompt_node/node.py,sha256=dTnP1yH1P0NqMw3noxt9XwaDCpX8ZOhuvVYNAn_DdCQ,2119
|
1318
1318
|
vellum/workflows/nodes/displayable/inline_prompt_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1319
|
-
vellum/workflows/nodes/displayable/inline_prompt_node/tests/test_node.py,sha256=
|
1319
|
+
vellum/workflows/nodes/displayable/inline_prompt_node/tests/test_node.py,sha256=P1DUL0wIG-cyA5dqGv7242cFWJXysmombdujKrJtl7k,4669
|
1320
1320
|
vellum/workflows/nodes/displayable/merge_node/__init__.py,sha256=J8IC08dSH7P76wKlNuxe1sn7toNGtSQdFirUbtPDEs0,60
|
1321
1321
|
vellum/workflows/nodes/displayable/merge_node/node.py,sha256=ZyPvcTgfPOneOm5Dc2kUOoPkwNJqwRPZSj232akXynA,324
|
1322
1322
|
vellum/workflows/nodes/displayable/note_node/__init__.py,sha256=KWA3P4fyYJ-fOTky8qNGlcOotQ-HeHJ9AjZt6mRQmCE,58
|
@@ -1328,7 +1328,7 @@ vellum/workflows/nodes/displayable/search_node/node.py,sha256=yhFWulbNmSQoDAwtTS
|
|
1328
1328
|
vellum/workflows/nodes/displayable/subworkflow_deployment_node/__init__.py,sha256=9yYM6001YZeqI1VOk1QuEM_yrffk_EdsO7qaPzINKds,92
|
1329
1329
|
vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py,sha256=pnbRCgdzWXrXhm5jDkDDASl5xu5w3DxskC34yJVmWUs,7147
|
1330
1330
|
vellum/workflows/nodes/displayable/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1331
|
-
vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py,sha256=
|
1331
|
+
vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py,sha256=UI_RMmXn9qwB-StnFPvkDd9FctBQAg43wrfouqvPepk,4701
|
1332
1332
|
vellum/workflows/nodes/displayable/tests/test_search_node_wth_text_output.py,sha256=4CMwDtXwTaEvFfDpA6j2iLqc7S6IICSkvVZOobEpeps,6954
|
1333
1333
|
vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py,sha256=KqKJtJ0vuNoPuUPMdILmBTt4a2fBBxxun-nmOI7T8jo,2585
|
1334
1334
|
vellum/workflows/nodes/utils.py,sha256=EZt7CzJmgQBR_GWFpZr8d-oaoti3tolTd2Cv9wm7dKo,1087
|
@@ -1384,8 +1384,8 @@ vellum/workflows/vellum_client.py,sha256=ODrq_TSl-drX2aezXegf7pizpWDVJuTXH-j6528
|
|
1384
1384
|
vellum/workflows/workflows/__init__.py,sha256=KY45TqvavCCvXIkyCFMEc0dc6jTMOUci93U2DUrlZYc,66
|
1385
1385
|
vellum/workflows/workflows/base.py,sha256=zpspOEdO5Ye_0ZvN-Wkzv9iQSiF1sD201ba8lhbnPbs,17086
|
1386
1386
|
vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnadGsrSZGa7t7LpJA,2008
|
1387
|
-
vellum_ai-0.12.
|
1388
|
-
vellum_ai-0.12.
|
1389
|
-
vellum_ai-0.12.
|
1390
|
-
vellum_ai-0.12.
|
1391
|
-
vellum_ai-0.12.
|
1387
|
+
vellum_ai-0.12.6.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
|
1388
|
+
vellum_ai-0.12.6.dist-info/METADATA,sha256=C1VU1fn4OEzUUW4pv7NTqN6hMP4XCwxUZldj2hAtths,5128
|
1389
|
+
vellum_ai-0.12.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
1390
|
+
vellum_ai-0.12.6.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
|
1391
|
+
vellum_ai-0.12.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|