vellum-ai 0.14.89__py3-none-any.whl → 1.0.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.
- vellum/__init__.py +7 -1
- vellum/client/__init__.py +2 -2
- vellum/client/core/client_wrapper.py +2 -2
- vellum/client/types/__init__.py +6 -0
- vellum/client/types/organization_limit_config.py +24 -0
- vellum/client/types/organization_read.py +2 -0
- vellum/client/types/quota.py +21 -0
- vellum/client/types/vembda_service_tier_enum.py +5 -0
- vellum/client/types/workflow_execution_actual.py +1 -1
- vellum/evaluations/resources.py +5 -5
- vellum/types/organization_limit_config.py +3 -0
- vellum/types/quota.py +3 -0
- vellum/types/vembda_service_tier_enum.py +3 -0
- vellum/workflows/events/node.py +1 -1
- vellum/workflows/events/types.py +1 -1
- vellum/workflows/events/workflow.py +1 -1
- vellum/workflows/nodes/bases/tests/test_base_node.py +1 -1
- vellum/workflows/nodes/displayable/api_node/node.py +1 -0
- vellum/workflows/nodes/displayable/api_node/tests/test_api_node.py +30 -0
- vellum/workflows/nodes/displayable/bases/api_node/node.py +27 -10
- vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +1 -1
- vellum/workflows/nodes/displayable/bases/search_node.py +1 -1
- vellum/workflows/nodes/displayable/code_execution_node/node.py +1 -1
- vellum/workflows/nodes/displayable/guardrail_node/node.py +1 -1
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +1 -1
- vellum/workflows/nodes/displayable/tool_calling_node/node.py +5 -0
- vellum/workflows/nodes/displayable/tool_calling_node/tests/test_node.py +3 -0
- vellum/workflows/nodes/displayable/tool_calling_node/utils.py +86 -114
- vellum/workflows/nodes/experimental/__init__.py +2 -2
- vellum/workflows/state/base.py +1 -1
- vellum/workflows/state/delta.py +1 -1
- {vellum_ai-0.14.89.dist-info → vellum_ai-1.0.1.dist-info}/METADATA +1 -1
- {vellum_ai-0.14.89.dist-info → vellum_ai-1.0.1.dist-info}/RECORD +59 -55
- vellum_cli/config.py +1 -1
- vellum_cli/push.py +1 -1
- vellum_cli/tests/test_ping.py +1 -0
- vellum_ee/workflows/display/base.py +0 -54
- vellum_ee/workflows/display/nodes/base_node_display.py +24 -0
- vellum_ee/workflows/display/nodes/vellum/api_node.py +20 -1
- vellum_ee/workflows/display/nodes/vellum/conditional_node.py +16 -2
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +0 -26
- vellum_ee/workflows/display/nodes/vellum/tests/test_api_node.py +31 -0
- vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +3 -3
- vellum_ee/workflows/display/tests/test_base_workflow_display.py +2 -4
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/conftest.py +2 -2
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +10 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +11 -11
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_serialization.py +21 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py +21 -0
- vellum_ee/workflows/display/vellum.py +2 -128
- vellum_ee/workflows/display/workflows/__init__.py +0 -1
- vellum_ee/workflows/display/workflows/base_workflow_display.py +15 -3
- vellum_ee/workflows/display/workflows/tests/test_workflow_display.py +127 -0
- vellum_ee/workflows/tests/local_workflow/display/nodes/final_output.py +1 -1
- vellum_ee/workflows/tests/local_workflow/display/nodes/templating_node.py +1 -1
- vellum_ee/workflows/tests/local_workflow/display/workflow.py +11 -14
- vellum/workflows/nodes/experimental/tool_calling_node/__init__.py +0 -3
- vellum/workflows/nodes/experimental/tool_calling_node/node.py +0 -3
- vellum_ee/workflows/display/workflows/vellum_workflow_display.py +0 -9
- {vellum_ai-0.14.89.dist-info → vellum_ai-1.0.1.dist-info}/LICENSE +0 -0
- {vellum_ai-0.14.89.dist-info → vellum_ai-1.0.1.dist-info}/WHEEL +0 -0
- {vellum_ai-0.14.89.dist-info → vellum_ai-1.0.1.dist-info}/entry_points.txt +0 -0
vellum/__init__.py
CHANGED
@@ -3,7 +3,7 @@ from .plugins.utils import load_runtime_plugins
|
|
3
3
|
|
4
4
|
load_runtime_plugins()
|
5
5
|
|
6
|
-
from .types import (
|
6
|
+
from .client.types import (
|
7
7
|
AdHocExecutePromptEvent,
|
8
8
|
AdHocExpandMeta,
|
9
9
|
AdHocFulfilledPromptExecutionMeta,
|
@@ -287,6 +287,7 @@ from .types import (
|
|
287
287
|
OpenAiVectorizerTextEmbedding3SmallRequest,
|
288
288
|
OpenAiVectorizerTextEmbeddingAda002,
|
289
289
|
OpenAiVectorizerTextEmbeddingAda002Request,
|
290
|
+
OrganizationLimitConfig,
|
290
291
|
OrganizationRead,
|
291
292
|
PaginatedContainerImageReadList,
|
292
293
|
PaginatedDeploymentReleaseTagReadList,
|
@@ -327,6 +328,7 @@ from .types import (
|
|
327
328
|
PromptRequestStringInput,
|
328
329
|
PromptSettings,
|
329
330
|
PromptVersionBuildConfigSandbox,
|
331
|
+
Quota,
|
330
332
|
RawPromptExecutionOverridesRequest,
|
331
333
|
ReductoChunkerConfig,
|
332
334
|
ReductoChunkerConfigRequest,
|
@@ -524,6 +526,7 @@ from .types import (
|
|
524
526
|
VellumVariableExtensions,
|
525
527
|
VellumVariableType,
|
526
528
|
VellumWorkflowExecutionEvent,
|
529
|
+
VembdaServiceTierEnum,
|
527
530
|
WorkflowDeploymentEventExecutionsResponse,
|
528
531
|
WorkflowDeploymentHistoryItem,
|
529
532
|
WorkflowDeploymentParentContext,
|
@@ -932,6 +935,7 @@ __all__ = [
|
|
932
935
|
"OpenAiVectorizerTextEmbedding3SmallRequest",
|
933
936
|
"OpenAiVectorizerTextEmbeddingAda002",
|
934
937
|
"OpenAiVectorizerTextEmbeddingAda002Request",
|
938
|
+
"OrganizationLimitConfig",
|
935
939
|
"OrganizationRead",
|
936
940
|
"PaginatedContainerImageReadList",
|
937
941
|
"PaginatedDeploymentReleaseTagReadList",
|
@@ -972,6 +976,7 @@ __all__ = [
|
|
972
976
|
"PromptRequestStringInput",
|
973
977
|
"PromptSettings",
|
974
978
|
"PromptVersionBuildConfigSandbox",
|
979
|
+
"Quota",
|
975
980
|
"RawPromptExecutionOverridesRequest",
|
976
981
|
"ReductoChunkerConfig",
|
977
982
|
"ReductoChunkerConfigRequest",
|
@@ -1171,6 +1176,7 @@ __all__ = [
|
|
1171
1176
|
"VellumVariableExtensions",
|
1172
1177
|
"VellumVariableType",
|
1173
1178
|
"VellumWorkflowExecutionEvent",
|
1179
|
+
"VembdaServiceTierEnum",
|
1174
1180
|
"WorkflowDeploymentEventExecutionsResponse",
|
1175
1181
|
"WorkflowDeploymentHistoryItem",
|
1176
1182
|
"WorkflowDeploymentParentContext",
|
vellum/client/__init__.py
CHANGED
@@ -128,7 +128,7 @@ class Vellum:
|
|
128
128
|
self,
|
129
129
|
*,
|
130
130
|
environment: VellumEnvironment = VellumEnvironment.PRODUCTION,
|
131
|
-
api_version: typing.Optional[ApiVersionEnum] = os.getenv("VELLUM_API_VERSION", "
|
131
|
+
api_version: typing.Optional[ApiVersionEnum] = os.getenv("VELLUM_API_VERSION", "2025-07-30"),
|
132
132
|
api_key: str,
|
133
133
|
timeout: typing.Optional[float] = None,
|
134
134
|
follow_redirects: typing.Optional[bool] = True,
|
@@ -1562,7 +1562,7 @@ class AsyncVellum:
|
|
1562
1562
|
self,
|
1563
1563
|
*,
|
1564
1564
|
environment: VellumEnvironment = VellumEnvironment.PRODUCTION,
|
1565
|
-
api_version: typing.Optional[ApiVersionEnum] = os.getenv("VELLUM_API_VERSION", "
|
1565
|
+
api_version: typing.Optional[ApiVersionEnum] = os.getenv("VELLUM_API_VERSION", "2025-07-30"),
|
1566
1566
|
api_key: str,
|
1567
1567
|
timeout: typing.Optional[float] = None,
|
1568
1568
|
follow_redirects: typing.Optional[bool] = True,
|
@@ -25,10 +25,10 @@ class BaseClientWrapper:
|
|
25
25
|
|
26
26
|
def get_headers(self) -> typing.Dict[str, str]:
|
27
27
|
headers: typing.Dict[str, str] = {
|
28
|
-
"User-Agent": "vellum-ai/0.
|
28
|
+
"User-Agent": "vellum-ai/1.0.1",
|
29
29
|
"X-Fern-Language": "Python",
|
30
30
|
"X-Fern-SDK-Name": "vellum-ai",
|
31
|
-
"X-Fern-SDK-Version": "0.
|
31
|
+
"X-Fern-SDK-Version": "1.0.1",
|
32
32
|
}
|
33
33
|
if self._api_version is not None:
|
34
34
|
headers["X-API-Version"] = self._api_version
|
vellum/client/types/__init__.py
CHANGED
@@ -295,6 +295,7 @@ from .open_ai_vectorizer_text_embedding_3_small import OpenAiVectorizerTextEmbed
|
|
295
295
|
from .open_ai_vectorizer_text_embedding_3_small_request import OpenAiVectorizerTextEmbedding3SmallRequest
|
296
296
|
from .open_ai_vectorizer_text_embedding_ada_002 import OpenAiVectorizerTextEmbeddingAda002
|
297
297
|
from .open_ai_vectorizer_text_embedding_ada_002_request import OpenAiVectorizerTextEmbeddingAda002Request
|
298
|
+
from .organization_limit_config import OrganizationLimitConfig
|
298
299
|
from .organization_read import OrganizationRead
|
299
300
|
from .paginated_container_image_read_list import PaginatedContainerImageReadList
|
300
301
|
from .paginated_deployment_release_tag_read_list import PaginatedDeploymentReleaseTagReadList
|
@@ -335,6 +336,7 @@ from .prompt_request_json_input import PromptRequestJsonInput
|
|
335
336
|
from .prompt_request_string_input import PromptRequestStringInput
|
336
337
|
from .prompt_settings import PromptSettings
|
337
338
|
from .prompt_version_build_config_sandbox import PromptVersionBuildConfigSandbox
|
339
|
+
from .quota import Quota
|
338
340
|
from .raw_prompt_execution_overrides_request import RawPromptExecutionOverridesRequest
|
339
341
|
from .reducto_chunker_config import ReductoChunkerConfig
|
340
342
|
from .reducto_chunker_config_request import ReductoChunkerConfigRequest
|
@@ -548,6 +550,7 @@ from .vellum_variable import VellumVariable
|
|
548
550
|
from .vellum_variable_extensions import VellumVariableExtensions
|
549
551
|
from .vellum_variable_type import VellumVariableType
|
550
552
|
from .vellum_workflow_execution_event import VellumWorkflowExecutionEvent
|
553
|
+
from .vembda_service_tier_enum import VembdaServiceTierEnum
|
551
554
|
from .workflow_deployment_event_executions_response import WorkflowDeploymentEventExecutionsResponse
|
552
555
|
from .workflow_deployment_history_item import WorkflowDeploymentHistoryItem
|
553
556
|
from .workflow_deployment_parent_context import WorkflowDeploymentParentContext
|
@@ -912,6 +915,7 @@ __all__ = [
|
|
912
915
|
"OpenAiVectorizerTextEmbedding3SmallRequest",
|
913
916
|
"OpenAiVectorizerTextEmbeddingAda002",
|
914
917
|
"OpenAiVectorizerTextEmbeddingAda002Request",
|
918
|
+
"OrganizationLimitConfig",
|
915
919
|
"OrganizationRead",
|
916
920
|
"PaginatedContainerImageReadList",
|
917
921
|
"PaginatedDeploymentReleaseTagReadList",
|
@@ -952,6 +956,7 @@ __all__ = [
|
|
952
956
|
"PromptRequestStringInput",
|
953
957
|
"PromptSettings",
|
954
958
|
"PromptVersionBuildConfigSandbox",
|
959
|
+
"Quota",
|
955
960
|
"RawPromptExecutionOverridesRequest",
|
956
961
|
"ReductoChunkerConfig",
|
957
962
|
"ReductoChunkerConfigRequest",
|
@@ -1149,6 +1154,7 @@ __all__ = [
|
|
1149
1154
|
"VellumVariableExtensions",
|
1150
1155
|
"VellumVariableType",
|
1151
1156
|
"VellumWorkflowExecutionEvent",
|
1157
|
+
"VembdaServiceTierEnum",
|
1152
1158
|
"WorkflowDeploymentEventExecutionsResponse",
|
1153
1159
|
"WorkflowDeploymentHistoryItem",
|
1154
1160
|
"WorkflowDeploymentParentContext",
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ..core.pydantic_utilities import UniversalBaseModel
|
4
|
+
import typing
|
5
|
+
from .vembda_service_tier_enum import VembdaServiceTierEnum
|
6
|
+
from .quota import Quota
|
7
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2
|
8
|
+
import pydantic
|
9
|
+
|
10
|
+
|
11
|
+
class OrganizationLimitConfig(UniversalBaseModel):
|
12
|
+
vembda_service_tier: typing.Optional[VembdaServiceTierEnum] = None
|
13
|
+
prompt_executions_quota: typing.Optional[Quota] = None
|
14
|
+
workflow_executions_quota: typing.Optional[Quota] = None
|
15
|
+
workflow_runtime_seconds_quota: typing.Optional[Quota] = None
|
16
|
+
|
17
|
+
if IS_PYDANTIC_V2:
|
18
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
19
|
+
else:
|
20
|
+
|
21
|
+
class Config:
|
22
|
+
frozen = True
|
23
|
+
smart_union = True
|
24
|
+
extra = pydantic.Extra.allow
|
@@ -3,6 +3,7 @@
|
|
3
3
|
from ..core.pydantic_utilities import UniversalBaseModel
|
4
4
|
import typing
|
5
5
|
from .new_member_join_behavior_enum import NewMemberJoinBehaviorEnum
|
6
|
+
from .organization_limit_config import OrganizationLimitConfig
|
6
7
|
from ..core.pydantic_utilities import IS_PYDANTIC_V2
|
7
8
|
import pydantic
|
8
9
|
|
@@ -12,6 +13,7 @@ class OrganizationRead(UniversalBaseModel):
|
|
12
13
|
name: str
|
13
14
|
allow_staff_access: typing.Optional[bool] = None
|
14
15
|
new_member_join_behavior: NewMemberJoinBehaviorEnum
|
16
|
+
limit_config: OrganizationLimitConfig
|
15
17
|
|
16
18
|
if IS_PYDANTIC_V2:
|
17
19
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
from ..core.pydantic_utilities import UniversalBaseModel
|
4
|
+
import typing
|
5
|
+
from ..core.pydantic_utilities import IS_PYDANTIC_V2
|
6
|
+
import pydantic
|
7
|
+
|
8
|
+
|
9
|
+
class Quota(UniversalBaseModel):
|
10
|
+
name: str
|
11
|
+
value: typing.Optional[int] = None
|
12
|
+
period_seconds: typing.Optional[int] = None
|
13
|
+
|
14
|
+
if IS_PYDANTIC_V2:
|
15
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
16
|
+
else:
|
17
|
+
|
18
|
+
class Config:
|
19
|
+
frozen = True
|
20
|
+
smart_union = True
|
21
|
+
extra = pydantic.Extra.allow
|
@@ -12,7 +12,7 @@ import pydantic
|
|
12
12
|
class WorkflowExecutionActual(UniversalBaseModel):
|
13
13
|
output: ExecutionVellumValue
|
14
14
|
timestamp: dt.datetime
|
15
|
-
quality: float
|
15
|
+
quality: typing.Optional[float] = None
|
16
16
|
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
|
17
17
|
|
18
18
|
if IS_PYDANTIC_V2:
|
vellum/evaluations/resources.py
CHANGED
@@ -8,11 +8,7 @@ from typing import Callable, Generator, Iterable, List, cast
|
|
8
8
|
|
9
9
|
from vellum import TestSuiteRunMetricNumberOutput, TestSuiteRunRead
|
10
10
|
from vellum.client import OMIT, Vellum
|
11
|
-
from vellum.
|
12
|
-
from vellum.evaluations.exceptions import TestSuiteRunResultsException
|
13
|
-
from vellum.evaluations.utils.env import get_api_key
|
14
|
-
from vellum.evaluations.utils.paginator import PaginatedResults, get_all_results
|
15
|
-
from vellum.types import (
|
11
|
+
from vellum.client.types import (
|
16
12
|
ExternalTestCaseExecutionRequest,
|
17
13
|
NamedTestCaseVariableValueRequest,
|
18
14
|
TestCaseVariableValue,
|
@@ -22,6 +18,10 @@ from vellum.types import (
|
|
22
18
|
TestSuiteRunMetricOutput,
|
23
19
|
TestSuiteRunState,
|
24
20
|
)
|
21
|
+
from vellum.evaluations.constants import DEFAULT_MAX_POLLING_DURATION_MS, DEFAULT_POLLING_INTERVAL_MS
|
22
|
+
from vellum.evaluations.exceptions import TestSuiteRunResultsException
|
23
|
+
from vellum.evaluations.utils.env import get_api_key
|
24
|
+
from vellum.evaluations.utils.paginator import PaginatedResults, get_all_results
|
25
25
|
from vellum.utils.typing import cast_not_optional
|
26
26
|
from vellum.utils.uuid import is_valid_uuid
|
27
27
|
|
vellum/types/quota.py
ADDED
vellum/workflows/events/node.py
CHANGED
@@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, Dict, Generic, List, Literal, Optional, S
|
|
2
2
|
|
3
3
|
from pydantic import SerializerFunctionWrapHandler, field_serializer, model_serializer
|
4
4
|
|
5
|
-
from vellum.core.pydantic_utilities import UniversalBaseModel
|
5
|
+
from vellum.client.core.pydantic_utilities import UniversalBaseModel
|
6
6
|
from vellum.workflows.errors import WorkflowError
|
7
7
|
from vellum.workflows.expressions.accessor import AccessorExpression
|
8
8
|
from vellum.workflows.outputs.base import BaseOutput
|
vellum/workflows/events/types.py
CHANGED
@@ -6,7 +6,7 @@ from typing import Annotated, Any, Literal, Optional, Union, get_args
|
|
6
6
|
from pydantic import Field, GetCoreSchemaHandler, Tag, ValidationInfo
|
7
7
|
from pydantic_core import CoreSchema, core_schema
|
8
8
|
|
9
|
-
from vellum.core.pydantic_utilities import UniversalBaseModel
|
9
|
+
from vellum.client.core.pydantic_utilities import UniversalBaseModel
|
10
10
|
from vellum.workflows.state.encoder import DefaultStateEncoder
|
11
11
|
from vellum.workflows.types.definition import VellumCodeResourceDefinition
|
12
12
|
from vellum.workflows.types.utils import datetime_now
|
@@ -4,7 +4,7 @@ from typing_extensions import TypeGuard
|
|
4
4
|
|
5
5
|
from pydantic import field_serializer
|
6
6
|
|
7
|
-
from vellum.core.pydantic_utilities import UniversalBaseModel
|
7
|
+
from vellum.client.core.pydantic_utilities import UniversalBaseModel
|
8
8
|
from vellum.workflows.errors import WorkflowError
|
9
9
|
from vellum.workflows.outputs.base import BaseOutput
|
10
10
|
from vellum.workflows.references import ExternalInputReference
|
@@ -2,8 +2,8 @@ import pytest
|
|
2
2
|
from uuid import UUID
|
3
3
|
from typing import Optional, Set
|
4
4
|
|
5
|
+
from vellum.client.core.pydantic_utilities import UniversalBaseModel
|
5
6
|
from vellum.client.types.string_vellum_value_request import StringVellumValueRequest
|
6
|
-
from vellum.core.pydantic_utilities import UniversalBaseModel
|
7
7
|
from vellum.workflows.constants import undefined
|
8
8
|
from vellum.workflows.descriptors.tests.test_utils import FixtureState
|
9
9
|
from vellum.workflows.inputs.base import BaseInputs
|
@@ -233,3 +233,33 @@ def test_api_node_raises_error_for_whitespace_url():
|
|
233
233
|
|
234
234
|
assert excinfo.value.code == WorkflowErrorCode.INVALID_INPUTS
|
235
235
|
assert "URL is required and must be a non-empty string" in str(excinfo.value)
|
236
|
+
|
237
|
+
|
238
|
+
def test_api_node_passes_timeout_to_vellum_client(vellum_client):
|
239
|
+
"""Test that timeout is passed to vellum client as RequestOptions."""
|
240
|
+
vellum_client.execute_api.return_value = ExecuteApiResponse(
|
241
|
+
status_code=200,
|
242
|
+
text='{"result": "success"}',
|
243
|
+
json_={"result": "success"},
|
244
|
+
headers={"content-type": "application/json"},
|
245
|
+
)
|
246
|
+
|
247
|
+
# GIVEN an API node configured with a timeout value of 25 seconds
|
248
|
+
class APINodeWithTimeout(APINode):
|
249
|
+
method = APIRequestMethod.GET
|
250
|
+
authorization_type = AuthorizationType.BEARER_TOKEN
|
251
|
+
url = "https://example.com"
|
252
|
+
timeout = 25
|
253
|
+
bearer_token_value = VellumSecret(name="secret")
|
254
|
+
|
255
|
+
# WHEN the API node is executed
|
256
|
+
node = APINodeWithTimeout()
|
257
|
+
node.run()
|
258
|
+
|
259
|
+
# THEN the vellum client should be called exactly once
|
260
|
+
assert vellum_client.execute_api.call_count == 1
|
261
|
+
call_args = vellum_client.execute_api.call_args
|
262
|
+
request_options = call_args.kwargs["request_options"]
|
263
|
+
# AND the call should include RequestOptions with the correct timeout
|
264
|
+
assert request_options is not None
|
265
|
+
assert request_options["timeout_in_seconds"] == 25
|
@@ -4,6 +4,7 @@ from requests import Request, RequestException, Session
|
|
4
4
|
from requests.exceptions import JSONDecodeError
|
5
5
|
|
6
6
|
from vellum.client import ApiError
|
7
|
+
from vellum.client.core.request_options import RequestOptions
|
7
8
|
from vellum.client.types.vellum_secret import VellumSecret as ClientVellumSecret
|
8
9
|
from vellum.workflows.constants import APIRequestMethod
|
9
10
|
from vellum.workflows.errors.types import WorkflowErrorCode
|
@@ -23,6 +24,7 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
23
24
|
data: Optional[str] - The data to send in the request body.
|
24
25
|
json: Optional["JsonObject"] - The JSON data to send in the request body.
|
25
26
|
headers: Optional[Dict[str, Union[str, VellumSecret]]] - The headers to send in the request.
|
27
|
+
timeout: Optional[int] - The timeout in seconds for the API request.
|
26
28
|
"""
|
27
29
|
|
28
30
|
class Trigger(BaseNode.Trigger):
|
@@ -33,6 +35,7 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
33
35
|
data: Optional[str] = None
|
34
36
|
json: Optional[Json] = None
|
35
37
|
headers: Optional[Dict[str, Union[str, VellumSecret]]] = None
|
38
|
+
timeout: Optional[int] = None
|
36
39
|
|
37
40
|
class Outputs(BaseOutputs):
|
38
41
|
json: Optional[Json]
|
@@ -45,7 +48,9 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
45
48
|
raise NodeException("URL is required and must be a non-empty string", code=WorkflowErrorCode.INVALID_INPUTS)
|
46
49
|
|
47
50
|
def run(self) -> Outputs:
|
48
|
-
return self._run(
|
51
|
+
return self._run(
|
52
|
+
method=self.method, url=self.url, data=self.data, json=self.json, headers=self.headers, timeout=self.timeout
|
53
|
+
)
|
49
54
|
|
50
55
|
def _run(
|
51
56
|
self,
|
@@ -55,6 +60,7 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
55
60
|
json: Any = None,
|
56
61
|
headers: Any = None,
|
57
62
|
bearer_token: Optional[VellumSecret] = None,
|
63
|
+
timeout: Optional[int] = None,
|
58
64
|
) -> Outputs:
|
59
65
|
self._validate()
|
60
66
|
|
@@ -63,11 +69,11 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
63
69
|
if isinstance(headers[header], VellumSecret):
|
64
70
|
vellum_instance = True
|
65
71
|
if vellum_instance or bearer_token:
|
66
|
-
return self._vellum_execute_api(bearer_token, json, headers, method, url)
|
72
|
+
return self._vellum_execute_api(bearer_token, json, headers, method, url, timeout)
|
67
73
|
else:
|
68
|
-
return self._local_execute_api(data, headers, json, method, url)
|
74
|
+
return self._local_execute_api(data, headers, json, method, url, timeout)
|
69
75
|
|
70
|
-
def _local_execute_api(self, data, headers, json, method, url):
|
76
|
+
def _local_execute_api(self, data, headers, json, method, url, timeout):
|
71
77
|
try:
|
72
78
|
if data is not None:
|
73
79
|
prepped = Request(method=method.value, url=url, data=data, headers=headers).prepare()
|
@@ -79,25 +85,36 @@ class BaseAPINode(BaseNode, Generic[StateType]):
|
|
79
85
|
raise NodeException(f"Failed to prepare HTTP request: {e}", code=WorkflowErrorCode.PROVIDER_ERROR)
|
80
86
|
try:
|
81
87
|
with Session() as session:
|
82
|
-
response = session.send(prepped)
|
88
|
+
response = session.send(prepped, timeout=timeout)
|
83
89
|
except RequestException as e:
|
84
90
|
raise NodeException(f"HTTP request failed: {e}", code=WorkflowErrorCode.PROVIDER_ERROR)
|
85
91
|
try:
|
86
|
-
|
92
|
+
json_response = response.json()
|
87
93
|
except JSONDecodeError:
|
88
|
-
|
94
|
+
json_response = None
|
89
95
|
return self.Outputs(
|
90
|
-
json=
|
96
|
+
json=json_response,
|
91
97
|
headers={header: value for header, value in response.headers.items()},
|
92
98
|
status_code=response.status_code,
|
93
99
|
text=response.text,
|
94
100
|
)
|
95
101
|
|
96
|
-
def _vellum_execute_api(self, bearer_token, data, headers, method, url):
|
102
|
+
def _vellum_execute_api(self, bearer_token, data, headers, method, url, timeout):
|
97
103
|
client_vellum_secret = ClientVellumSecret(name=bearer_token.name) if bearer_token else None
|
104
|
+
|
105
|
+
# Create request_options if timeout is specified
|
106
|
+
request_options = None
|
107
|
+
if timeout is not None:
|
108
|
+
request_options = RequestOptions(timeout_in_seconds=timeout)
|
109
|
+
|
98
110
|
try:
|
99
111
|
vellum_response = self._context.vellum_client.execute_api(
|
100
|
-
url=url,
|
112
|
+
url=url,
|
113
|
+
method=method.value,
|
114
|
+
body=data,
|
115
|
+
headers=headers,
|
116
|
+
bearer_token=client_vellum_secret,
|
117
|
+
request_options=request_options,
|
101
118
|
)
|
102
119
|
except ApiError as e:
|
103
120
|
raise NodeException(f"Failed to prepare HTTP request: {e}", code=WorkflowErrorCode.NODE_EXECUTION)
|
@@ -2,8 +2,8 @@ from abc import abstractmethod
|
|
2
2
|
from typing import ClassVar, Generator, Generic, Iterator, List, Optional, Union
|
3
3
|
|
4
4
|
from vellum import AdHocExecutePromptEvent, ExecutePromptEvent, PromptOutput
|
5
|
+
from vellum.client.core import RequestOptions
|
5
6
|
from vellum.client.core.api_error import ApiError
|
6
|
-
from vellum.core import RequestOptions
|
7
7
|
from vellum.workflows.errors.types import WorkflowErrorCode, vellum_error_to_workflow_error
|
8
8
|
from vellum.workflows.events.node import NodeExecutionStreamingEvent
|
9
9
|
from vellum.workflows.exceptions import NodeException
|
@@ -11,7 +11,7 @@ from vellum import (
|
|
11
11
|
SearchResultMergingRequest,
|
12
12
|
SearchWeightsRequest,
|
13
13
|
)
|
14
|
-
from vellum.core import ApiError, RequestOptions
|
14
|
+
from vellum.client.core import ApiError, RequestOptions
|
15
15
|
from vellum.workflows.errors import WorkflowErrorCode
|
16
16
|
from vellum.workflows.exceptions import NodeException
|
17
17
|
from vellum.workflows.nodes.bases import BaseNode
|
@@ -20,9 +20,9 @@ from vellum import (
|
|
20
20
|
VellumError,
|
21
21
|
VellumValue,
|
22
22
|
)
|
23
|
+
from vellum.client.core import RequestOptions
|
23
24
|
from vellum.client.core.api_error import ApiError
|
24
25
|
from vellum.client.types.code_executor_secret_input import CodeExecutorSecretInput
|
25
|
-
from vellum.core import RequestOptions
|
26
26
|
from vellum.workflows.errors.types import WorkflowErrorCode
|
27
27
|
from vellum.workflows.exceptions import NodeException
|
28
28
|
from vellum.workflows.nodes.bases import BaseNode
|
@@ -3,7 +3,7 @@ from typing import Any, ClassVar, Dict, Generic, List, Optional, Union, cast
|
|
3
3
|
|
4
4
|
from vellum import ChatHistoryInput, ChatMessage, JsonInput, MetricDefinitionInput, NumberInput, StringInput
|
5
5
|
from vellum.client import ApiError
|
6
|
-
from vellum.core import RequestOptions
|
6
|
+
from vellum.client.core import RequestOptions
|
7
7
|
from vellum.workflows.constants import LATEST_RELEASE_TAG
|
8
8
|
from vellum.workflows.errors.types import WorkflowErrorCode
|
9
9
|
from vellum.workflows.exceptions import NodeException
|
@@ -12,9 +12,9 @@ from vellum import (
|
|
12
12
|
WorkflowRequestNumberInputRequest,
|
13
13
|
WorkflowRequestStringInputRequest,
|
14
14
|
)
|
15
|
+
from vellum.client.core import RequestOptions
|
15
16
|
from vellum.client.core.api_error import ApiError
|
16
17
|
from vellum.client.types.chat_message_request import ChatMessageRequest
|
17
|
-
from vellum.core import RequestOptions
|
18
18
|
from vellum.workflows.constants import LATEST_RELEASE_TAG, OMIT
|
19
19
|
from vellum.workflows.context import get_execution_context
|
20
20
|
from vellum.workflows.errors import WorkflowErrorCode
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from typing import ClassVar, Iterator, List, Optional, Set
|
2
2
|
|
3
3
|
from vellum import ChatMessage, PromptBlock
|
4
|
+
from vellum.client.types.prompt_parameters import PromptParameters
|
4
5
|
from vellum.workflows.context import execution_context, get_parent_context
|
5
6
|
from vellum.workflows.errors.types import WorkflowErrorCode
|
6
7
|
from vellum.workflows.events.workflow import is_workflow_event
|
@@ -8,6 +9,7 @@ from vellum.workflows.exceptions import NodeException
|
|
8
9
|
from vellum.workflows.graph.graph import Graph
|
9
10
|
from vellum.workflows.inputs.base import BaseInputs
|
10
11
|
from vellum.workflows.nodes.bases import BaseNode
|
12
|
+
from vellum.workflows.nodes.displayable.bases.inline_prompt_node.constants import DEFAULT_PROMPT_PARAMETERS
|
11
13
|
from vellum.workflows.nodes.displayable.tool_calling_node.state import ToolCallingState
|
12
14
|
from vellum.workflows.nodes.displayable.tool_calling_node.utils import (
|
13
15
|
create_function_node,
|
@@ -29,6 +31,7 @@ class ToolCallingNode(BaseNode):
|
|
29
31
|
blocks: List[PromptBlock] - The prompt blocks to use (same format as InlinePromptNode)
|
30
32
|
functions: List[Tool] - The functions that can be called
|
31
33
|
prompt_inputs: Optional[EntityInputsInterface] - Mapping of input variable names to values
|
34
|
+
parameters: PromptParameters - The parameters for the Prompt
|
32
35
|
max_prompt_iterations: Optional[int] - Maximum number of prompt iterations before stopping
|
33
36
|
"""
|
34
37
|
|
@@ -36,6 +39,7 @@ class ToolCallingNode(BaseNode):
|
|
36
39
|
blocks: ClassVar[List[PromptBlock]] = []
|
37
40
|
functions: ClassVar[List[Tool]] = []
|
38
41
|
prompt_inputs: ClassVar[Optional[EntityInputsInterface]] = None
|
42
|
+
parameters: PromptParameters = DEFAULT_PROMPT_PARAMETERS
|
39
43
|
max_prompt_iterations: ClassVar[Optional[int]] = 5
|
40
44
|
|
41
45
|
class Outputs(BaseOutputs):
|
@@ -131,6 +135,7 @@ class ToolCallingNode(BaseNode):
|
|
131
135
|
blocks=self.blocks,
|
132
136
|
functions=self.functions,
|
133
137
|
prompt_inputs=self.prompt_inputs,
|
138
|
+
parameters=self.parameters,
|
134
139
|
max_prompt_iterations=self.max_prompt_iterations,
|
135
140
|
)
|
136
141
|
|
@@ -13,6 +13,7 @@ from vellum.client.types.variable_prompt_block import VariablePromptBlock
|
|
13
13
|
from vellum.workflows import BaseWorkflow
|
14
14
|
from vellum.workflows.inputs.base import BaseInputs
|
15
15
|
from vellum.workflows.nodes.bases import BaseNode
|
16
|
+
from vellum.workflows.nodes.displayable.bases.inline_prompt_node.constants import DEFAULT_PROMPT_PARAMETERS
|
16
17
|
from vellum.workflows.nodes.displayable.tool_calling_node.node import ToolCallingNode
|
17
18
|
from vellum.workflows.nodes.displayable.tool_calling_node.utils import create_function_node, create_tool_router_node
|
18
19
|
from vellum.workflows.outputs.base import BaseOutputs
|
@@ -39,6 +40,7 @@ def test_port_condition_match_function_name():
|
|
39
40
|
blocks=[],
|
40
41
|
functions=[first_function, second_function],
|
41
42
|
prompt_inputs=None,
|
43
|
+
parameters=DEFAULT_PROMPT_PARAMETERS,
|
42
44
|
)
|
43
45
|
|
44
46
|
# AND a state with a function call to the first function
|
@@ -96,6 +98,7 @@ def test_tool_calling_node_inline_workflow_context():
|
|
96
98
|
blocks=[],
|
97
99
|
functions=[MyWorkflow],
|
98
100
|
prompt_inputs=None,
|
101
|
+
parameters=DEFAULT_PROMPT_PARAMETERS,
|
99
102
|
)
|
100
103
|
|
101
104
|
# WHEN we create a function node for the workflow
|