vellum-ai 0.8.4__py3-none-any.whl → 0.8.6__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. vellum/__init__.py +64 -104
  2. vellum/client.py +17 -17
  3. vellum/core/client_wrapper.py +1 -1
  4. vellum/resources/__init__.py +2 -2
  5. vellum/resources/ad_hoc/client.py +372 -0
  6. vellum/types/__init__.py +62 -102
  7. vellum/types/ad_hoc_execute_prompt_event.py +14 -0
  8. vellum/types/ad_hoc_expand_meta_request.py +33 -0
  9. vellum/types/ad_hoc_fulfilled_prompt_execution_meta.py +27 -0
  10. vellum/types/{open_api_const_property_request.py → ad_hoc_initiated_prompt_execution_meta.py} +4 -6
  11. vellum/types/{open_api_boolean_property_request.py → ad_hoc_rejected_prompt_execution_meta.py} +5 -6
  12. vellum/types/{tik_token_tokenizer_config_request.py → ad_hoc_streaming_prompt_execution_meta.py} +3 -4
  13. vellum/types/{open_api_one_of_property.py → chat_message_prompt_block_properties_request.py} +10 -9
  14. vellum/types/chat_message_prompt_block_request.py +36 -0
  15. vellum/types/{ml_model_developer_enum_value_label.py → ephemeral_prompt_cache_config_request.py} +4 -5
  16. vellum/types/ephemeral_prompt_cache_config_type_enum.py +5 -0
  17. vellum/types/fulfilled_ad_hoc_execute_prompt_event.py +28 -0
  18. vellum/types/function_definition_prompt_block_properties_request.py +42 -0
  19. vellum/types/function_definition_prompt_block_request.py +30 -0
  20. vellum/types/generate_response.py +3 -20
  21. vellum/types/{hugging_face_tokenizer_config.py → initiated_ad_hoc_execute_prompt_event.py} +6 -5
  22. vellum/types/{ml_model_display_tag_enum_value_label.py → jinja_prompt_block_properties_request.py} +5 -5
  23. vellum/types/jinja_prompt_block_request.py +30 -0
  24. vellum/types/ml_model_usage.py +2 -0
  25. vellum/types/plain_text_prompt_block_request.py +29 -0
  26. vellum/types/prompt_block_request.py +19 -0
  27. vellum/types/prompt_block_state.py +5 -0
  28. vellum/types/{prompt_deployment_expand_meta_request_request.py → prompt_deployment_expand_meta_request.py} +1 -1
  29. vellum/types/prompt_parameters_request.py +27 -0
  30. vellum/types/{open_api_boolean_property.py → prompt_request_chat_history_input_request.py} +7 -7
  31. vellum/types/prompt_request_input_request.py +10 -0
  32. vellum/types/{hugging_face_tokenizer_config_request.py → prompt_request_json_input_request.py} +6 -6
  33. vellum/types/{tik_token_tokenizer_config.py → prompt_request_string_input_request.py} +6 -5
  34. vellum/types/rejected_ad_hoc_execute_prompt_event.py +28 -0
  35. vellum/types/rich_text_child_block_request.py +7 -0
  36. vellum/types/rich_text_prompt_block_request.py +30 -0
  37. vellum/types/streaming_ad_hoc_execute_prompt_event.py +33 -0
  38. vellum/types/variable_prompt_block_request.py +29 -0
  39. vellum/types/{ml_model_family_enum_value_label.py → vellum_variable_request.py} +5 -4
  40. {vellum_ai-0.8.4.dist-info → vellum_ai-0.8.6.dist-info}/METADATA +1 -1
  41. {vellum_ai-0.8.4.dist-info → vellum_ai-0.8.6.dist-info}/RECORD +44 -64
  42. vellum/resources/ml_models/client.py +0 -948
  43. vellum/types/hosted_by_enum.py +0 -26
  44. vellum/types/ml_model_developer.py +0 -27
  45. vellum/types/ml_model_display_config_labelled.py +0 -26
  46. vellum/types/ml_model_display_config_request.py +0 -26
  47. vellum/types/ml_model_display_tag.py +0 -7
  48. vellum/types/ml_model_exec_config.py +0 -34
  49. vellum/types/ml_model_exec_config_request.py +0 -34
  50. vellum/types/ml_model_family.py +0 -29
  51. vellum/types/ml_model_feature.py +0 -18
  52. vellum/types/ml_model_parameter_config.py +0 -32
  53. vellum/types/ml_model_parameter_config_request.py +0 -32
  54. vellum/types/ml_model_read.py +0 -92
  55. vellum/types/ml_model_request_authorization_config.py +0 -20
  56. vellum/types/ml_model_request_authorization_config_request.py +0 -20
  57. vellum/types/ml_model_request_authorization_config_type_enum.py +0 -5
  58. vellum/types/ml_model_request_config.py +0 -22
  59. vellum/types/ml_model_request_config_request.py +0 -22
  60. vellum/types/ml_model_response_config.py +0 -21
  61. vellum/types/ml_model_response_config_request.py +0 -21
  62. vellum/types/ml_model_tokenizer_config.py +0 -7
  63. vellum/types/ml_model_tokenizer_config_request.py +0 -7
  64. vellum/types/open_api_array_property.py +0 -41
  65. vellum/types/open_api_array_property_request.py +0 -41
  66. vellum/types/open_api_const_property.py +0 -26
  67. vellum/types/open_api_integer_property.py +0 -30
  68. vellum/types/open_api_integer_property_request.py +0 -30
  69. vellum/types/open_api_number_property.py +0 -31
  70. vellum/types/open_api_number_property_request.py +0 -31
  71. vellum/types/open_api_object_property.py +0 -40
  72. vellum/types/open_api_object_property_request.py +0 -40
  73. vellum/types/open_api_one_of_property_request.py +0 -33
  74. vellum/types/open_api_property.py +0 -27
  75. vellum/types/open_api_property_request.py +0 -27
  76. vellum/types/open_api_ref_property.py +0 -26
  77. vellum/types/open_api_ref_property_request.py +0 -26
  78. vellum/types/open_api_string_property.py +0 -30
  79. vellum/types/open_api_string_property_request.py +0 -30
  80. vellum/types/paginated_ml_model_read_list.py +0 -23
  81. vellum/types/visibility_enum.py +0 -5
  82. /vellum/resources/{ml_models → ad_hoc}/__init__.py +0 -0
  83. {vellum_ai-0.8.4.dist-info → vellum_ai-0.8.6.dist-info}/LICENSE +0 -0
  84. {vellum_ai-0.8.4.dist-info → vellum_ai-0.8.6.dist-info}/WHEEL +0 -0
