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.
Files changed (125) hide show
  1. vellum/__init__.py +2 -2
  2. vellum/client/README.md +0 -55
  3. vellum/client/__init__.py +159 -877
  4. vellum/client/core/__init__.py +3 -0
  5. vellum/client/core/client_wrapper.py +2 -2
  6. vellum/client/core/http_response.py +47 -0
  7. vellum/client/raw_client.py +1561 -0
  8. vellum/client/reference.md +22 -696
  9. vellum/client/resources/__init__.py +0 -2
  10. vellum/client/resources/ad_hoc/client.py +55 -161
  11. vellum/client/resources/ad_hoc/raw_client.py +278 -0
  12. vellum/client/resources/container_images/client.py +62 -172
  13. vellum/client/resources/container_images/raw_client.py +400 -0
  14. vellum/client/resources/deployments/client.py +112 -437
  15. vellum/client/resources/deployments/raw_client.py +995 -0
  16. vellum/client/resources/document_indexes/client.py +108 -317
  17. vellum/client/resources/document_indexes/raw_client.py +847 -0
  18. vellum/client/resources/documents/client.py +88 -285
  19. vellum/client/resources/documents/raw_client.py +655 -0
  20. vellum/client/resources/folder_entities/client.py +54 -92
  21. vellum/client/resources/folder_entities/raw_client.py +277 -0
  22. vellum/client/resources/metric_definitions/client.py +48 -95
  23. vellum/client/resources/metric_definitions/raw_client.py +225 -0
  24. vellum/client/resources/ml_models/client.py +36 -40
  25. vellum/client/resources/ml_models/raw_client.py +103 -0
  26. vellum/client/resources/organizations/client.py +34 -39
  27. vellum/client/resources/organizations/raw_client.py +96 -0
  28. vellum/client/resources/prompts/client.py +50 -193
  29. vellum/client/resources/prompts/raw_client.py +346 -0
  30. vellum/client/resources/sandboxes/client.py +68 -141
  31. vellum/client/resources/sandboxes/raw_client.py +393 -0
  32. vellum/client/resources/test_suite_runs/client.py +58 -141
  33. vellum/client/resources/test_suite_runs/raw_client.py +355 -0
  34. vellum/client/resources/test_suites/client.py +73 -141
  35. vellum/client/resources/test_suites/raw_client.py +379 -0
  36. vellum/client/resources/workflow_deployments/client.py +203 -328
  37. vellum/client/resources/workflow_deployments/raw_client.py +931 -0
  38. vellum/client/resources/workflow_executions/client.py +36 -40
  39. vellum/client/resources/workflow_executions/raw_client.py +97 -0
  40. vellum/client/resources/workflow_sandboxes/client.py +60 -108
  41. vellum/client/resources/workflow_sandboxes/raw_client.py +300 -0
  42. vellum/client/resources/workflows/client.py +68 -133
  43. vellum/client/resources/workflows/raw_client.py +307 -0
  44. vellum/client/resources/workspace_secrets/client.py +46 -90
  45. vellum/client/resources/workspace_secrets/raw_client.py +220 -0
  46. vellum/client/resources/workspaces/client.py +34 -39
  47. vellum/client/resources/workspaces/raw_client.py +96 -0
  48. vellum/client/types/__init__.py +2 -0
  49. vellum/client/types/api_request_parent_context.py +1 -0
  50. vellum/client/types/external_parent_context.py +36 -0
  51. vellum/client/types/node_execution_fulfilled_event.py +1 -0
  52. vellum/client/types/node_execution_initiated_event.py +1 -0
  53. vellum/client/types/node_execution_paused_event.py +1 -0
  54. vellum/client/types/node_execution_rejected_event.py +1 -0
  55. vellum/client/types/node_execution_resumed_event.py +1 -0
  56. vellum/client/types/node_execution_span.py +1 -0
  57. vellum/client/types/node_execution_span_attributes.py +1 -0
  58. vellum/client/types/node_execution_streaming_event.py +1 -0
  59. vellum/client/types/node_parent_context.py +1 -0
  60. vellum/client/types/parent_context.py +2 -0
  61. vellum/client/types/prompt_deployment_parent_context.py +1 -0
  62. vellum/client/types/slim_workflow_execution_read.py +1 -0
  63. vellum/client/types/span_link.py +1 -0
  64. vellum/client/types/workflow_deployment_event_executions_response.py +1 -0
  65. vellum/client/types/workflow_deployment_parent_context.py +1 -0
  66. vellum/client/types/workflow_event_execution_read.py +1 -0
  67. vellum/client/types/workflow_execution_detail.py +1 -0
  68. vellum/client/types/workflow_execution_fulfilled_event.py +1 -0
  69. vellum/client/types/workflow_execution_initiated_event.py +1 -0
  70. vellum/client/types/workflow_execution_paused_event.py +1 -0
  71. vellum/client/types/workflow_execution_rejected_event.py +1 -0
  72. vellum/client/types/workflow_execution_resumed_event.py +1 -0
  73. vellum/client/types/workflow_execution_snapshotted_event.py +1 -0
  74. vellum/client/types/workflow_execution_span.py +1 -0
  75. vellum/client/types/workflow_execution_span_attributes.py +1 -0
  76. vellum/client/types/workflow_execution_streaming_event.py +1 -0
  77. vellum/client/types/workflow_parent_context.py +1 -0
  78. vellum/client/types/workflow_sandbox_parent_context.py +1 -0
  79. vellum/{resources/release_reviews/__init__.py → core/http_response.py} +1 -1
  80. vellum/{resources/release_reviews/client.py → raw_client.py} +1 -1
  81. vellum/resources/ad_hoc/raw_client.py +3 -0
  82. vellum/resources/container_images/raw_client.py +3 -0
  83. vellum/resources/deployments/raw_client.py +3 -0
  84. vellum/resources/document_indexes/raw_client.py +3 -0
  85. vellum/resources/documents/raw_client.py +3 -0
  86. vellum/resources/folder_entities/raw_client.py +3 -0
  87. vellum/resources/metric_definitions/raw_client.py +3 -0
  88. vellum/resources/ml_models/raw_client.py +3 -0
  89. vellum/resources/organizations/raw_client.py +3 -0
  90. vellum/resources/prompts/raw_client.py +3 -0
  91. vellum/resources/sandboxes/raw_client.py +3 -0
  92. vellum/resources/test_suite_runs/raw_client.py +3 -0
  93. vellum/resources/test_suites/raw_client.py +3 -0
  94. vellum/resources/workflow_deployments/raw_client.py +3 -0
  95. vellum/resources/workflow_executions/raw_client.py +3 -0
  96. vellum/resources/workflow_sandboxes/raw_client.py +3 -0
  97. vellum/resources/workflows/raw_client.py +3 -0
  98. vellum/resources/workspace_secrets/raw_client.py +3 -0
  99. vellum/resources/workspaces/raw_client.py +3 -0
  100. vellum/types/external_parent_context.py +3 -0
  101. vellum/workflows/emitters/vellum_emitter.py +3 -2
  102. vellum/workflows/events/types.py +6 -0
  103. vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py +5 -15
  104. vellum/workflows/nodes/displayable/tool_calling_node/node.py +6 -0
  105. vellum/workflows/nodes/displayable/tool_calling_node/utils.py +75 -0
  106. vellum/workflows/state/context.py +13 -2
  107. vellum/workflows/types/definition.py +2 -2
  108. vellum/workflows/types/tests/test_definition.py +2 -3
  109. vellum/workflows/utils/functions.py +1 -1
  110. vellum/workflows/utils/tests/test_functions.py +3 -3
  111. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/METADATA +1 -1
  112. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/RECORD +123 -81
  113. vellum_ee/workflows/display/exceptions.py +7 -0
  114. vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +2 -1
  115. vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +53 -2
  116. vellum_ee/workflows/display/nodes/vellum/tests/test_tool_calling_node.py +93 -0
  117. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_mcp_serialization.py +98 -0
  118. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_workflow_deployment_serialization.py +1 -1
  119. vellum_ee/workflows/display/utils/expressions.py +1 -1
  120. vellum_ee/workflows/display/workflows/base_workflow_display.py +2 -1
  121. vellum/client/resources/release_reviews/__init__.py +0 -2
  122. vellum/client/resources/release_reviews/client.py +0 -139
  123. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/LICENSE +0 -0
  124. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/WHEEL +0 -0
  125. {vellum_ai-1.0.11.dist-info → vellum_ai-1.1.1.dist-info}/entry_points.txt +0 -0
