vellum-ai 0.0.21__py3-none-any.whl → 0.0.22__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/__init__.py +19 -19
- vellum/client.py +270 -101
- vellum/core/__init__.py +11 -2
- vellum/core/client_wrapper.py +27 -0
- vellum/core/remove_none_from_dict.py +11 -0
- vellum/resources/deployments/client.py +35 -15
- vellum/resources/document_indexes/client.py +64 -16
- vellum/resources/documents/client.py +110 -35
- vellum/resources/model_versions/client.py +67 -25
- vellum/resources/registered_prompts/client.py +80 -16
- vellum/resources/sandboxes/client.py +90 -25
- vellum/resources/test_suites/client.py +90 -25
- vellum/types/deployment_read.py +2 -6
- vellum/types/document.py +3 -7
- vellum/types/document_document_to_document_index.py +2 -2
- vellum/types/document_index_read.py +3 -7
- vellum/types/enriched_normalized_completion.py +5 -9
- vellum/types/evaluation_params.py +1 -3
- vellum/types/evaluation_params_request.py +1 -3
- vellum/types/generate_error_response.py +1 -1
- vellum/types/generate_request.py +3 -7
- vellum/types/generate_result.py +2 -6
- vellum/types/generate_result_data.py +1 -1
- vellum/types/generate_result_error.py +1 -1
- vellum/types/model_version_build_config.py +2 -6
- vellum/types/model_version_compile_prompt_response.py +1 -1
- vellum/types/model_version_compiled_prompt.py +2 -4
- vellum/types/model_version_exec_config.py +3 -3
- vellum/types/model_version_read.py +6 -10
- vellum/types/model_version_sandbox_snapshot.py +3 -5
- vellum/types/prompt_template_block_properties_request.py +2 -2
- vellum/types/prompt_template_block_request.py +1 -1
- vellum/types/prompt_template_input_variable.py +1 -1
- vellum/types/prompt_template_input_variable_request.py +1 -1
- vellum/types/register_prompt_error_response.py +1 -1
- vellum/types/register_prompt_prompt.py +2 -2
- vellum/types/register_prompt_prompt_info_request.py +1 -1
- vellum/types/register_prompt_response.py +5 -7
- vellum/types/registered_prompt_deployment.py +3 -3
- vellum/types/registered_prompt_model_version.py +2 -2
- vellum/types/registered_prompt_sandbox.py +2 -2
- vellum/types/registered_prompt_sandbox_snapshot.py +1 -1
- vellum/types/sandbox_scenario.py +2 -2
- vellum/types/scenario_input_request.py +1 -1
- vellum/types/search_error_response.py +1 -1
- vellum/types/search_filters_request.py +1 -1
- vellum/types/search_request_options_request.py +4 -6
- vellum/types/search_response.py +1 -1
- vellum/types/search_result.py +3 -3
- vellum/types/search_result_merging_request.py +1 -1
- vellum/types/search_weights_request.py +2 -2
- vellum/types/slim_document.py +5 -9
- vellum/types/submit_completion_actual_request.py +5 -15
- vellum/types/terminal_node_chat_history_result.py +1 -1
- vellum/types/terminal_node_json_result.py +1 -1
- vellum/types/terminal_node_result_output.py +2 -4
- vellum/types/terminal_node_string_result.py +1 -1
- vellum/types/test_suite_test_case.py +4 -8
- vellum/types/upload_document_response.py +1 -1
- vellum/types/workflow_node_result_data.py +7 -11
- vellum/types/workflow_request_chat_history_input_request.py +1 -3
- vellum/types/workflow_request_input_request.py +2 -6
- vellum/types/workflow_request_json_input_request.py +1 -3
- vellum/types/workflow_request_string_input_request.py +1 -3
- vellum/types/workflow_result_event_output_data.py +2 -8
- vellum/types/workflow_result_event_output_data_chat_history.py +3 -0
- vellum/types/workflow_result_event_output_data_json.py +3 -0
- vellum/types/workflow_result_event_output_data_string.py +6 -1
- vellum/types/workflow_stream_event.py +1 -4
- {vellum_ai-0.0.21.dist-info → vellum_ai-0.0.22.dist-info}/METADATA +1 -1
- {vellum_ai-0.0.21.dist-info → vellum_ai-0.0.22.dist-info}/RECORD +72 -71
- vellum/core/remove_none_from_headers.py +0 -11
- {vellum_ai-0.0.21.dist-info → vellum_ai-0.0.22.dist-info}/WHEEL +0 -0
vellum/__init__.py
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
|
-
from .environment import VellumEnvironment
|
4
|
-
from .errors import BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError
|
5
|
-
from .resources import (
|
6
|
-
deployments,
|
7
|
-
document_indexes,
|
8
|
-
documents,
|
9
|
-
model_versions,
|
10
|
-
registered_prompts,
|
11
|
-
sandboxes,
|
12
|
-
test_suites,
|
13
|
-
)
|
14
3
|
from .types import (
|
15
4
|
BlockTypeEnum,
|
16
5
|
ChatMessage,
|
@@ -46,8 +35,8 @@ from .types import (
|
|
46
35
|
LogprobsEnum,
|
47
36
|
ModelTypeEnum,
|
48
37
|
ModelVersionBuildConfig,
|
49
|
-
ModelVersionCompiledPrompt,
|
50
38
|
ModelVersionCompilePromptResponse,
|
39
|
+
ModelVersionCompiledPrompt,
|
51
40
|
ModelVersionExecConfig,
|
52
41
|
ModelVersionExecConfigParameters,
|
53
42
|
ModelVersionRead,
|
@@ -69,15 +58,15 @@ from .types import (
|
|
69
58
|
PromptTemplateInputVariable,
|
70
59
|
PromptTemplateInputVariableRequest,
|
71
60
|
ProviderEnum,
|
72
|
-
RegisteredPromptDeployment,
|
73
|
-
RegisteredPromptModelVersion,
|
74
|
-
RegisteredPromptSandbox,
|
75
|
-
RegisteredPromptSandboxSnapshot,
|
76
61
|
RegisterPromptErrorResponse,
|
77
62
|
RegisterPromptModelParametersRequest,
|
78
63
|
RegisterPromptPrompt,
|
79
64
|
RegisterPromptPromptInfoRequest,
|
80
65
|
RegisterPromptResponse,
|
66
|
+
RegisteredPromptDeployment,
|
67
|
+
RegisteredPromptModelVersion,
|
68
|
+
RegisteredPromptSandbox,
|
69
|
+
RegisteredPromptSandboxSnapshot,
|
81
70
|
SandboxMetricInputParams,
|
82
71
|
SandboxMetricInputParamsRequest,
|
83
72
|
SandboxNodeResult,
|
@@ -133,16 +122,27 @@ from .types import (
|
|
133
122
|
WorkflowRequestStringInputRequest,
|
134
123
|
WorkflowResultEvent,
|
135
124
|
WorkflowResultEventOutputData,
|
136
|
-
WorkflowResultEventOutputData_ChatHistory,
|
137
|
-
WorkflowResultEventOutputData_Json,
|
138
|
-
WorkflowResultEventOutputData_String,
|
139
125
|
WorkflowResultEventOutputDataChatHistory,
|
140
126
|
WorkflowResultEventOutputDataJson,
|
141
127
|
WorkflowResultEventOutputDataString,
|
128
|
+
WorkflowResultEventOutputData_ChatHistory,
|
129
|
+
WorkflowResultEventOutputData_Json,
|
130
|
+
WorkflowResultEventOutputData_String,
|
142
131
|
WorkflowStreamEvent,
|
143
132
|
WorkflowStreamEvent_Node,
|
144
133
|
WorkflowStreamEvent_Workflow,
|
145
134
|
)
|
135
|
+
from .errors import BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError
|
136
|
+
from .resources import (
|
137
|
+
deployments,
|
138
|
+
document_indexes,
|
139
|
+
documents,
|
140
|
+
model_versions,
|
141
|
+
registered_prompts,
|
142
|
+
sandboxes,
|
143
|
+
test_suites,
|
144
|
+
)
|
145
|
+
from .environment import VellumEnvironment
|
146
146
|
|
147
147
|
__all__ = [
|
148
148
|
"BadRequestError",
|
vellum/client.py
CHANGED
@@ -9,8 +9,8 @@ import httpx
|
|
9
9
|
import pydantic
|
10
10
|
|
11
11
|
from .core.api_error import ApiError
|
12
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
12
13
|
from .core.jsonable_encoder import jsonable_encoder
|
13
|
-
from .core.remove_none_from_headers import remove_none_from_headers
|
14
14
|
from .environment import VellumEnvironment
|
15
15
|
from .errors.bad_request_error import BadRequestError
|
16
16
|
from .errors.forbidden_error import ForbiddenError
|
@@ -39,16 +39,22 @@ OMIT = typing.cast(typing.Any, ...)
|
|
39
39
|
|
40
40
|
|
41
41
|
class Vellum:
|
42
|
-
def __init__(
|
42
|
+
def __init__(
|
43
|
+
self,
|
44
|
+
*,
|
45
|
+
environment: VellumEnvironment = VellumEnvironment.PRODUCTION,
|
46
|
+
api_key: str,
|
47
|
+
timeout: typing.Optional[float] = None,
|
48
|
+
):
|
43
49
|
self._environment = environment
|
44
|
-
self.
|
45
|
-
self.deployments = DeploymentsClient(environment=
|
46
|
-
self.document_indexes = DocumentIndexesClient(environment=
|
47
|
-
self.documents = DocumentsClient(environment=
|
48
|
-
self.model_versions = ModelVersionsClient(environment=
|
49
|
-
self.registered_prompts = RegisteredPromptsClient(environment=
|
50
|
-
self.sandboxes = SandboxesClient(environment=
|
51
|
-
self.test_suites = TestSuitesClient(environment=
|
50
|
+
self._client_wrapper = SyncClientWrapper(api_key=api_key, httpx_client=httpx.Client(timeout=timeout))
|
51
|
+
self.deployments = DeploymentsClient(environment=environment, client_wrapper=self._client_wrapper)
|
52
|
+
self.document_indexes = DocumentIndexesClient(environment=environment, client_wrapper=self._client_wrapper)
|
53
|
+
self.documents = DocumentsClient(environment=environment, client_wrapper=self._client_wrapper)
|
54
|
+
self.model_versions = ModelVersionsClient(environment=environment, client_wrapper=self._client_wrapper)
|
55
|
+
self.registered_prompts = RegisteredPromptsClient(environment=environment, client_wrapper=self._client_wrapper)
|
56
|
+
self.sandboxes = SandboxesClient(environment=environment, client_wrapper=self._client_wrapper)
|
57
|
+
self.test_suites = TestSuitesClient(environment=environment, client_wrapper=self._client_wrapper)
|
52
58
|
|
53
59
|
def execute_workflow_stream(
|
54
60
|
self,
|
@@ -59,6 +65,22 @@ class Vellum:
|
|
59
65
|
inputs: typing.List[WorkflowRequestInputRequest],
|
60
66
|
external_id: typing.Optional[str] = OMIT,
|
61
67
|
) -> typing.Iterator[WorkflowStreamEvent]:
|
68
|
+
"""
|
69
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
70
|
+
|
71
|
+
Executes a deployed Workflow and streams back its results.
|
72
|
+
|
73
|
+
Parameters:
|
74
|
+
- workflow_deployment_id: typing.Optional[str]. The ID of the Workflow Deployment. Must provide either this or workflow_deployment_name.
|
75
|
+
|
76
|
+
- workflow_deployment_name: typing.Optional[str]. The name of the Workflow Deployment. Must provide either this or workflow_deployment_id.
|
77
|
+
|
78
|
+
- release_tag: typing.Optional[str]. Optionally specify a release tag if you want to pin to a specific release of the Workflow Deployment
|
79
|
+
|
80
|
+
- inputs: typing.List[WorkflowRequestInputRequest].
|
81
|
+
|
82
|
+
- external_id: typing.Optional[str]. Optionally include a unique identifier for tracking purposes.
|
83
|
+
"""
|
62
84
|
_request: typing.Dict[str, typing.Any] = {"inputs": inputs}
|
63
85
|
if workflow_deployment_id is not OMIT:
|
64
86
|
_request["workflow_deployment_id"] = workflow_deployment_id
|
@@ -68,20 +90,21 @@ class Vellum:
|
|
68
90
|
_request["release_tag"] = release_tag
|
69
91
|
if external_id is not OMIT:
|
70
92
|
_request["external_id"] = external_id
|
71
|
-
with
|
93
|
+
with self._client_wrapper.httpx_client.stream(
|
72
94
|
"POST",
|
73
95
|
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/execute-workflow-stream"),
|
74
96
|
json=jsonable_encoder(_request),
|
75
|
-
headers=
|
97
|
+
headers=self._client_wrapper.get_headers(),
|
76
98
|
timeout=None,
|
77
99
|
) as _response:
|
78
100
|
if 200 <= _response.status_code < 300:
|
79
|
-
for _text in _response.
|
101
|
+
for _text in _response.iter_lines():
|
80
102
|
if len(_text) == 0:
|
81
103
|
continue
|
82
104
|
yield pydantic.parse_obj_as(WorkflowStreamEvent, json.loads(_text)) # type: ignore
|
83
105
|
return
|
84
106
|
try:
|
107
|
+
_response.read()
|
85
108
|
_response_json = _response.json()
|
86
109
|
except JSONDecodeError:
|
87
110
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
@@ -95,6 +118,22 @@ class Vellum:
|
|
95
118
|
requests: typing.List[GenerateRequest],
|
96
119
|
options: typing.Optional[GenerateOptionsRequest] = OMIT,
|
97
120
|
) -> GenerateResponse:
|
121
|
+
"""
|
122
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
123
|
+
|
124
|
+
Generate a completion using a previously defined deployment.
|
125
|
+
|
126
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
127
|
+
|
128
|
+
Parameters:
|
129
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
130
|
+
|
131
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
132
|
+
|
133
|
+
- requests: typing.List[GenerateRequest]. The generation requests to make. Supplying multiple will perform a bulk request to the LLM provided when possible.
|
134
|
+
|
135
|
+
- options: typing.Optional[GenerateOptionsRequest]. Additional configuration that can be used to control what's included in the response.
|
136
|
+
"""
|
98
137
|
_request: typing.Dict[str, typing.Any] = {"requests": requests}
|
99
138
|
if deployment_id is not OMIT:
|
100
139
|
_request["deployment_id"] = deployment_id
|
@@ -102,11 +141,11 @@ class Vellum:
|
|
102
141
|
_request["deployment_name"] = deployment_name
|
103
142
|
if options is not OMIT:
|
104
143
|
_request["options"] = options
|
105
|
-
_response =
|
144
|
+
_response = self._client_wrapper.httpx_client.request(
|
106
145
|
"POST",
|
107
146
|
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/generate"),
|
108
147
|
json=jsonable_encoder(_request),
|
109
|
-
headers=
|
148
|
+
headers=self._client_wrapper.get_headers(),
|
110
149
|
timeout=None,
|
111
150
|
)
|
112
151
|
if 200 <= _response.status_code < 300:
|
@@ -133,6 +172,22 @@ class Vellum:
|
|
133
172
|
requests: typing.List[GenerateRequest],
|
134
173
|
options: typing.Optional[GenerateOptionsRequest] = OMIT,
|
135
174
|
) -> typing.Iterator[GenerateStreamResponse]:
|
175
|
+
"""
|
176
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
177
|
+
|
178
|
+
Generate a stream of completions using a previously defined deployment.
|
179
|
+
|
180
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
181
|
+
|
182
|
+
Parameters:
|
183
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
184
|
+
|
185
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
186
|
+
|
187
|
+
- requests: typing.List[GenerateRequest]. The generation requests to make. Supplying multiple will perform a bulk request to the LLM provided when possible.
|
188
|
+
|
189
|
+
- options: typing.Optional[GenerateOptionsRequest]. Additional configuration that can be used to control what's included in the response.
|
190
|
+
"""
|
136
191
|
_request: typing.Dict[str, typing.Any] = {"requests": requests}
|
137
192
|
if deployment_id is not OMIT:
|
138
193
|
_request["deployment_id"] = deployment_id
|
@@ -140,15 +195,15 @@ class Vellum:
|
|
140
195
|
_request["deployment_name"] = deployment_name
|
141
196
|
if options is not OMIT:
|
142
197
|
_request["options"] = options
|
143
|
-
with
|
198
|
+
with self._client_wrapper.httpx_client.stream(
|
144
199
|
"POST",
|
145
200
|
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/generate-stream"),
|
146
201
|
json=jsonable_encoder(_request),
|
147
|
-
headers=
|
202
|
+
headers=self._client_wrapper.get_headers(),
|
148
203
|
timeout=None,
|
149
204
|
) as _response:
|
150
205
|
if 200 <= _response.status_code < 300:
|
151
|
-
for _text in _response.
|
206
|
+
for _text in _response.iter_lines():
|
152
207
|
if len(_text) == 0:
|
153
208
|
continue
|
154
209
|
yield pydantic.parse_obj_as(GenerateStreamResponse, json.loads(_text)) # type: ignore
|
@@ -162,6 +217,7 @@ class Vellum:
|
|
162
217
|
if _response.status_code == 500:
|
163
218
|
raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
164
219
|
try:
|
220
|
+
_response.read()
|
165
221
|
_response_json = _response.json()
|
166
222
|
except JSONDecodeError:
|
167
223
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
@@ -175,6 +231,22 @@ class Vellum:
|
|
175
231
|
query: str,
|
176
232
|
options: typing.Optional[SearchRequestOptionsRequest] = OMIT,
|
177
233
|
) -> SearchResponse:
|
234
|
+
"""
|
235
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
236
|
+
|
237
|
+
Perform a search against a document index.
|
238
|
+
|
239
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
240
|
+
|
241
|
+
Parameters:
|
242
|
+
- index_id: typing.Optional[str]. The ID of the index to search against. Must provide either this or index_name.
|
243
|
+
|
244
|
+
- index_name: typing.Optional[str]. The name of the index to search against. Must provide either this or index_id.
|
245
|
+
|
246
|
+
- query: str. The query to search for. <span style="white-space: nowrap">`non-empty`</span>
|
247
|
+
|
248
|
+
- options: typing.Optional[SearchRequestOptionsRequest]. Configuration options for the search.
|
249
|
+
"""
|
178
250
|
_request: typing.Dict[str, typing.Any] = {"query": query}
|
179
251
|
if index_id is not OMIT:
|
180
252
|
_request["index_id"] = index_id
|
@@ -182,11 +254,11 @@ class Vellum:
|
|
182
254
|
_request["index_name"] = index_name
|
183
255
|
if options is not OMIT:
|
184
256
|
_request["options"] = options
|
185
|
-
_response =
|
257
|
+
_response = self._client_wrapper.httpx_client.request(
|
186
258
|
"POST",
|
187
259
|
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/search"),
|
188
260
|
json=jsonable_encoder(_request),
|
189
|
-
headers=
|
261
|
+
headers=self._client_wrapper.get_headers(),
|
190
262
|
timeout=None,
|
191
263
|
)
|
192
264
|
if 200 <= _response.status_code < 300:
|
@@ -210,16 +282,30 @@ class Vellum:
|
|
210
282
|
deployment_name: typing.Optional[str] = OMIT,
|
211
283
|
actuals: typing.List[SubmitCompletionActualRequest],
|
212
284
|
) -> None:
|
285
|
+
"""
|
286
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
287
|
+
|
288
|
+
Used to submit feedback regarding the quality of previously generated completions.
|
289
|
+
|
290
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
291
|
+
|
292
|
+
Parameters:
|
293
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
294
|
+
|
295
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
296
|
+
|
297
|
+
- actuals: typing.List[SubmitCompletionActualRequest]. Feedback regarding the quality of previously generated completions
|
298
|
+
"""
|
213
299
|
_request: typing.Dict[str, typing.Any] = {"actuals": actuals}
|
214
300
|
if deployment_id is not OMIT:
|
215
301
|
_request["deployment_id"] = deployment_id
|
216
302
|
if deployment_name is not OMIT:
|
217
303
|
_request["deployment_name"] = deployment_name
|
218
|
-
_response =
|
304
|
+
_response = self._client_wrapper.httpx_client.request(
|
219
305
|
"POST",
|
220
306
|
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/submit-completion-actuals"),
|
221
307
|
json=jsonable_encoder(_request),
|
222
|
-
headers=
|
308
|
+
headers=self._client_wrapper.get_headers(),
|
223
309
|
timeout=None,
|
224
310
|
)
|
225
311
|
if 200 <= _response.status_code < 300:
|
@@ -238,16 +324,24 @@ class Vellum:
|
|
238
324
|
|
239
325
|
|
240
326
|
class AsyncVellum:
|
241
|
-
def __init__(
|
327
|
+
def __init__(
|
328
|
+
self,
|
329
|
+
*,
|
330
|
+
environment: VellumEnvironment = VellumEnvironment.PRODUCTION,
|
331
|
+
api_key: str,
|
332
|
+
timeout: typing.Optional[float] = None,
|
333
|
+
):
|
242
334
|
self._environment = environment
|
243
|
-
self.
|
244
|
-
self.deployments = AsyncDeploymentsClient(environment=
|
245
|
-
self.document_indexes = AsyncDocumentIndexesClient(environment=
|
246
|
-
self.documents = AsyncDocumentsClient(environment=
|
247
|
-
self.model_versions = AsyncModelVersionsClient(environment=
|
248
|
-
self.registered_prompts = AsyncRegisteredPromptsClient(
|
249
|
-
|
250
|
-
|
335
|
+
self._client_wrapper = AsyncClientWrapper(api_key=api_key, httpx_client=httpx.AsyncClient(timeout=timeout))
|
336
|
+
self.deployments = AsyncDeploymentsClient(environment=environment, client_wrapper=self._client_wrapper)
|
337
|
+
self.document_indexes = AsyncDocumentIndexesClient(environment=environment, client_wrapper=self._client_wrapper)
|
338
|
+
self.documents = AsyncDocumentsClient(environment=environment, client_wrapper=self._client_wrapper)
|
339
|
+
self.model_versions = AsyncModelVersionsClient(environment=environment, client_wrapper=self._client_wrapper)
|
340
|
+
self.registered_prompts = AsyncRegisteredPromptsClient(
|
341
|
+
environment=environment, client_wrapper=self._client_wrapper
|
342
|
+
)
|
343
|
+
self.sandboxes = AsyncSandboxesClient(environment=environment, client_wrapper=self._client_wrapper)
|
344
|
+
self.test_suites = AsyncTestSuitesClient(environment=environment, client_wrapper=self._client_wrapper)
|
251
345
|
|
252
346
|
async def execute_workflow_stream(
|
253
347
|
self,
|
@@ -258,6 +352,22 @@ class AsyncVellum:
|
|
258
352
|
inputs: typing.List[WorkflowRequestInputRequest],
|
259
353
|
external_id: typing.Optional[str] = OMIT,
|
260
354
|
) -> typing.AsyncIterator[WorkflowStreamEvent]:
|
355
|
+
"""
|
356
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
357
|
+
|
358
|
+
Executes a deployed Workflow and streams back its results.
|
359
|
+
|
360
|
+
Parameters:
|
361
|
+
- workflow_deployment_id: typing.Optional[str]. The ID of the Workflow Deployment. Must provide either this or workflow_deployment_name.
|
362
|
+
|
363
|
+
- workflow_deployment_name: typing.Optional[str]. The name of the Workflow Deployment. Must provide either this or workflow_deployment_id.
|
364
|
+
|
365
|
+
- release_tag: typing.Optional[str]. Optionally specify a release tag if you want to pin to a specific release of the Workflow Deployment
|
366
|
+
|
367
|
+
- inputs: typing.List[WorkflowRequestInputRequest].
|
368
|
+
|
369
|
+
- external_id: typing.Optional[str]. Optionally include a unique identifier for tracking purposes.
|
370
|
+
"""
|
261
371
|
_request: typing.Dict[str, typing.Any] = {"inputs": inputs}
|
262
372
|
if workflow_deployment_id is not OMIT:
|
263
373
|
_request["workflow_deployment_id"] = workflow_deployment_id
|
@@ -267,25 +377,25 @@ class AsyncVellum:
|
|
267
377
|
_request["release_tag"] = release_tag
|
268
378
|
if external_id is not OMIT:
|
269
379
|
_request["external_id"] = external_id
|
270
|
-
async with
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
380
|
+
async with self._client_wrapper.httpx_client.stream(
|
381
|
+
"POST",
|
382
|
+
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/execute-workflow-stream"),
|
383
|
+
json=jsonable_encoder(_request),
|
384
|
+
headers=self._client_wrapper.get_headers(),
|
385
|
+
timeout=None,
|
386
|
+
) as _response:
|
387
|
+
if 200 <= _response.status_code < 300:
|
388
|
+
async for _text in _response.aiter_lines():
|
389
|
+
if len(_text) == 0:
|
390
|
+
continue
|
391
|
+
yield pydantic.parse_obj_as(WorkflowStreamEvent, json.loads(_text)) # type: ignore
|
392
|
+
return
|
393
|
+
try:
|
394
|
+
await _response.aread()
|
395
|
+
_response_json = _response.json()
|
396
|
+
except JSONDecodeError:
|
397
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
398
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
289
399
|
|
290
400
|
async def generate(
|
291
401
|
self,
|
@@ -295,6 +405,22 @@ class AsyncVellum:
|
|
295
405
|
requests: typing.List[GenerateRequest],
|
296
406
|
options: typing.Optional[GenerateOptionsRequest] = OMIT,
|
297
407
|
) -> GenerateResponse:
|
408
|
+
"""
|
409
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
410
|
+
|
411
|
+
Generate a completion using a previously defined deployment.
|
412
|
+
|
413
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
414
|
+
|
415
|
+
Parameters:
|
416
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
417
|
+
|
418
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
419
|
+
|
420
|
+
- requests: typing.List[GenerateRequest]. The generation requests to make. Supplying multiple will perform a bulk request to the LLM provided when possible.
|
421
|
+
|
422
|
+
- options: typing.Optional[GenerateOptionsRequest]. Additional configuration that can be used to control what's included in the response.
|
423
|
+
"""
|
298
424
|
_request: typing.Dict[str, typing.Any] = {"requests": requests}
|
299
425
|
if deployment_id is not OMIT:
|
300
426
|
_request["deployment_id"] = deployment_id
|
@@ -302,14 +428,13 @@ class AsyncVellum:
|
|
302
428
|
_request["deployment_name"] = deployment_name
|
303
429
|
if options is not OMIT:
|
304
430
|
_request["options"] = options
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
)
|
431
|
+
_response = await self._client_wrapper.httpx_client.request(
|
432
|
+
"POST",
|
433
|
+
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/generate"),
|
434
|
+
json=jsonable_encoder(_request),
|
435
|
+
headers=self._client_wrapper.get_headers(),
|
436
|
+
timeout=None,
|
437
|
+
)
|
313
438
|
if 200 <= _response.status_code < 300:
|
314
439
|
return pydantic.parse_obj_as(GenerateResponse, _response.json()) # type: ignore
|
315
440
|
if _response.status_code == 400:
|
@@ -334,6 +459,22 @@ class AsyncVellum:
|
|
334
459
|
requests: typing.List[GenerateRequest],
|
335
460
|
options: typing.Optional[GenerateOptionsRequest] = OMIT,
|
336
461
|
) -> typing.AsyncIterator[GenerateStreamResponse]:
|
462
|
+
"""
|
463
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
464
|
+
|
465
|
+
Generate a stream of completions using a previously defined deployment.
|
466
|
+
|
467
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
468
|
+
|
469
|
+
Parameters:
|
470
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
471
|
+
|
472
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
473
|
+
|
474
|
+
- requests: typing.List[GenerateRequest]. The generation requests to make. Supplying multiple will perform a bulk request to the LLM provided when possible.
|
475
|
+
|
476
|
+
- options: typing.Optional[GenerateOptionsRequest]. Additional configuration that can be used to control what's included in the response.
|
477
|
+
"""
|
337
478
|
_request: typing.Dict[str, typing.Any] = {"requests": requests}
|
338
479
|
if deployment_id is not OMIT:
|
339
480
|
_request["deployment_id"] = deployment_id
|
@@ -341,33 +482,33 @@ class AsyncVellum:
|
|
341
482
|
_request["deployment_name"] = deployment_name
|
342
483
|
if options is not OMIT:
|
343
484
|
_request["options"] = options
|
344
|
-
async with
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
485
|
+
async with self._client_wrapper.httpx_client.stream(
|
486
|
+
"POST",
|
487
|
+
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/generate-stream"),
|
488
|
+
json=jsonable_encoder(_request),
|
489
|
+
headers=self._client_wrapper.get_headers(),
|
490
|
+
timeout=None,
|
491
|
+
) as _response:
|
492
|
+
if 200 <= _response.status_code < 300:
|
493
|
+
async for _text in _response.aiter_lines():
|
494
|
+
if len(_text) == 0:
|
495
|
+
continue
|
496
|
+
yield pydantic.parse_obj_as(GenerateStreamResponse, json.loads(_text)) # type: ignore
|
497
|
+
return
|
498
|
+
if _response.status_code == 400:
|
499
|
+
raise BadRequestError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
500
|
+
if _response.status_code == 403:
|
501
|
+
raise ForbiddenError(pydantic.parse_obj_as(GenerateErrorResponse, _response.json())) # type: ignore
|
502
|
+
if _response.status_code == 404:
|
503
|
+
raise NotFoundError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
504
|
+
if _response.status_code == 500:
|
505
|
+
raise InternalServerError(pydantic.parse_obj_as(typing.Any, _response.json())) # type: ignore
|
506
|
+
try:
|
507
|
+
await _response.aread()
|
508
|
+
_response_json = _response.json()
|
509
|
+
except JSONDecodeError:
|
510
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
511
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
371
512
|
|
372
513
|
async def search(
|
373
514
|
self,
|
@@ -377,6 +518,22 @@ class AsyncVellum:
|
|
377
518
|
query: str,
|
378
519
|
options: typing.Optional[SearchRequestOptionsRequest] = OMIT,
|
379
520
|
) -> SearchResponse:
|
521
|
+
"""
|
522
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
523
|
+
|
524
|
+
Perform a search against a document index.
|
525
|
+
|
526
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
527
|
+
|
528
|
+
Parameters:
|
529
|
+
- index_id: typing.Optional[str]. The ID of the index to search against. Must provide either this or index_name.
|
530
|
+
|
531
|
+
- index_name: typing.Optional[str]. The name of the index to search against. Must provide either this or index_id.
|
532
|
+
|
533
|
+
- query: str. The query to search for. <span style="white-space: nowrap">`non-empty`</span>
|
534
|
+
|
535
|
+
- options: typing.Optional[SearchRequestOptionsRequest]. Configuration options for the search.
|
536
|
+
"""
|
380
537
|
_request: typing.Dict[str, typing.Any] = {"query": query}
|
381
538
|
if index_id is not OMIT:
|
382
539
|
_request["index_id"] = index_id
|
@@ -384,14 +541,13 @@ class AsyncVellum:
|
|
384
541
|
_request["index_name"] = index_name
|
385
542
|
if options is not OMIT:
|
386
543
|
_request["options"] = options
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
)
|
544
|
+
_response = await self._client_wrapper.httpx_client.request(
|
545
|
+
"POST",
|
546
|
+
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/search"),
|
547
|
+
json=jsonable_encoder(_request),
|
548
|
+
headers=self._client_wrapper.get_headers(),
|
549
|
+
timeout=None,
|
550
|
+
)
|
395
551
|
if 200 <= _response.status_code < 300:
|
396
552
|
return pydantic.parse_obj_as(SearchResponse, _response.json()) # type: ignore
|
397
553
|
if _response.status_code == 400:
|
@@ -413,19 +569,32 @@ class AsyncVellum:
|
|
413
569
|
deployment_name: typing.Optional[str] = OMIT,
|
414
570
|
actuals: typing.List[SubmitCompletionActualRequest],
|
415
571
|
) -> None:
|
572
|
+
"""
|
573
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
574
|
+
|
575
|
+
Used to submit feedback regarding the quality of previously generated completions.
|
576
|
+
|
577
|
+
**Note:** Uses a base url of `https://predict.vellum.ai`.
|
578
|
+
|
579
|
+
Parameters:
|
580
|
+
- deployment_id: typing.Optional[str]. The ID of the deployment. Must provide either this or deployment_name.
|
581
|
+
|
582
|
+
- deployment_name: typing.Optional[str]. The name of the deployment. Must provide either this or deployment_id.
|
583
|
+
|
584
|
+
- actuals: typing.List[SubmitCompletionActualRequest]. Feedback regarding the quality of previously generated completions
|
585
|
+
"""
|
416
586
|
_request: typing.Dict[str, typing.Any] = {"actuals": actuals}
|
417
587
|
if deployment_id is not OMIT:
|
418
588
|
_request["deployment_id"] = deployment_id
|
419
589
|
if deployment_name is not OMIT:
|
420
590
|
_request["deployment_name"] = deployment_name
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
)
|
591
|
+
_response = await self._client_wrapper.httpx_client.request(
|
592
|
+
"POST",
|
593
|
+
urllib.parse.urljoin(f"{self._environment.predict}/", "v1/submit-completion-actuals"),
|
594
|
+
json=jsonable_encoder(_request),
|
595
|
+
headers=self._client_wrapper.get_headers(),
|
596
|
+
timeout=None,
|
597
|
+
)
|
429
598
|
if 200 <= _response.status_code < 300:
|
430
599
|
return
|
431
600
|
if _response.status_code == 400:
|
vellum/core/__init__.py
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
from .api_error import ApiError
|
4
|
+
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
|
4
5
|
from .datetime_utils import serialize_datetime
|
5
6
|
from .jsonable_encoder import jsonable_encoder
|
6
|
-
from .
|
7
|
+
from .remove_none_from_dict import remove_none_from_dict
|
7
8
|
|
8
|
-
__all__ = [
|
9
|
+
__all__ = [
|
10
|
+
"ApiError",
|
11
|
+
"AsyncClientWrapper",
|
12
|
+
"BaseClientWrapper",
|
13
|
+
"SyncClientWrapper",
|
14
|
+
"jsonable_encoder",
|
15
|
+
"remove_none_from_dict",
|
16
|
+
"serialize_datetime",
|
17
|
+
]
|