@@ -0,0 +1,372 @@
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_request import PromptRequestInputRequest
6
+ from ...types.vellum_variable_request import VellumVariableRequest
7
+ from ...types.prompt_parameters_request import PromptParametersRequest
8
+ from ...types.prompt_block_request import PromptBlockRequest
9
+ from ...types.ad_hoc_expand_meta_request import AdHocExpandMetaRequest
10
+ from ...core.request_options import RequestOptions
11
+ from ...types.ad_hoc_execute_prompt_event import AdHocExecutePromptEvent
12
+ from ...core.pydantic_utilities import parse_obj_as
13
+ import json
14
+ from ...errors.bad_request_error import BadRequestError
15
+ from ...errors.forbidden_error import ForbiddenError
16
+ from ...errors.internal_server_error import InternalServerError
17
+ from json.decoder import JSONDecodeError
18
+ from ...core.api_error import ApiError
19
+ from ...core.client_wrapper import AsyncClientWrapper
20
+
21
+ # this is used as the default value for optional parameters
22
+ OMIT = typing.cast(typing.Any, ...)
23
+
24
+
25
+ class AdHocClient:
26
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
27
+ self._client_wrapper = client_wrapper
28
+
29
+ def adhoc_execute_prompt_stream(
30
+ self,
31
+ *,
32
+ ml_model: str,
33
+ input_values: typing.Sequence[PromptRequestInputRequest],
34
+ input_variables: typing.Sequence[VellumVariableRequest],
35
+ parameters: PromptParametersRequest,
36
+ blocks: typing.Sequence[PromptBlockRequest],
37
+ expand_meta: typing.Optional[AdHocExpandMetaRequest] = OMIT,
38
+ request_options: typing.Optional[RequestOptions] = None,
39
+ ) -> typing.Iterator[AdHocExecutePromptEvent]:
40
+ """
41
+ An internal-only endpoint that's subject to breaking changes without notice. Not intended for public use.
42
+
43
+ Parameters
44
+ ----------
45
+ ml_model : str
46
+
47
+ input_values : typing.Sequence[PromptRequestInputRequest]
48
+
49
+ input_variables : typing.Sequence[VellumVariableRequest]
50
+
51
+ parameters : PromptParametersRequest
52
+
53
+ blocks : typing.Sequence[PromptBlockRequest]
54
+
55
+ expand_meta : typing.Optional[AdHocExpandMetaRequest]
56
+
57
+ request_options : typing.Optional[RequestOptions]
58
+ Request-specific configuration.
59
+
60
+ Yields
61
+ ------
62
+ typing.Iterator[AdHocExecutePromptEvent]
63
+
64
+
65
+ Examples
66
+ --------
67
+ from vellum import (
68
+ AdHocExpandMetaRequest,
69
+ EphemeralPromptCacheConfigRequest,
70
+ JinjaPromptBlockPropertiesRequest,
71
+ JinjaPromptBlockRequest,
72
+ PromptParametersRequest,
73
+ PromptRequestStringInputRequest,
74
+ Vellum,
75
+ VellumVariableRequest,
76
+ )
77
+
78
+ client = Vellum(
79
+ api_key="YOUR_API_KEY",
80
+ )
81
+ response = client.ad_hoc.adhoc_execute_prompt_stream(
82
+ ml_model="string",
83
+ input_values=[
84
+ PromptRequestStringInputRequest(
85
+ key="string",
86
+ value="string",
87
+ )
88
+ ],
89
+ input_variables=[
90
+ VellumVariableRequest(
91
+ id="string",
92
+ key="string",
93
+ type="STRING",
94
+ )
95
+ ],
96
+ parameters=PromptParametersRequest(
97
+ stop=["string"],
98
+ temperature=1.1,
99
+ max_tokens=1,
100
+ top_p=1.1,
101
+ top_k=1,
102
+ frequency_penalty=1.1,
103
+ presence_penalty=1.1,
104
+ logit_bias={"string": {"key": "value"}},
105
+ custom_parameters={"string": {"key": "value"}},
106
+ ),
107
+ blocks=[
108
+ JinjaPromptBlockRequest(
109
+ properties=JinjaPromptBlockPropertiesRequest(
110
+ template="string",
111
+ template_type="STRING",
112
+ ),
113
+ id="string",
114
+ state="ENABLED",
115
+ cache_config=EphemeralPromptCacheConfigRequest(),
116
+ )
117
+ ],
118
+ expand_meta=AdHocExpandMetaRequest(
119
+ cost=True,
120
+ model_name=True,
121
+ usage=True,
122
+ finish_reason=True,
123
+ ),
124
+ )
125
+ for chunk in response:
126
+ yield chunk
127
+ """
128
+ with self._client_wrapper.httpx_client.stream(
129
+ "v1/ad-hoc/execute-prompt-stream",
130
+ base_url=self._client_wrapper.get_environment().default,
131
+ method="POST",
132
+ json={
133
+ "ml_model": ml_model,
134
+ "input_values": input_values,
135
+ "input_variables": input_variables,
136
+ "parameters": parameters,
137
+ "blocks": blocks,
138
+ "expand_meta": expand_meta,
139
+ },
140
+ request_options=request_options,
141
+ omit=OMIT,
142
+ ) as _response:
143
+ try:
144
+ if 200 <= _response.status_code < 300:
145
+ for _text in _response.iter_lines():
146
+ try:
147
+ if len(_text) == 0:
148
+ continue
149
+ yield typing.cast(
150
+ AdHocExecutePromptEvent,
151
+ parse_obj_as(
152
+ type_=AdHocExecutePromptEvent, # type: ignore
153
+ object_=json.loads(_text),
154
+ ),
155
+ )
156
+ except:
157
+ pass
158
+ return
159
+ _response.read()
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 == 403:
171
+ raise ForbiddenError(
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
+ if _response.status_code == 500:
181
+ raise InternalServerError(
182
+ typing.cast(
183
+ typing.Optional[typing.Any],
184
+ parse_obj_as(
185
+ type_=typing.Optional[typing.Any], # type: ignore
186
+ object_=_response.json(),
187
+ ),
188
+ )
189
+ )
190
+ _response_json = _response.json()
191
+ except JSONDecodeError:
192
+ raise ApiError(status_code=_response.status_code, body=_response.text)
193
+ raise ApiError(status_code=_response.status_code, body=_response_json)
194
+
195
+
196
+ class AsyncAdHocClient:
197
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
198
+ self._client_wrapper = client_wrapper
199
+
200
+ async def adhoc_execute_prompt_stream(
201
+ self,
202
+ *,
203
+ ml_model: str,
204
+ input_values: typing.Sequence[PromptRequestInputRequest],
205
+ input_variables: typing.Sequence[VellumVariableRequest],
206
+ parameters: PromptParametersRequest,
207
+ blocks: typing.Sequence[PromptBlockRequest],
208
+ expand_meta: typing.Optional[AdHocExpandMetaRequest] = OMIT,
209
+ request_options: typing.Optional[RequestOptions] = None,
210
+ ) -> typing.AsyncIterator[AdHocExecutePromptEvent]:
211
+ """
212
+ An internal-only endpoint that's subject to breaking changes without notice. Not intended for public use.
213
+
214
+ Parameters
215
+ ----------
216
+ ml_model : str
217
+
218
+ input_values : typing.Sequence[PromptRequestInputRequest]
219
+
220
+ input_variables : typing.Sequence[VellumVariableRequest]
221
+
222
+ parameters : PromptParametersRequest
223
+
224
+ blocks : typing.Sequence[PromptBlockRequest]
225
+
226
+ expand_meta : typing.Optional[AdHocExpandMetaRequest]
227
+
228
+ request_options : typing.Optional[RequestOptions]
229
+ Request-specific configuration.
230
+
231
+ Yields
232
+ ------
233
+ typing.AsyncIterator[AdHocExecutePromptEvent]
234
+
235
+
236
+ Examples
237
+ --------
238
+ import asyncio
239
+
240
+ from vellum import (
241
+ AdHocExpandMetaRequest,
242
+ AsyncVellum,
243
+ EphemeralPromptCacheConfigRequest,
244
+ JinjaPromptBlockPropertiesRequest,
245
+ JinjaPromptBlockRequest,
246
+ PromptParametersRequest,
247
+ PromptRequestStringInputRequest,
248
+ VellumVariableRequest,
249
+ )
250
+
251
+ client = AsyncVellum(
252
+ api_key="YOUR_API_KEY",
253
+ )
254
+
255
+
256
+ async def main() -> None:
257
+ response = await client.ad_hoc.adhoc_execute_prompt_stream(
258
+ ml_model="string",
259
+ input_values=[
260
+ PromptRequestStringInputRequest(
261
+ key="string",
262
+ value="string",
263
+ )
264
+ ],
265
+ input_variables=[
266
+ VellumVariableRequest(
267
+ id="string",
268
+ key="string",
269
+ type="STRING",
270
+ )
271
+ ],
272
+ parameters=PromptParametersRequest(
273
+ stop=["string"],
274
+ temperature=1.1,
275
+ max_tokens=1,
276
+ top_p=1.1,
277
+ top_k=1,
278
+ frequency_penalty=1.1,
279
+ presence_penalty=1.1,
280
+ logit_bias={"string": {"key": "value"}},
281
+ custom_parameters={"string": {"key": "value"}},
282
+ ),
283
+ blocks=[
284
+ JinjaPromptBlockRequest(
285
+ properties=JinjaPromptBlockPropertiesRequest(
286
+ template="string",
287
+ template_type="STRING",
288
+ ),
289
+ id="string",
290
+ state="ENABLED",
291
+ cache_config=EphemeralPromptCacheConfigRequest(),
292
+ )
293
+ ],
294
+ expand_meta=AdHocExpandMetaRequest(
295
+ cost=True,
296
+ model_name=True,
297
+ usage=True,
298
+ finish_reason=True,
299
+ ),
300
+ )
301
+ async for chunk in response:
302
+ yield chunk
303
+
304
+
305
+ asyncio.run(main())
306
+ """
307
+ async with self._client_wrapper.httpx_client.stream(
308
+ "v1/ad-hoc/execute-prompt-stream",
309
+ base_url=self._client_wrapper.get_environment().default,
310
+ method="POST",
311
+ json={
312
+ "ml_model": ml_model,
313
+ "input_values": input_values,
314
+ "input_variables": input_variables,
315
+ "parameters": parameters,
316
+ "blocks": blocks,
317
+ "expand_meta": expand_meta,
318
+ },
319
+ request_options=request_options,
320
+ omit=OMIT,
321
+ ) as _response:
322
+ try:
323
+ if 200 <= _response.status_code < 300:
324
+ async for _text in _response.aiter_lines():
325
+ try:
326
+ if len(_text) == 0:
327
+ continue
328
+ yield typing.cast(
329
+ AdHocExecutePromptEvent,
330
+ parse_obj_as(
331
+ type_=AdHocExecutePromptEvent, # type: ignore
332
+ object_=json.loads(_text),
333
+ ),
334
+ )
335
+ except:
336
+ pass
337
+ return
338
+ await _response.aread()
339
+ if _response.status_code == 400:
340
+ raise BadRequestError(
341
+ typing.cast(
342
+ typing.Optional[typing.Any],
343
+ parse_obj_as(
344
+ type_=typing.Optional[typing.Any], # type: ignore
345
+ object_=_response.json(),
346
+ ),
347
+ )
348
+ )
349
+ if _response.status_code == 403:
350
+ raise ForbiddenError(
351
+ typing.cast(
352
+ typing.Optional[typing.Any],
353
+ parse_obj_as(
354
+ type_=typing.Optional[typing.Any], # type: ignore
355
+ object_=_response.json(),
356
+ ),
357
+ )
358
+ )
359
+ if _response.status_code == 500:
360
+ raise InternalServerError(
361
+ typing.cast(
362
+ typing.Optional[typing.Any],
363
+ parse_obj_as(
364
+ type_=typing.Optional[typing.Any], # type: ignore
365
+ object_=_response.json(),
366
+ ),
367
+ )
368
+ )
369
+ _response_json = _response.json()
370
+ except JSONDecodeError:
371
+ raise ApiError(status_code=_response.status_code, body=_response.text)
372
+ raise ApiError(status_code=_response.status_code, body=_response_json)