@@ -2,17 +2,12 @@
2
2
 
3
3
  import typing
4
4
  from ...core.client_wrapper import SyncClientWrapper
5
+ from .raw_client import RawPromptsClient
5
6
  from ...core.request_options import RequestOptions
6
7
  from ...types.prompt_exec_config import PromptExecConfig
7
- from ...core.jsonable_encoder import jsonable_encoder
8
- from ...core.pydantic_utilities import parse_obj_as
9
- from ...errors.bad_request_error import BadRequestError
10
- from ...errors.not_found_error import NotFoundError
11
- from json.decoder import JSONDecodeError
12
- from ...core.api_error import ApiError
13
8
  from ...types.prompt_push_response import PromptPushResponse
14
- from ...core.serialization import convert_and_respect_annotation_metadata
15
9
  from ...core.client_wrapper import AsyncClientWrapper
10
+ from .raw_client import AsyncRawPromptsClient
16
11
 
17
12
  # this is used as the default value for optional parameters
18
13
  OMIT = typing.cast(typing.Any, ...)
@@ -20,7 +15,22 @@ OMIT = typing.cast(typing.Any, ...)
20
15
 
21
16
  class PromptsClient:
22
17
  def __init__(self, *, client_wrapper: SyncClientWrapper):
23
- self._client_wrapper = client_wrapper
18
+ self._raw_client = RawPromptsClient(client_wrapper=client_wrapper)
19
+
20
+ @property
21
+ def _client_wrapper(self) -> SyncClientWrapper:
22
+ return self._raw_client._client_wrapper
23
+
24
+ @property
25
+ def with_raw_response(self) -> RawPromptsClient:
26
+ """
27
+ Retrieves a raw implementation of this client that returns raw responses.
28
+
29
+ Returns
30
+ -------
31
+ RawPromptsClient
32
+ """
33
+ return self._raw_client
24
34
 
