vellum-ai 1.0.11__py3-none-any.whl → 1.1.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 +2 -2
- vellum/client/README.md +0 -55
- vellum/client/__init__.py +159 -877
- vellum/client/core/__init__.py +3 -0
- vellum/client/core/client_wrapper.py +2 -2
- vellum/client/core/http_response.py +47 -0
- vellum/client/raw_client.py +1561 -0
- vellum/client/reference.md +22 -696
- vellum/client/resources/__init__.py +0 -2
- vellum/client/resources/ad_hoc/client.py +55 -161
- vellum/client/resources/ad_hoc/raw_client.py +278 -0
- vellum/client/resources/container_images/client.py +62 -172
- vellum/client/resources/container_images/raw_client.py +400 -0
- vellum/client/resources/deployments/client.py +112 -437
- vellum/client/resources/deployments/raw_client.py +995 -0
- vellum/client/resources/document_indexes/client.py +108 -317
- vellum/client/resources/document_indexes/raw_client.py +847 -0
- vellum/client/resources/documents/client.py +88 -285
- vellum/client/resources/documents/raw_client.py +655 -0
- vellum/client/resources/folder_entities/client.py +54 -92
- vellum/client/resources/folder_entities/raw_client.py +277 -0
- vellum/client/resources/metric_definitions/client.py +48 -95
- vellum/client/resources/metric_definitions/raw_client.py +225 -0
- vellum/client/resources/ml_models/client.py +36 -40
- vellum/client/resources/ml_models/raw_client.py +103 -0
- vellum/client/resources/organizations/client.py +34 -39
- vellum/client/resources/organizations/raw_client.py +96 -0
- vellum/client/resources/prompts/client.py +50 -193
- vellum/client/resources/prompts/raw_client.py +346 -0
- vellum/client/resources/sandboxes/client.py +68 -141
- vellum/client/resources/sandboxes/raw_client.py +393 -0
- vellum/client/resources/test_suite_runs/client.py +58 -141
- vellum/client/resources/test_suite_runs/raw_client.py +355 -0
- vellum/client/resources/test_suites/client.py +73 -141
- vellum/client/resources/test_suites/raw_client.py +379 -0
- vellum/client/resources/workflow_deployments/client.py +203 -328
- vellum/client/resources/workflow_deployments/raw_client.py +931 -0
- vellum/client/resources/workflow_executions/client.py +36 -40
- vellum/client/resources/workflow_executions/raw_client.py +97 -0
- vellum/client/resources/workflow_sandboxes/client.py +60 -108
- vellum/client/resources/workflow_sandboxes/raw_client.py +300 -0
- vellum/client/resources/workflows/client.py +68 -133
- vellum/client/resources/workflows/raw_client.py +307 -0
- vellum/client/resources/workspace_secrets/client.py +46 -90
- vellum/client/resources/workspace_secrets/raw_client.py +220 -0
- vellum/client/resources/workspaces/client.py +34 -39
- vellum/client/resources/workspaces/raw_client.py +96 -0
- vellum/client/types/__init__.py +2 -0
- vellum/client/types/api_request_parent_context.py +1 -0
- vellum/client/types/external_parent_context.py +36 -0
- vellum/client/types/node_execution_fulfilled_event.py +1 -0
- vellum/client/types/node_execution_initiated_event.py +1 -0
- vellum/client/types/node_execution_paused_event.py +1 -0
- vellum/client/types/node_execution_rejected_event.py +1 -0
- vellum/client/types/node_execution_resumed_event.py +1 -0
- vellum/client/types/node_execution_span.py +1 -0
- vellum/client/types/node_execution_span_attributes.py +1 -0
- vellum/client/types/node_execution_streaming_event.py +1 -0
- vellum/client/types/node_parent_context.py +1 -0
- vellum/client/types/parent_context.py +2 -0
- vellum/client/types/prompt_deployment_parent_context.py +1 -0
- vellum/client/types/slim_workflow_execution_read.py +1 -0
- vellum/client/types/span_link.py +1 -0
- vellum/client/types/workflow_deployment_event_executions_response.py +1 -0
- vellum/client/types/workflow_deployment_parent_context.py +1 -0
- vellum/client/types/workflow_event_execution_read.py +1 -0
- vellum/client/types/workflow_execution_detail.py +1 -0
- vellum/client/types/workflow_execution_fulfilled_event.py +1 -0
- vellum/client/types/workflow_execution_initiated_event.py +1 -0
- vellum/client/types/workflow_execution_paused_event.py +1 -0
- vellum/client/types/workflow_execution_rejected_event.py +1 -0
- vellum/client/types/workflow_execution_resumed_event.py +1 -0
- vellum/client/types/workflow_execution_snapshotted_event.py +1 -0
- vellum/client/types/workflow_execution_span.py +1 -0
- vellum/client/types/workflow_execution_span_attributes.py +1 -0
- vellum/client/types/workflow_execution_streaming_event.py +1 -0
- vellum/client/types/workflow_parent_context.py +1 -0
- vellum/client/types/workflow_sandbox_parent_context.py +1 -0
- vellum/{resources/release_reviews/__init__.py → core/http_response.py} +1 -1
- vellum/{resources/release_reviews/client.py → raw_client.py} +1 -1
- vellum/resources/ad_hoc/raw_client.py +3 -0
- vellum/resources/container_images/raw_client.py +3 -0
- vellum/resources/deployments/raw_client.py +3 -0
- vellum/resources/document_indexes/raw_client.py +3 -0
- vellum/resources/documents/raw_client.py +3 -0
- vellum/resources/folder_entities/raw_client.py +3 -0
- vellum/resources/metric_definitions/raw_client.py +3 -0
- vellum/resources/ml_models/raw_client.py +3 -0
- vellum/resources/organizations/raw_client.py +3 -0
- vellum/resources/prompts/raw_client.py +3 -0
- vellum/resources/sandboxes/raw_client.py +3 -0
- vellum/resources/test_suite_runs/raw_client.py +3 -0
- vellum/resources/test_suites/raw_client.py +3 -0
- vellum/resources/workflow_deployments/raw_client.py +3 -0
- vellum/resources/workflow_executions/raw_client.py +3 -0
- vellum/resources/workflow_sandboxes/raw_client.py +3 -0
- vellum/resources/workflows/raw_client.py +3 -0
- vellum/resources/workspace_secrets/raw_client.py +3 -0
- vellum/resources/workspaces/raw_client.py +3 -0
- vellum/types/external_parent_context.py +3 -0
- vellum/workflows/emitters/vellum_emitter.py +3 -2
- vellum/workflows/events/types.py +6 -0
- vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py +5 -15
- vellum/workflows/nodes/displayable/tool_calling_node/node.py +6 -0
- vellum/workflows/nodes/displayable/tool_calling_node/utils.py +75 -0
- vellum/workflows/state/context.py +13 -2
- vellum/workflows/types/definition.py +2 -2
- vellum/workflows/types/tests/test_definition.py +2 -3
- vellum/workflows/utils/functions.py +1 -1
- vellum/workflows/utils/tests/test_functions.py +3 -3
- {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/METADATA +1 -1
- {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/RECORD +123 -81
- vellum_ee/workflows/display/exceptions.py +7 -0
- vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +2 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +53 -2
- vellum_ee/workflows/display/nodes/vellum/tests/test_tool_calling_node.py +93 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_mcp_serialization.py +98 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_workflow_deployment_serialization.py +1 -1
- vellum_ee/workflows/display/utils/expressions.py +1 -1
- vellum_ee/workflows/display/workflows/base_workflow_display.py +2 -1
- vellum/client/resources/release_reviews/__init__.py +0 -2
- vellum/client/resources/release_reviews/client.py +0 -139
- {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/LICENSE +0 -0
- {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/WHEEL +0 -0
- {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/entry_points.txt +0 -0
@@ -11,7 +11,6 @@ from . import (
|
|
11
11
|
ml_models,
|
12
12
|
organizations,
|
13
13
|
prompts,
|
14
|
-
release_reviews,
|
15
14
|
sandboxes,
|
16
15
|
test_suite_runs,
|
17
16
|
test_suites,
|
@@ -46,7 +45,6 @@ __all__ = [
|
|
46
45
|
"ml_models",
|
47
46
|
"organizations",
|
48
47
|
"prompts",
|
49
|
-
"release_reviews",
|
50
48
|
"sandboxes",
|
51
49
|
"test_suite_runs",
|
52
50
|
"test_suites",
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
import typing
|
4
4
|
from ...core.client_wrapper import SyncClientWrapper
|
5
|
+
from .raw_client import RawAdHocClient
|
5
6
|
from ...types.prompt_request_input import PromptRequestInput
|
6
7
|
from ...types.vellum_variable import VellumVariable
|
7
8
|
from ...types.prompt_parameters import PromptParameters
|
@@ -13,13 +14,14 @@ from ...core.request_options import RequestOptions
|
|
13
14
|
from ...types.ad_hoc_execute_prompt_event import AdHocExecutePromptEvent
|
14
15
|
from ...core.serialization import convert_and_respect_annotation_metadata
|
15
16
|
from ...core.pydantic_utilities import parse_obj_as
|
17
|
+
import json
|
16
18
|
from ...errors.bad_request_error import BadRequestError
|
17
19
|
from ...errors.forbidden_error import ForbiddenError
|
18
20
|
from ...errors.internal_server_error import InternalServerError
|
19
21
|
from json.decoder import JSONDecodeError
|
20
22
|
from ...core.api_error import ApiError
|
21
|
-
import json
|
22
23
|
from ...core.client_wrapper import AsyncClientWrapper
|
24
|
+
from .raw_client import AsyncRawAdHocClient
|
23
25
|
|
24
26
|
# this is used as the default value for optional parameters
|
25
27
|
OMIT = typing.cast(typing.Any, ...)
|
@@ -27,7 +29,22 @@ OMIT = typing.cast(typing.Any, ...)
|
|
27
29
|
|
28
30
|
class AdHocClient:
|
29
31
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
30
|
-
self.
|
32
|
+
self._raw_client = RawAdHocClient(client_wrapper=client_wrapper)
|
33
|
+
|
34
|
+
@property
|
35
|
+
def _client_wrapper(self) -> SyncClientWrapper:
|
36
|
+
return self._raw_client._client_wrapper
|
37
|
+
|
38
|
+
@property
|
39
|
+
def with_raw_response(self) -> RawAdHocClient:
|
40
|
+
"""
|
41
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
42
|
+
|
43
|
+
Returns
|
44
|
+
-------
|
45
|
+
RawAdHocClient
|
46
|
+
"""
|
47
|
+
return self._raw_client
|
31
48
|
|
32
49
|
def adhoc_execute_prompt(
|
33
50
|
self,
|
@@ -118,85 +135,18 @@ class AdHocClient:
|
|
118
135
|
],
|
119
136
|
)
|
120
137
|
"""
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
"input_variables": convert_and_respect_annotation_metadata(
|
131
|
-
object_=input_variables, annotation=typing.Sequence[VellumVariable], direction="write"
|
132
|
-
),
|
133
|
-
"parameters": convert_and_respect_annotation_metadata(
|
134
|
-
object_=parameters, annotation=PromptParameters, direction="write"
|
135
|
-
),
|
136
|
-
"settings": convert_and_respect_annotation_metadata(
|
137
|
-
object_=settings, annotation=typing.Optional[PromptSettings], direction="write"
|
138
|
-
),
|
139
|
-
"blocks": convert_and_respect_annotation_metadata(
|
140
|
-
object_=blocks, annotation=typing.Sequence[PromptBlock], direction="write"
|
141
|
-
),
|
142
|
-
"functions": convert_and_respect_annotation_metadata(
|
143
|
-
object_=functions,
|
144
|
-
annotation=typing.Optional[typing.Sequence[FunctionDefinition]],
|
145
|
-
direction="write",
|
146
|
-
),
|
147
|
-
"expand_meta": convert_and_respect_annotation_metadata(
|
148
|
-
object_=expand_meta, annotation=typing.Optional[AdHocExpandMeta], direction="write"
|
149
|
-
),
|
150
|
-
},
|
151
|
-
headers={
|
152
|
-
"content-type": "application/json",
|
153
|
-
},
|
138
|
+
response = self._raw_client.adhoc_execute_prompt(
|
139
|
+
ml_model=ml_model,
|
140
|
+
input_values=input_values,
|
141
|
+
input_variables=input_variables,
|
142
|
+
parameters=parameters,
|
143
|
+
blocks=blocks,
|
144
|
+
settings=settings,
|
145
|
+
functions=functions,
|
146
|
+
expand_meta=expand_meta,
|
154
147
|
request_options=request_options,
|
155
|
-
omit=OMIT,
|
156
148
|
)
|
157
|
-
|
158
|
-
if 200 <= _response.status_code < 300:
|
159
|
-
return typing.cast(
|
160
|
-
AdHocExecutePromptEvent,
|
161
|
-
parse_obj_as(
|
162
|
-
type_=AdHocExecutePromptEvent, # type: ignore
|
163
|
-
object_=_response.json(),
|
164
|
-
),
|
165
|
-
)
|
166
|
-
if _response.status_code == 400:
|
167
|
-
raise BadRequestError(
|
168
|
-
typing.cast(
|
169
|
-
typing.Optional[typing.Any],
|
170
|
-
parse_obj_as(
|
171
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
172
|
-
object_=_response.json(),
|
173
|
-
),
|
174
|
-
)
|
175
|
-
)
|
176
|
-
if _response.status_code == 403:
|
177
|
-
raise ForbiddenError(
|
178
|
-
typing.cast(
|
179
|
-
typing.Optional[typing.Any],
|
180
|
-
parse_obj_as(
|
181
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
182
|
-
object_=_response.json(),
|
183
|
-
),
|
184
|
-
)
|
185
|
-
)
|
186
|
-
if _response.status_code == 500:
|
187
|
-
raise InternalServerError(
|
188
|
-
typing.cast(
|
189
|
-
typing.Optional[typing.Any],
|
190
|
-
parse_obj_as(
|
191
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
192
|
-
object_=_response.json(),
|
193
|
-
),
|
194
|
-
)
|
195
|
-
)
|
196
|
-
_response_json = _response.json()
|
197
|
-
except JSONDecodeError:
|
198
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
199
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
149
|
+
return response.data
|
200
150
|
|
201
151
|
def adhoc_execute_prompt_stream(
|
202
152
|
self,
|
@@ -289,9 +239,9 @@ class AdHocClient:
|
|
289
239
|
for chunk in response:
|
290
240
|
yield chunk
|
291
241
|
"""
|
292
|
-
with self._client_wrapper.httpx_client.stream(
|
242
|
+
with self._raw_client._client_wrapper.httpx_client.stream(
|
293
243
|
"v1/ad-hoc/execute-prompt-stream",
|
294
|
-
base_url=self._client_wrapper.get_environment().predict,
|
244
|
+
base_url=self._raw_client._client_wrapper.get_environment().predict,
|
295
245
|
method="POST",
|
296
246
|
json={
|
297
247
|
"ml_model": ml_model,
|
@@ -380,7 +330,18 @@ class AdHocClient:
|
|
380
330
|
|
381
331
|
class AsyncAdHocClient:
|
382
332
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
383
|
-
self.
|
333
|
+
self._raw_client = AsyncRawAdHocClient(client_wrapper=client_wrapper)
|
334
|
+
|
335
|
+
@property
|
336
|
+
def with_raw_response(self) -> AsyncRawAdHocClient:
|
337
|
+
"""
|
338
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
339
|
+
|
340
|
+
Returns
|
341
|
+
-------
|
342
|
+
AsyncRawAdHocClient
|
343
|
+
"""
|
344
|
+
return self._raw_client
|
384
345
|
|
385
346
|
async def adhoc_execute_prompt(
|
386
347
|
self,
|
@@ -479,85 +440,18 @@ class AsyncAdHocClient:
|
|
479
440
|
|
480
441
|
asyncio.run(main())
|
481
442
|
"""
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
"input_variables": convert_and_respect_annotation_metadata(
|
492
|
-
object_=input_variables, annotation=typing.Sequence[VellumVariable], direction="write"
|
493
|
-
),
|
494
|
-
"parameters": convert_and_respect_annotation_metadata(
|
495
|
-
object_=parameters, annotation=PromptParameters, direction="write"
|
496
|
-
),
|
497
|
-
"settings": convert_and_respect_annotation_metadata(
|
498
|
-
object_=settings, annotation=typing.Optional[PromptSettings], direction="write"
|
499
|
-
),
|
500
|
-
"blocks": convert_and_respect_annotation_metadata(
|
501
|
-
object_=blocks, annotation=typing.Sequence[PromptBlock], direction="write"
|
502
|
-
),
|
503
|
-
"functions": convert_and_respect_annotation_metadata(
|
504
|
-
object_=functions,
|
505
|
-
annotation=typing.Optional[typing.Sequence[FunctionDefinition]],
|
506
|
-
direction="write",
|
507
|
-
),
|
508
|
-
"expand_meta": convert_and_respect_annotation_metadata(
|
509
|
-
object_=expand_meta, annotation=typing.Optional[AdHocExpandMeta], direction="write"
|
510
|
-
),
|
511
|
-
},
|
512
|
-
headers={
|
513
|
-
"content-type": "application/json",
|
514
|
-
},
|
443
|
+
response = await self._raw_client.adhoc_execute_prompt(
|
444
|
+
ml_model=ml_model,
|
445
|
+
input_values=input_values,
|
446
|
+
input_variables=input_variables,
|
447
|
+
parameters=parameters,
|
448
|
+
blocks=blocks,
|
449
|
+
settings=settings,
|
450
|
+
functions=functions,
|
451
|
+
expand_meta=expand_meta,
|
515
452
|
request_options=request_options,
|
516
|
-
omit=OMIT,
|
517
453
|
)
|
518
|
-
|
519
|
-
if 200 <= _response.status_code < 300:
|
520
|
-
return typing.cast(
|
521
|
-
AdHocExecutePromptEvent,
|
522
|
-
parse_obj_as(
|
523
|
-
type_=AdHocExecutePromptEvent, # type: ignore
|
524
|
-
object_=_response.json(),
|
525
|
-
),
|
526
|
-
)
|
527
|
-
if _response.status_code == 400:
|
528
|
-
raise BadRequestError(
|
529
|
-
typing.cast(
|
530
|
-
typing.Optional[typing.Any],
|
531
|
-
parse_obj_as(
|
532
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
533
|
-
object_=_response.json(),
|
534
|
-
),
|
535
|
-
)
|
536
|
-
)
|
537
|
-
if _response.status_code == 403:
|
538
|
-
raise ForbiddenError(
|
539
|
-
typing.cast(
|
540
|
-
typing.Optional[typing.Any],
|
541
|
-
parse_obj_as(
|
542
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
543
|
-
object_=_response.json(),
|
544
|
-
),
|
545
|
-
)
|
546
|
-
)
|
547
|
-
if _response.status_code == 500:
|
548
|
-
raise InternalServerError(
|
549
|
-
typing.cast(
|
550
|
-
typing.Optional[typing.Any],
|
551
|
-
parse_obj_as(
|
552
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
553
|
-
object_=_response.json(),
|
554
|
-
),
|
555
|
-
)
|
556
|
-
)
|
557
|
-
_response_json = _response.json()
|
558
|
-
except JSONDecodeError:
|
559
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
560
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
454
|
+
return response.data
|
561
455
|
|
562
456
|
async def adhoc_execute_prompt_stream(
|
563
457
|
self,
|
@@ -658,9 +552,9 @@ class AsyncAdHocClient:
|
|
658
552
|
|
659
553
|
asyncio.run(main())
|
660
554
|
"""
|
661
|
-
async with self._client_wrapper.httpx_client.stream(
|
555
|
+
async with self._raw_client._client_wrapper.httpx_client.stream(
|
662
556
|
"v1/ad-hoc/execute-prompt-stream",
|
663
|
-
base_url=self._client_wrapper.get_environment().predict,
|
557
|
+
base_url=self._raw_client._client_wrapper.get_environment().predict,
|
664
558
|
method="POST",
|
665
559
|
json={
|
666
560
|
"ml_model": ml_model,
|
@@ -0,0 +1,278 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import typing
|
4
|
+
from ...core.client_wrapper import SyncClientWrapper
|
5
|
+
from ...types.prompt_request_input import PromptRequestInput
|
6
|
+
from ...types.vellum_variable import VellumVariable
|
7
|
+
from ...types.prompt_parameters import PromptParameters
|
8
|
+
from ...types.prompt_block import PromptBlock
|
9
|
+
from ...types.prompt_settings import PromptSettings
|
10
|
+
from ...types.function_definition import FunctionDefinition
|
11
|
+
from ...types.ad_hoc_expand_meta import AdHocExpandMeta
|
12
|
+
from ...core.request_options import RequestOptions
|
13
|
+
from ...core.http_response import HttpResponse
|
14
|
+
from ...types.ad_hoc_execute_prompt_event import AdHocExecutePromptEvent
|
15
|
+
from ...core.serialization import convert_and_respect_annotation_metadata
|
16
|
+
from ...core.pydantic_utilities import parse_obj_as
|
17
|
+
from ...errors.bad_request_error import BadRequestError
|
18
|
+
from ...errors.forbidden_error import ForbiddenError
|
19
|
+
from ...errors.internal_server_error import InternalServerError
|
20
|
+
from json.decoder import JSONDecodeError
|
21
|
+
from ...core.api_error import ApiError
|
22
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
23
|
+
from ...core.http_response import AsyncHttpResponse
|
24
|
+
|
25
|
+
# this is used as the default value for optional parameters
|
26
|
+
OMIT = typing.cast(typing.Any, ...)
|
27
|
+
|
28
|
+
|
29
|
+
class RawAdHocClient:
|
30
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
31
|
+
self._client_wrapper = client_wrapper
|
32
|
+
|
33
|
+
def adhoc_execute_prompt(
|
34
|
+
self,
|
35
|
+
*,
|
36
|
+
ml_model: str,
|
37
|
+
input_values: typing.Sequence[PromptRequestInput],
|
38
|
+
input_variables: typing.Sequence[VellumVariable],
|
39
|
+
parameters: PromptParameters,
|
40
|
+
blocks: typing.Sequence[PromptBlock],
|
41
|
+
settings: typing.Optional[PromptSettings] = OMIT,
|
42
|
+
functions: typing.Optional[typing.Sequence[FunctionDefinition]] = OMIT,
|
43
|
+
expand_meta: typing.Optional[AdHocExpandMeta] = OMIT,
|
44
|
+
request_options: typing.Optional[RequestOptions] = None,
|
45
|
+
) -> HttpResponse[AdHocExecutePromptEvent]:
|
46
|
+
"""
|
47
|
+
Parameters
|
48
|
+
----------
|
49
|
+
ml_model : str
|
50
|
+
|
51
|
+
input_values : typing.Sequence[PromptRequestInput]
|
52
|
+
|
53
|
+
input_variables : typing.Sequence[VellumVariable]
|
54
|
+
|
55
|
+
parameters : PromptParameters
|
56
|
+
|
57
|
+
blocks : typing.Sequence[PromptBlock]
|
58
|
+
|
59
|
+
settings : typing.Optional[PromptSettings]
|
60
|
+
|
61
|
+
functions : typing.Optional[typing.Sequence[FunctionDefinition]]
|
62
|
+
|
63
|
+
expand_meta : typing.Optional[AdHocExpandMeta]
|
64
|
+
|
65
|
+
request_options : typing.Optional[RequestOptions]
|
66
|
+
Request-specific configuration.
|
67
|
+
|
68
|
+
Returns
|
69
|
+
-------
|
70
|
+
HttpResponse[AdHocExecutePromptEvent]
|
71
|
+
|
72
|
+
"""
|
73
|
+
_response = self._client_wrapper.httpx_client.request(
|
74
|
+
"v1/ad-hoc/execute-prompt",
|
75
|
+
base_url=self._client_wrapper.get_environment().default,
|
76
|
+
method="POST",
|
77
|
+
json={
|
78
|
+
"ml_model": ml_model,
|
79
|
+
"input_values": convert_and_respect_annotation_metadata(
|
80
|
+
object_=input_values, annotation=typing.Sequence[PromptRequestInput], direction="write"
|
81
|
+
),
|
82
|
+
"input_variables": convert_and_respect_annotation_metadata(
|
83
|
+
object_=input_variables, annotation=typing.Sequence[VellumVariable], direction="write"
|
84
|
+
),
|
85
|
+
"parameters": convert_and_respect_annotation_metadata(
|
86
|
+
object_=parameters, annotation=PromptParameters, direction="write"
|
87
|
+
),
|
88
|
+
"settings": convert_and_respect_annotation_metadata(
|
89
|
+
object_=settings, annotation=typing.Optional[PromptSettings], direction="write"
|
90
|
+
),
|
91
|
+
"blocks": convert_and_respect_annotation_metadata(
|
92
|
+
object_=blocks, annotation=typing.Sequence[PromptBlock], direction="write"
|
93
|
+
),
|
94
|
+
"functions": convert_and_respect_annotation_metadata(
|
95
|
+
object_=functions,
|
96
|
+
annotation=typing.Optional[typing.Sequence[FunctionDefinition]],
|
97
|
+
direction="write",
|
98
|
+
),
|
99
|
+
"expand_meta": convert_and_respect_annotation_metadata(
|
100
|
+
object_=expand_meta, annotation=typing.Optional[AdHocExpandMeta], direction="write"
|
101
|
+
),
|
102
|
+
},
|
103
|
+
headers={
|
104
|
+
"content-type": "application/json",
|
105
|
+
},
|
106
|
+
request_options=request_options,
|
107
|
+
omit=OMIT,
|
108
|
+
)
|
109
|
+
try:
|
110
|
+
if 200 <= _response.status_code < 300:
|
111
|
+
_data = typing.cast(
|
112
|
+
AdHocExecutePromptEvent,
|
113
|
+
parse_obj_as(
|
114
|
+
type_=AdHocExecutePromptEvent, # type: ignore
|
115
|
+
object_=_response.json(),
|
116
|
+
),
|
117
|
+
)
|
118
|
+
return HttpResponse(response=_response, data=_data)
|
119
|
+
if _response.status_code == 400:
|
120
|
+
raise BadRequestError(
|
121
|
+
typing.cast(
|
122
|
+
typing.Optional[typing.Any],
|
123
|
+
parse_obj_as(
|
124
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
125
|
+
object_=_response.json(),
|
126
|
+
),
|
127
|
+
)
|
128
|
+
)
|
129
|
+
if _response.status_code == 403:
|
130
|
+
raise ForbiddenError(
|
131
|
+
typing.cast(
|
132
|
+
typing.Optional[typing.Any],
|
133
|
+
parse_obj_as(
|
134
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
135
|
+
object_=_response.json(),
|
136
|
+
),
|
137
|
+
)
|
138
|
+
)
|
139
|
+
if _response.status_code == 500:
|
140
|
+
raise InternalServerError(
|
141
|
+
typing.cast(
|
142
|
+
typing.Optional[typing.Any],
|
143
|
+
parse_obj_as(
|
144
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
145
|
+
object_=_response.json(),
|
146
|
+
),
|
147
|
+
)
|
148
|
+
)
|
149
|
+
_response_json = _response.json()
|
150
|
+
except JSONDecodeError:
|
151
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
152
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
153
|
+
|
154
|
+
|
155
|
+
class AsyncRawAdHocClient:
|
156
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
157
|
+
self._client_wrapper = client_wrapper
|
158
|
+
|
159
|
+
async def adhoc_execute_prompt(
|
160
|
+
self,
|
161
|
+
*,
|
162
|
+
ml_model: str,
|
163
|
+
input_values: typing.Sequence[PromptRequestInput],
|
164
|
+
input_variables: typing.Sequence[VellumVariable],
|
165
|
+
parameters: PromptParameters,
|
166
|
+
blocks: typing.Sequence[PromptBlock],
|
167
|
+
settings: typing.Optional[PromptSettings] = OMIT,
|
168
|
+
functions: typing.Optional[typing.Sequence[FunctionDefinition]] = OMIT,
|
169
|
+
expand_meta: typing.Optional[AdHocExpandMeta] = OMIT,
|
170
|
+
request_options: typing.Optional[RequestOptions] = None,
|
171
|
+
) -> AsyncHttpResponse[AdHocExecutePromptEvent]:
|
172
|
+
"""
|
173
|
+
Parameters
|
174
|
+
----------
|
175
|
+
ml_model : str
|
176
|
+
|
177
|
+
input_values : typing.Sequence[PromptRequestInput]
|
178
|
+
|
179
|
+
input_variables : typing.Sequence[VellumVariable]
|
180
|
+
|
181
|
+
parameters : PromptParameters
|
182
|
+
|
183
|
+
blocks : typing.Sequence[PromptBlock]
|
184
|
+
|
185
|
+
settings : typing.Optional[PromptSettings]
|
186
|
+
|
187
|
+
functions : typing.Optional[typing.Sequence[FunctionDefinition]]
|
188
|
+
|
189
|
+
expand_meta : typing.Optional[AdHocExpandMeta]
|
190
|
+
|
191
|
+
request_options : typing.Optional[RequestOptions]
|
192
|
+
Request-specific configuration.
|
193
|
+
|
194
|
+
Returns
|
195
|
+
-------
|
196
|
+
AsyncHttpResponse[AdHocExecutePromptEvent]
|
197
|
+
|
198
|
+
"""
|
199
|
+
_response = await self._client_wrapper.httpx_client.request(
|
200
|
+
"v1/ad-hoc/execute-prompt",
|
201
|
+
base_url=self._client_wrapper.get_environment().default,
|
202
|
+
method="POST",
|
203
|
+
json={
|
204
|
+
"ml_model": ml_model,
|
205
|
+
"input_values": convert_and_respect_annotation_metadata(
|
206
|
+
object_=input_values, annotation=typing.Sequence[PromptRequestInput], direction="write"
|
207
|
+
),
|
208
|
+
"input_variables": convert_and_respect_annotation_metadata(
|
209
|
+
object_=input_variables, annotation=typing.Sequence[VellumVariable], direction="write"
|
210
|
+
),
|
211
|
+
"parameters": convert_and_respect_annotation_metadata(
|
212
|
+
object_=parameters, annotation=PromptParameters, direction="write"
|
213
|
+
),
|
214
|
+
"settings": convert_and_respect_annotation_metadata(
|
215
|
+
object_=settings, annotation=typing.Optional[PromptSettings], direction="write"
|
216
|
+
),
|
217
|
+
"blocks": convert_and_respect_annotation_metadata(
|
218
|
+
object_=blocks, annotation=typing.Sequence[PromptBlock], direction="write"
|
219
|
+
),
|
220
|
+
"functions": convert_and_respect_annotation_metadata(
|
221
|
+
object_=functions,
|
222
|
+
annotation=typing.Optional[typing.Sequence[FunctionDefinition]],
|
223
|
+
direction="write",
|
224
|
+
),
|
225
|
+
"expand_meta": convert_and_respect_annotation_metadata(
|
226
|
+
object_=expand_meta, annotation=typing.Optional[AdHocExpandMeta], direction="write"
|
227
|
+
),
|
228
|
+
},
|
229
|
+
headers={
|
230
|
+
"content-type": "application/json",
|
231
|
+
},
|
232
|
+
request_options=request_options,
|
233
|
+
omit=OMIT,
|
234
|
+
)
|
235
|
+
try:
|
236
|
+
if 200 <= _response.status_code < 300:
|
237
|
+
_data = typing.cast(
|
238
|
+
AdHocExecutePromptEvent,
|
239
|
+
parse_obj_as(
|
240
|
+
type_=AdHocExecutePromptEvent, # type: ignore
|
241
|
+
object_=_response.json(),
|
242
|
+
),
|
243
|
+
)
|
244
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
245
|
+
if _response.status_code == 400:
|
246
|
+
raise BadRequestError(
|
247
|
+
typing.cast(
|
248
|
+
typing.Optional[typing.Any],
|
249
|
+
parse_obj_as(
|
250
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
251
|
+
object_=_response.json(),
|
252
|
+
),
|
253
|
+
)
|
254
|
+
)
|
255
|
+
if _response.status_code == 403:
|
256
|
+
raise ForbiddenError(
|
257
|
+
typing.cast(
|
258
|
+
typing.Optional[typing.Any],
|
259
|
+
parse_obj_as(
|
260
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
261
|
+
object_=_response.json(),
|
262
|
+
),
|
263
|
+
)
|
264
|
+
)
|
265
|
+
if _response.status_code == 500:
|
266
|
+
raise InternalServerError(
|
267
|
+
typing.cast(
|
268
|
+
typing.Optional[typing.Any],
|
269
|
+
parse_obj_as(
|
270
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
271
|
+
object_=_response.json(),
|
272
|
+
),
|
273
|
+
)
|
274
|
+
)
|
275
|
+
_response_json = _response.json()
|
276
|
+
except JSONDecodeError:
|
277
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
278
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|