25
35
  def pull(
26
36
  self,
@@ -60,51 +70,12 @@ class PromptsClient:
60
70
  id="id",
61
71
  )
62
72
  """
63
- _response = self._client_wrapper.httpx_client.request(
64
- f"v1/prompts/{jsonable_encoder(id)}/pull",
65
- base_url=self._client_wrapper.get_environment().default,
66
- method="GET",
67
- params={
68
- "prompt_variant_id": prompt_variant_id,
69
- },
70
- headers={
71
- "Accept": "application/json",
72
- },
73
+ response = self._raw_client.pull(
74
+ id,
75
+ prompt_variant_id=prompt_variant_id,
73
76
  request_options=request_options,
74
77
  )
75
- try:
76
- if 200 <= _response.status_code < 300:
77
- return typing.cast(
78
- PromptExecConfig,
79
- parse_obj_as(
80
- type_=PromptExecConfig, # type: ignore
81
- object_=_response.json(),
82
- ),
83
- )
84
- if _response.status_code == 400:
85
- raise BadRequestError(
86
- typing.cast(
87
- typing.Optional[typing.Any],
88
- parse_obj_as(
89
- type_=typing.Optional[typing.Any], # type: ignore
90
- object_=_response.json(),
91
- ),
92
- )
93
- )
94
- if _response.status_code == 404:
95
- raise NotFoundError(
96
- typing.cast(
97
- typing.Optional[typing.Any],
98
- parse_obj_as(
99
- type_=typing.Optional[typing.Any], # type: ignore
100
- object_=_response.json(),
101
- ),
102
- )
103
- )
104
- _response_json = _response.json()
105
- except JSONDecodeError:
106
- raise ApiError(status_code=_response.status_code, body=_response.text)
107
- raise ApiError(status_code=_response.status_code, body=_response_json)
78
+ return response.data
108
79
 
109
80
  def push(
110
81
  self,
@@ -179,62 +150,30 @@ class PromptsClient:
179
150
  ),
180
151
  )
181
152
  """
182
- _response = self._client_wrapper.httpx_client.request(
183
- "v1/prompts/push",
184
- base_url=self._client_wrapper.get_environment().default,
185
- method="POST",
186
- json={
187
- "prompt_variant_id": prompt_variant_id,
188
- "prompt_variant_label": prompt_variant_label,
189
- "prompt_sandbox_id": prompt_sandbox_id,
190
- "exec_config": convert_and_respect_annotation_metadata(
191
- object_=exec_config, annotation=PromptExecConfig, direction="write"
192
- ),
193
- },
194
- headers={
195
- "content-type": "application/json",
196
- },
153
+ response = self._raw_client.push(
154
+ exec_config=exec_config,
155
+ prompt_variant_id=prompt_variant_id,
156
+ prompt_variant_label=prompt_variant_label,
157
+ prompt_sandbox_id=prompt_sandbox_id,
197
158
  request_options=request_options,
198
- omit=OMIT,
199
159
  )
200
- try:
201
- if 200 <= _response.status_code < 300:
202
- return typing.cast(
203
- PromptPushResponse,
204
- parse_obj_as(
205
- type_=PromptPushResponse, # type: ignore
206
- object_=_response.json(),
207
- ),
208
- )
209
- if _response.status_code == 400:
210
- raise BadRequestError(
211
- typing.cast(
212
- typing.Optional[typing.Any],
213
- parse_obj_as(
214
- type_=typing.Optional[typing.Any], # type: ignore
215
- object_=_response.json(),
216
- ),
217
- )
218
- )
219
- if _response.status_code == 404:
220
- raise NotFoundError(
221
- typing.cast(
222
- typing.Optional[typing.Any],
223
- parse_obj_as(
224
- type_=typing.Optional[typing.Any], # type: ignore
225
- object_=_response.json(),
226
- ),
227
- )
228
- )
229
- _response_json = _response.json()
230
- except JSONDecodeError:
231
- raise ApiError(status_code=_response.status_code, body=_response.text)
232
- raise ApiError(status_code=_response.status_code, body=_response_json)
160
+ return response.data
233
161
 
234
162
 
235
163
  class AsyncPromptsClient:
236
164
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
237
- self._client_wrapper = client_wrapper
165
+ self._raw_client = AsyncRawPromptsClient(client_wrapper=client_wrapper)
166
+
167
+ @property
168
+ def with_raw_response(self) -> AsyncRawPromptsClient:
169
+ """
170
+ Retrieves a raw implementation of this client that returns raw responses.
171
+
172
+ Returns
173
+ -------
174
+ AsyncRawPromptsClient
175
+ """
176
+ return self._raw_client
238
177
 
239
178
  async def pull(
240
179
  self,
@@ -282,51 +221,12 @@ class AsyncPromptsClient:
282
221
 
283
222
  asyncio.run(main())
284
223
  """
285
- _response = await self._client_wrapper.httpx_client.request(
286
- f"v1/prompts/{jsonable_encoder(id)}/pull",
287
- base_url=self._client_wrapper.get_environment().default,
288
- method="GET",
289
- params={
290
- "prompt_variant_id": prompt_variant_id,
291
- },
292
- headers={
293
- "Accept": "application/json",
294
- },
224
+ response = await self._raw_client.pull(
225
+ id,
226
+ prompt_variant_id=prompt_variant_id,
295
227
  request_options=request_options,
296
228
  )
297
- try:
298
- if 200 <= _response.status_code < 300:
299
- return typing.cast(
300
- PromptExecConfig,
301
- parse_obj_as(
302
- type_=PromptExecConfig, # type: ignore
303
- object_=_response.json(),
304
- ),
305
- )
306
- if _response.status_code == 400:
307
- raise BadRequestError(
308
- typing.cast(
309
- typing.Optional[typing.Any],
310
- parse_obj_as(
311
- type_=typing.Optional[typing.Any], # type: ignore
312
- object_=_response.json(),
313
- ),
314
- )
315
- )
316
- if _response.status_code == 404:
317
- raise NotFoundError(
318
- typing.cast(
319
- typing.Optional[typing.Any],
320
- parse_obj_as(
321
- type_=typing.Optional[typing.Any], # type: ignore
322
- object_=_response.json(),
323
- ),
324
- )
325
- )
326
- _response_json = _response.json()
327
- except JSONDecodeError:
328
- raise ApiError(status_code=_response.status_code, body=_response.text)
329
- raise ApiError(status_code=_response.status_code, body=_response_json)
229
+ return response.data
330
230
 
331
231
  async def push(
332
232
  self,
@@ -409,54 +309,11 @@ class AsyncPromptsClient:
409
309
 
410
310
  asyncio.run(main())
411
311
  """
412
- _response = await self._client_wrapper.httpx_client.request(
413
- "v1/prompts/push",
414
- base_url=self._client_wrapper.get_environment().default,
415
- method="POST",
416
- json={
417
- "prompt_variant_id": prompt_variant_id,
418
- "prompt_variant_label": prompt_variant_label,
419
- "prompt_sandbox_id": prompt_sandbox_id,
420
- "exec_config": convert_and_respect_annotation_metadata(
421
- object_=exec_config, annotation=PromptExecConfig, direction="write"
422
- ),
423
- },
424
- headers={
425
- "content-type": "application/json",
426
- },
312
+ response = await self._raw_client.push(
313
+ exec_config=exec_config,
314
+ prompt_variant_id=prompt_variant_id,
315
+ prompt_variant_label=prompt_variant_label,
316
+ prompt_sandbox_id=prompt_sandbox_id,
427
317
  request_options=request_options,
428
- omit=OMIT,
429
318
  )
430
- try:
431
- if 200 <= _response.status_code < 300:
432
- return typing.cast(
433
- PromptPushResponse,
434
- parse_obj_as(
435
- type_=PromptPushResponse, # type: ignore
436
- object_=_response.json(),
437
- ),
438
- )
439
- if _response.status_code == 400:
440
- raise BadRequestError(
441
- typing.cast(
442
- typing.Optional[typing.Any],
443
- parse_obj_as(
444
- type_=typing.Optional[typing.Any], # type: ignore
445
- object_=_response.json(),
446
- ),
447
- )
448
- )
449
- if _response.status_code == 404:
450
- raise NotFoundError(
451
- typing.cast(
452
- typing.Optional[typing.Any],
453
- parse_obj_as(
454
- type_=typing.Optional[typing.Any], # type: ignore
455
- object_=_response.json(),
456
- ),
457
- )
458
- )
459
- _response_json = _response.json()
460
- except JSONDecodeError:
461
- raise ApiError(status_code=_response.status_code, body=_response.text)
462
- raise ApiError(status_code=_response.status_code, body=_response_json)
319
+ return response.data
@@ -0,0 +1,346 @@
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 ...core.request_options import RequestOptions
6
+ from ...core.http_response import HttpResponse
7
+ from ...types.prompt_exec_config import PromptExecConfig
8
+ from ...core.jsonable_encoder import jsonable_encoder
9
+ from ...core.pydantic_utilities import parse_obj_as
10
+ from ...errors.bad_request_error import BadRequestError
11
+ from ...errors.not_found_error import NotFoundError
12
+ from json.decoder import JSONDecodeError
13
+ from ...core.api_error import ApiError
14
+ from ...types.prompt_push_response import PromptPushResponse
15
+ from ...core.serialization import convert_and_respect_annotation_metadata
16
+ from ...core.client_wrapper import AsyncClientWrapper
17
+ from ...core.http_response import AsyncHttpResponse
18
+
19
+ # this is used as the default value for optional parameters
20
+ OMIT = typing.cast(typing.Any, ...)
21
+
22
+
23
+ class RawPromptsClient:
24
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
25
+ self._client_wrapper = client_wrapper
26
+
27
+ def pull(
28
+ self,
29
+ id: str,
30
+ *,
31
+ prompt_variant_id: typing.Optional[str] = None,
32
+ request_options: typing.Optional[RequestOptions] = None,
33
+ ) -> HttpResponse[PromptExecConfig]:
34
+ """
35
+ Used to pull the definition of a Prompt from Vellum.
36
+
37
+ Parameters
38
+ ----------
39
+ id : str
40
+ The ID of the Prompt to pull from. Prompt Sandbox IDs are currently supported.
41
+
42
+ prompt_variant_id : typing.Optional[str]
43
+ The ID of the Prompt Variant within a Prompt Sandbox to pull. Must be included if providing the ID of a Prompt Sandbox.
44
+
45
+ request_options : typing.Optional[RequestOptions]
46
+ Request-specific configuration.
47
+
48
+ Returns
49
+ -------
50
+ HttpResponse[PromptExecConfig]
51
+
52
+ """
53
+ _response = self._client_wrapper.httpx_client.request(
54
+ f"v1/prompts/{jsonable_encoder(id)}/pull",
55
+ base_url=self._client_wrapper.get_environment().default,
56
+ method="GET",
57
+ params={
58
+ "prompt_variant_id": prompt_variant_id,
59
+ },
60
+ headers={
61
+ "Accept": "application/json",
62
+ },
63
+ request_options=request_options,
64
+ )
65
+ try:
66
+ if 200 <= _response.status_code < 300:
67
+ _data = typing.cast(
68
+ PromptExecConfig,
69
+ parse_obj_as(
70
+ type_=PromptExecConfig, # type: ignore
71
+ object_=_response.json(),
72
+ ),
73
+ )
74
+ return HttpResponse(response=_response, data=_data)
75
+ if _response.status_code == 400:
76
+ raise BadRequestError(
77
+ typing.cast(
78
+ typing.Optional[typing.Any],
79
+ parse_obj_as(
80
+ type_=typing.Optional[typing.Any], # type: ignore
81
+ object_=_response.json(),
82
+ ),
83
+ )
84
+ )
85
+ if _response.status_code == 404:
86
+ raise NotFoundError(
87
+ typing.cast(
88
+ typing.Optional[typing.Any],
89
+ parse_obj_as(
90
+ type_=typing.Optional[typing.Any], # type: ignore
91
+ object_=_response.json(),
92
+ ),
93
+ )
94
+ )
95
+ _response_json = _response.json()
96
+ except JSONDecodeError:
97
+ raise ApiError(status_code=_response.status_code, body=_response.text)
98
+ raise ApiError(status_code=_response.status_code, body=_response_json)
99
+
100
+ def push(
101
+ self,
102
+ *,
103
+ exec_config: PromptExecConfig,
104
+ prompt_variant_id: typing.Optional[str] = OMIT,
105
+ prompt_variant_label: typing.Optional[str] = OMIT,
106
+ prompt_sandbox_id: typing.Optional[str] = OMIT,
107
+ request_options: typing.Optional[RequestOptions] = None,
108
+ ) -> HttpResponse[PromptPushResponse]:
109
+ """
110
+ Used to push updates to a Prompt in Vellum.
111
+
112
+ Parameters
113
+ ----------
114
+ exec_config : PromptExecConfig
115
+
116
+ prompt_variant_id : typing.Optional[str]
117
+ If specified, an existing Prompt Variant by the provided ID will be updated. Otherwise, a new Prompt Variant will be created and an ID generated.
118
+
119
+ prompt_variant_label : typing.Optional[str]
120
+ If provided, then the created/updated Prompt Variant will have this label.
121
+
122
+ prompt_sandbox_id : typing.Optional[str]
123
+
124
+ request_options : typing.Optional[RequestOptions]
125
+ Request-specific configuration.
126
+
127
+ Returns
128
+ -------
129
+ HttpResponse[PromptPushResponse]
130
+
131
+ """
132
+ _response = self._client_wrapper.httpx_client.request(
133
+ "v1/prompts/push",
134
+ base_url=self._client_wrapper.get_environment().default,
135
+ method="POST",
136
+ json={
137
+ "prompt_variant_id": prompt_variant_id,
138
+ "prompt_variant_label": prompt_variant_label,
139
+ "prompt_sandbox_id": prompt_sandbox_id,
140
+ "exec_config": convert_and_respect_annotation_metadata(
141
+ object_=exec_config, annotation=PromptExecConfig, direction="write"
142
+ ),
143
+ },
144
+ headers={
145
+ "content-type": "application/json",
146
+ },
147
+ request_options=request_options,
148
+ omit=OMIT,
149
+ )
150
+ try:
151
+ if 200 <= _response.status_code < 300:
152
+ _data = typing.cast(
153
+ PromptPushResponse,
154
+ parse_obj_as(
155
+ type_=PromptPushResponse, # type: ignore
156
+ object_=_response.json(),
157
+ ),
158
+ )
159
+ return HttpResponse(response=_response, data=_data)
160
+ if _response.status_code == 400:
161
+ raise BadRequestError(
162
+ typing.cast(
163
+ typing.Optional[typing.Any],
164
+ parse_obj_as(
165
+ type_=typing.Optional[typing.Any], # type: ignore
166
+ object_=_response.json(),
167
+ ),
168
+ )
169
+ )
170
+ if _response.status_code == 404:
171
+ raise NotFoundError(
172
+ typing.cast(
173
+ typing.Optional[typing.Any],
174
+ parse_obj_as(
175
+ type_=typing.Optional[typing.Any], # type: ignore
176
+ object_=_response.json(),
177
+ ),
178
+ )
179
+ )
180
+ _response_json = _response.json()
181
+ except JSONDecodeError:
182
+ raise ApiError(status_code=_response.status_code, body=_response.text)
183
+ raise ApiError(status_code=_response.status_code, body=_response_json)
184
+
185
+
186
+ class AsyncRawPromptsClient:
187
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
188
+ self._client_wrapper = client_wrapper
189
+
190
+ async def pull(
191
+ self,
192
+ id: str,
193
+ *,
194
+ prompt_variant_id: typing.Optional[str] = None,
195
+ request_options: typing.Optional[RequestOptions] = None,
196
+ ) -> AsyncHttpResponse[PromptExecConfig]:
197
+ """
198
+ Used to pull the definition of a Prompt from Vellum.
199
+
200
+ Parameters
201
+ ----------
202
+ id : str
203
+ The ID of the Prompt to pull from. Prompt Sandbox IDs are currently supported.
204
+
205
+ prompt_variant_id : typing.Optional[str]
206
+ The ID of the Prompt Variant within a Prompt Sandbox to pull. Must be included if providing the ID of a Prompt Sandbox.
207
+
208
+ request_options : typing.Optional[RequestOptions]
209
+ Request-specific configuration.
210
+
211
+ Returns
212
+ -------
213
+ AsyncHttpResponse[PromptExecConfig]
214
+
215
+ """
216
+ _response = await self._client_wrapper.httpx_client.request(
217
+ f"v1/prompts/{jsonable_encoder(id)}/pull",
218
+ base_url=self._client_wrapper.get_environment().default,
219
+ method="GET",
220
+ params={
221
+ "prompt_variant_id": prompt_variant_id,
222
+ },
223
+ headers={
224
+ "Accept": "application/json",
225
+ },
226
+ request_options=request_options,
227
+ )
228
+ try:
229
+ if 200 <= _response.status_code < 300:
230
+ _data = typing.cast(
231
+ PromptExecConfig,
232
+ parse_obj_as(
233
+ type_=PromptExecConfig, # type: ignore
234
+ object_=_response.json(),
235
+ ),
236
+ )
237
+ return AsyncHttpResponse(response=_response, data=_data)
238
+ if _response.status_code == 400:
239
+ raise BadRequestError(
240
+ typing.cast(
241
+ typing.Optional[typing.Any],
242
+ parse_obj_as(
243
+ type_=typing.Optional[typing.Any], # type: ignore
244
+ object_=_response.json(),
245
+ ),
246
+ )
247
+ )
248
+ if _response.status_code == 404:
249
+ raise NotFoundError(
250
+ typing.cast(
251
+ typing.Optional[typing.Any],
252
+ parse_obj_as(
253
+ type_=typing.Optional[typing.Any], # type: ignore
254
+ object_=_response.json(),
255
+ ),
256
+ )
257
+ )
258
+ _response_json = _response.json()
259
+ except JSONDecodeError:
260
+ raise ApiError(status_code=_response.status_code, body=_response.text)
261
+ raise ApiError(status_code=_response.status_code, body=_response_json)
262
+
263
+ async def push(
264
+ self,
265
+ *,
266
+ exec_config: PromptExecConfig,
267
+ prompt_variant_id: typing.Optional[str] = OMIT,
268
+ prompt_variant_label: typing.Optional[str] = OMIT,
269
+ prompt_sandbox_id: typing.Optional[str] = OMIT,
270
+ request_options: typing.Optional[RequestOptions] = None,
271
+ ) -> AsyncHttpResponse[PromptPushResponse]:
272
+ """
273
+ Used to push updates to a Prompt in Vellum.
274
+
275
+ Parameters
276
+ ----------
277
+ exec_config : PromptExecConfig
278
+
279
+ prompt_variant_id : typing.Optional[str]
280
+ If specified, an existing Prompt Variant by the provided ID will be updated. Otherwise, a new Prompt Variant will be created and an ID generated.
281
+
282
+ prompt_variant_label : typing.Optional[str]
283
+ If provided, then the created/updated Prompt Variant will have this label.
284
+
285
+ prompt_sandbox_id : typing.Optional[str]
286
+
287
+ request_options : typing.Optional[RequestOptions]
288
+ Request-specific configuration.
289
+
290
+ Returns
291
+ -------
292
+ AsyncHttpResponse[PromptPushResponse]
293
+
294
+ """
295
+ _response = await self._client_wrapper.httpx_client.request(
296
+ "v1/prompts/push",
297
+ base_url=self._client_wrapper.get_environment().default,
298
+ method="POST",
299
+ json={
300
+ "prompt_variant_id": prompt_variant_id,
301
+ "prompt_variant_label": prompt_variant_label,
302
+ "prompt_sandbox_id": prompt_sandbox_id,
303
+ "exec_config": convert_and_respect_annotation_metadata(
304
+ object_=exec_config, annotation=PromptExecConfig, direction="write"
305
+ ),
306
+ },
307
+ headers={
308
+ "content-type": "application/json",
309
+ },
310
+ request_options=request_options,
311
+ omit=OMIT,
312
+ )
313
+ try:
314
+ if 200 <= _response.status_code < 300:
315
+ _data = typing.cast(
316
+ PromptPushResponse,
317
+ parse_obj_as(
318
+ type_=PromptPushResponse, # type: ignore
319
+ object_=_response.json(),
320
+ ),
321
+ )
322
+ return AsyncHttpResponse(response=_response, data=_data)
323
+ if _response.status_code == 400:
324
+ raise BadRequestError(
325
+ typing.cast(
326
+ typing.Optional[typing.Any],
327
+ parse_obj_as(
328
+ type_=typing.Optional[typing.Any], # type: ignore
329
+ object_=_response.json(),
330
+ ),
331
+ )
332
+ )
333
+ if _response.status_code == 404:
334
+ raise NotFoundError(
335
+ typing.cast(
336
+ typing.Optional[typing.Any],
337
+ parse_obj_as(
338
+ type_=typing.Optional[typing.Any], # type: ignore
339
+ object_=_response.json(),
340
+ ),
341
+ )
342
+ )
343
+ _response_json = _response.json()
344
+ except JSONDecodeError:
345
+ raise ApiError(status_code=_response.status_code, body=_response.text)
346
+ raise ApiError(status_code=_response.status_code, body=_response_json)