vellum-ai 0.0.20__py3-none-any.whl → 0.0.25__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 +38 -20
- vellum/client.py +278 -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/__init__.py +24 -4
- 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/execute_workflow_stream_error_response.py +24 -0
- 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 +7 -10
- vellum/types/model_version_sandbox_snapshot.py +3 -5
- vellum/types/prompt_template_block_properties.py +1 -0
- vellum/types/prompt_template_block_properties_request.py +3 -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/provider_enum.py +5 -0
- 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_event_error.py +26 -0
- vellum/types/workflow_execution_event_error_code.py +31 -0
- vellum/types/workflow_node_result_data.py +7 -11
- vellum/types/workflow_node_result_event.py +4 -3
- vellum/types/{workflow_node_result_event_state_enum.py → workflow_node_result_event_state.py} +5 -5
- 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.py +6 -3
- vellum/types/workflow_result_event_output_data.py +40 -0
- vellum/types/workflow_result_event_output_data_chat_history.py +32 -0
- vellum/types/workflow_result_event_output_data_json.py +31 -0
- vellum/types/workflow_result_event_output_data_string.py +33 -0
- vellum/types/workflow_stream_event.py +1 -4
- {vellum_ai-0.0.20.dist-info → vellum_ai-0.0.25.dist-info}/METADATA +1 -1
- vellum_ai-0.0.25.dist-info/RECORD +149 -0
- vellum/core/remove_none_from_headers.py +0 -11
- vellum/types/workflow_result_event_state_enum.py +0 -31
- vellum_ai-0.0.20.dist-info/RECORD +0 -142
- {vellum_ai-0.0.20.dist-info → vellum_ai-0.0.25.dist-info}/WHEEL +0 -0
@@ -3,25 +3,35 @@
|
|
3
3
|
import urllib.parse
|
4
4
|
from json.decoder import JSONDecodeError
|
5
5
|
|
6
|
-
import httpx
|
7
6
|
import pydantic
|
8
7
|
|
9
8
|
from ...core.api_error import ApiError
|
10
|
-
from ...core.
|
9
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
11
10
|
from ...environment import VellumEnvironment
|
12
11
|
from ...types.deployment_read import DeploymentRead
|
13
12
|
|
14
13
|
|
15
14
|
class DeploymentsClient:
|
16
|
-
def __init__(
|
15
|
+
def __init__(
|
16
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
|
17
|
+
):
|
17
18
|
self._environment = environment
|
18
|
-
self.
|
19
|
+
self._client_wrapper = client_wrapper
|
19
20
|
|
20
21
|
def retrieve(self, id: str) -> DeploymentRead:
|
21
|
-
|
22
|
+
"""
|
23
|
+
|
24
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
25
|
+
|
26
|
+
Used to retrieve a deployment given its ID or name.
|
27
|
+
|
28
|
+
Parameters:
|
29
|
+
- id: str. Either the Deployment's ID or its unique name
|
30
|
+
"""
|
31
|
+
_response = self._client_wrapper.httpx_client.request(
|
22
32
|
"GET",
|
23
33
|
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/deployments/{id}"),
|
24
|
-
headers=
|
34
|
+
headers=self._client_wrapper.get_headers(),
|
25
35
|
timeout=None,
|
26
36
|
)
|
27
37
|
if 200 <= _response.status_code < 300:
|
@@ -34,18 +44,28 @@ class DeploymentsClient:
|
|
34
44
|
|
35
45
|
|
36
46
|
class AsyncDeploymentsClient:
|
37
|
-
def __init__(
|
47
|
+
def __init__(
|
48
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
|
49
|
+
):
|
38
50
|
self._environment = environment
|
39
|
-
self.
|
51
|
+
self._client_wrapper = client_wrapper
|
40
52
|
|
41
53
|
async def retrieve(self, id: str) -> DeploymentRead:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
"""
|
55
|
+
|
56
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
57
|
+
|
58
|
+
Used to retrieve a deployment given its ID or name.
|
59
|
+
|
60
|
+
Parameters:
|
61
|
+
- id: str. Either the Deployment's ID or its unique name
|
62
|
+
"""
|
63
|
+
_response = await self._client_wrapper.httpx_client.request(
|
64
|
+
"GET",
|
65
|
+
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/deployments/{id}"),
|
66
|
+
headers=self._client_wrapper.get_headers(),
|
67
|
+
timeout=None,
|
68
|
+
)
|
49
69
|
if 200 <= _response.status_code < 300:
|
50
70
|
return pydantic.parse_obj_as(DeploymentRead, _response.json()) # type: ignore
|
51
71
|
try:
|
@@ -4,12 +4,11 @@ import typing
|
|
4
4
|
import urllib.parse
|
5
5
|
from json.decoder import JSONDecodeError
|
6
6
|
|
7
|
-
import httpx
|
8
7
|
import pydantic
|
9
8
|
|
10
9
|
from ...core.api_error import ApiError
|
10
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
11
11
|
from ...core.jsonable_encoder import jsonable_encoder
|
12
|
-
from ...core.remove_none_from_headers import remove_none_from_headers
|
13
12
|
from ...environment import VellumEnvironment
|
14
13
|
from ...types.document_index_read import DocumentIndexRead
|
15
14
|
from ...types.document_index_status import DocumentIndexStatus
|
@@ -20,9 +19,11 @@ OMIT = typing.cast(typing.Any, ...)
|
|
20
19
|
|
21
20
|
|
22
21
|
class DocumentIndexesClient:
|
23
|
-
def __init__(
|
22
|
+
def __init__(
|
23
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
|
24
|
+
):
|
24
25
|
self._environment = environment
|
25
|
-
self.
|
26
|
+
self._client_wrapper = client_wrapper
|
26
27
|
|
27
28
|
def create(
|
28
29
|
self,
|
@@ -34,6 +35,29 @@ class DocumentIndexesClient:
|
|
34
35
|
indexing_config: typing.Dict[str, typing.Any],
|
35
36
|
copy_documents_from_index_id: typing.Optional[str] = OMIT,
|
36
37
|
) -> DocumentIndexRead:
|
38
|
+
"""
|
39
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
40
|
+
|
41
|
+
Creates a new document index.
|
42
|
+
|
43
|
+
Parameters:
|
44
|
+
- label: str. A human-readable label for the document index <span style="white-space: nowrap">`non-empty`</span> <span style="white-space: nowrap">`<= 150 characters`</span>
|
45
|
+
|
46
|
+
- name: str. A name that uniquely identifies this index within its workspace <span style="white-space: nowrap">`non-empty`</span> <span style="white-space: nowrap">`<= 150 characters`</span>
|
47
|
+
|
48
|
+
- status: typing.Optional[DocumentIndexStatus]. The current status of the document index
|
49
|
+
|
50
|
+
* `ACTIVE` - Active
|
51
|
+
* `ARCHIVED` - Archived
|
52
|
+
- environment: typing.Optional[EnvironmentEnum]. The environment this document index is used in
|
53
|
+
|
54
|
+
* `DEVELOPMENT` - Development
|
55
|
+
* `STAGING` - Staging
|
56
|
+
* `PRODUCTION` - Production
|
57
|
+
- indexing_config: typing.Dict[str, typing.Any]. Configuration representing how documents should be indexed
|
58
|
+
|
59
|
+
- copy_documents_from_index_id: typing.Optional[str]. Optionally specify the id of a document index from which you'd like to copy and re-index its documents into this newly created index
|
60
|
+
"""
|
37
61
|
_request: typing.Dict[str, typing.Any] = {"label": label, "name": name, "indexing_config": indexing_config}
|
38
62
|
if status is not OMIT:
|
39
63
|
_request["status"] = status
|
@@ -41,11 +65,11 @@ class DocumentIndexesClient:
|
|
41
65
|
_request["environment"] = environment
|
42
66
|
if copy_documents_from_index_id is not OMIT:
|
43
67
|
_request["copy_documents_from_index_id"] = copy_documents_from_index_id
|
44
|
-
_response =
|
68
|
+
_response = self._client_wrapper.httpx_client.request(
|
45
69
|
"POST",
|
46
70
|
urllib.parse.urljoin(f"{self._environment.default}/", "v1/document-indexes"),
|
47
71
|
json=jsonable_encoder(_request),
|
48
|
-
headers=
|
72
|
+
headers=self._client_wrapper.get_headers(),
|
49
73
|
timeout=None,
|
50
74
|
)
|
51
75
|
if 200 <= _response.status_code < 300:
|
@@ -58,9 +82,11 @@ class DocumentIndexesClient:
|
|
58
82
|
|
59
83
|
|
60
84
|
class AsyncDocumentIndexesClient:
|
61
|
-
def __init__(
|
85
|
+
def __init__(
|
86
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
|
87
|
+
):
|
62
88
|
self._environment = environment
|
63
|
-
self.
|
89
|
+
self._client_wrapper = client_wrapper
|
64
90
|
|
65
91
|
async def create(
|
66
92
|
self,
|
@@ -72,6 +98,29 @@ class AsyncDocumentIndexesClient:
|
|
72
98
|
indexing_config: typing.Dict[str, typing.Any],
|
73
99
|
copy_documents_from_index_id: typing.Optional[str] = OMIT,
|
74
100
|
) -> DocumentIndexRead:
|
101
|
+
"""
|
102
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
103
|
+
|
104
|
+
Creates a new document index.
|
105
|
+
|
106
|
+
Parameters:
|
107
|
+
- label: str. A human-readable label for the document index <span style="white-space: nowrap">`non-empty`</span> <span style="white-space: nowrap">`<= 150 characters`</span>
|
108
|
+
|
109
|
+
- name: str. A name that uniquely identifies this index within its workspace <span style="white-space: nowrap">`non-empty`</span> <span style="white-space: nowrap">`<= 150 characters`</span>
|
110
|
+
|
111
|
+
- status: typing.Optional[DocumentIndexStatus]. The current status of the document index
|
112
|
+
|
113
|
+
* `ACTIVE` - Active
|
114
|
+
* `ARCHIVED` - Archived
|
115
|
+
- environment: typing.Optional[EnvironmentEnum]. The environment this document index is used in
|
116
|
+
|
117
|
+
* `DEVELOPMENT` - Development
|
118
|
+
* `STAGING` - Staging
|
119
|
+
* `PRODUCTION` - Production
|
120
|
+
- indexing_config: typing.Dict[str, typing.Any]. Configuration representing how documents should be indexed
|
121
|
+
|
122
|
+
- copy_documents_from_index_id: typing.Optional[str]. Optionally specify the id of a document index from which you'd like to copy and re-index its documents into this newly created index
|
123
|
+
"""
|
75
124
|
_request: typing.Dict[str, typing.Any] = {"label": label, "name": name, "indexing_config": indexing_config}
|
76
125
|
if status is not OMIT:
|
77
126
|
_request["status"] = status
|
@@ -79,14 +128,13 @@ class AsyncDocumentIndexesClient:
|
|
79
128
|
_request["environment"] = environment
|
80
129
|
if copy_documents_from_index_id is not OMIT:
|
81
130
|
_request["copy_documents_from_index_id"] = copy_documents_from_index_id
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
)
|
131
|
+
_response = await self._client_wrapper.httpx_client.request(
|
132
|
+
"POST",
|
133
|
+
urllib.parse.urljoin(f"{self._environment.default}/", "v1/document-indexes"),
|
134
|
+
json=jsonable_encoder(_request),
|
135
|
+
headers=self._client_wrapper.get_headers(),
|
136
|
+
timeout=None,
|
137
|
+
)
|
90
138
|
if 200 <= _response.status_code < 300:
|
91
139
|
return pydantic.parse_obj_as(DocumentIndexRead, _response.json()) # type: ignore
|
92
140
|
try:
|
@@ -4,12 +4,12 @@ import typing
|
|
4
4
|
import urllib.parse
|
5
5
|
from json.decoder import JSONDecodeError
|
6
6
|
|
7
|
-
import httpx
|
8
7
|
import pydantic
|
9
8
|
|
10
9
|
from ...core.api_error import ApiError
|
10
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
11
11
|
from ...core.jsonable_encoder import jsonable_encoder
|
12
|
-
from ...core.
|
12
|
+
from ...core.remove_none_from_dict import remove_none_from_dict
|
13
13
|
from ...environment import VellumEnvironment
|
14
14
|
from ...errors.bad_request_error import BadRequestError
|
15
15
|
from ...errors.internal_server_error import InternalServerError
|
@@ -17,11 +17,16 @@ from ...errors.not_found_error import NotFoundError
|
|
17
17
|
from ...types.paginated_slim_document_list import PaginatedSlimDocumentList
|
18
18
|
from ...types.upload_document_response import UploadDocumentResponse
|
19
19
|
|
20
|
+
# this is used as the default value for optional parameters
|
21
|
+
OMIT = typing.cast(typing.Any, ...)
|
22
|
+
|
20
23
|
|
21
24
|
class DocumentsClient:
|
22
|
-
def __init__(
|
25
|
+
def __init__(
|
26
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
|
27
|
+
):
|
23
28
|
self._environment = environment
|
24
|
-
self.
|
29
|
+
self._client_wrapper = client_wrapper
|
25
30
|
|
26
31
|
def list(
|
27
32
|
self,
|
@@ -31,11 +36,28 @@ class DocumentsClient:
|
|
31
36
|
offset: typing.Optional[int] = None,
|
32
37
|
ordering: typing.Optional[str] = None,
|
33
38
|
) -> PaginatedSlimDocumentList:
|
34
|
-
|
39
|
+
"""
|
40
|
+
|
41
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
42
|
+
|
43
|
+
Used to list documents. Optionally filter on supported fields.
|
44
|
+
|
45
|
+
Parameters:
|
46
|
+
- document_index_id: typing.Optional[str]. Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
47
|
+
|
48
|
+
- limit: typing.Optional[int]. Number of results to return per page.
|
49
|
+
|
50
|
+
- offset: typing.Optional[int]. The initial index from which to return the results.
|
51
|
+
|
52
|
+
- ordering: typing.Optional[str]. Which field to use when ordering the results.
|
53
|
+
"""
|
54
|
+
_response = self._client_wrapper.httpx_client.request(
|
35
55
|
"GET",
|
36
56
|
urllib.parse.urljoin(f"{self._environment.default}/", "v1/documents"),
|
37
|
-
params=
|
38
|
-
|
57
|
+
params=remove_none_from_dict(
|
58
|
+
{"document_index_id": document_index_id, "limit": limit, "offset": offset, "ordering": ordering}
|
59
|
+
),
|
60
|
+
headers=self._client_wrapper.get_headers(),
|
39
61
|
timeout=None,
|
40
62
|
)
|
41
63
|
if 200 <= _response.status_code < 300:
|
@@ -55,7 +77,25 @@ class DocumentsClient:
|
|
55
77
|
contents: typing.IO,
|
56
78
|
keywords: typing.Optional[typing.List[str]] = None,
|
57
79
|
) -> UploadDocumentResponse:
|
58
|
-
|
80
|
+
"""
|
81
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
82
|
+
|
83
|
+
Upload a document to be indexed and used for search.
|
84
|
+
|
85
|
+
**Note:** Uses a base url of `https://documents.vellum.ai`.
|
86
|
+
|
87
|
+
Parameters:
|
88
|
+
- add_to_index_names: typing.Optional[typing.List[str]].
|
89
|
+
|
90
|
+
- external_id: typing.Optional[str].
|
91
|
+
|
92
|
+
- label: str.
|
93
|
+
|
94
|
+
- contents: typing.IO.
|
95
|
+
|
96
|
+
- keywords: typing.Optional[typing.List[str]].
|
97
|
+
"""
|
98
|
+
_response = self._client_wrapper.httpx_client.request(
|
59
99
|
"POST",
|
60
100
|
urllib.parse.urljoin(f"{self._environment.documents}/", "v1/upload-document"),
|
61
101
|
data=jsonable_encoder(
|
@@ -67,7 +107,7 @@ class DocumentsClient:
|
|
67
107
|
}
|
68
108
|
),
|
69
109
|
files={"contents": contents},
|
70
|
-
headers=
|
110
|
+
headers=self._client_wrapper.get_headers(),
|
71
111
|
timeout=None,
|
72
112
|
)
|
73
113
|
if 200 <= _response.status_code < 300:
|
@@ -86,9 +126,11 @@ class DocumentsClient:
|
|
86
126
|
|
87
127
|
|
88
128
|
class AsyncDocumentsClient:
|
89
|
-
def __init__(
|
129
|
+
def __init__(
|
130
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
|
131
|
+
):
|
90
132
|
self._environment = environment
|
91
|
-
self.
|
133
|
+
self._client_wrapper = client_wrapper
|
92
134
|
|
93
135
|
async def list(
|
94
136
|
self,
|
@@ -98,14 +140,30 @@ class AsyncDocumentsClient:
|
|
98
140
|
offset: typing.Optional[int] = None,
|
99
141
|
ordering: typing.Optional[str] = None,
|
100
142
|
) -> PaginatedSlimDocumentList:
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
143
|
+
"""
|
144
|
+
|
145
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
146
|
+
|
147
|
+
Used to list documents. Optionally filter on supported fields.
|
148
|
+
|
149
|
+
Parameters:
|
150
|
+
- document_index_id: typing.Optional[str]. Filter down to only those documents that are included in the specified index. You may provide either the Vellum-generated ID or the unique name of the index specified upon initial creation.
|
151
|
+
|
152
|
+
- limit: typing.Optional[int]. Number of results to return per page.
|
153
|
+
|
154
|
+
- offset: typing.Optional[int]. The initial index from which to return the results.
|
155
|
+
|
156
|
+
- ordering: typing.Optional[str]. Which field to use when ordering the results.
|
157
|
+
"""
|
158
|
+
_response = await self._client_wrapper.httpx_client.request(
|
159
|
+
"GET",
|
160
|
+
urllib.parse.urljoin(f"{self._environment.default}/", "v1/documents"),
|
161
|
+
params=remove_none_from_dict(
|
162
|
+
{"document_index_id": document_index_id, "limit": limit, "offset": offset, "ordering": ordering}
|
163
|
+
),
|
164
|
+
headers=self._client_wrapper.get_headers(),
|
165
|
+
timeout=None,
|
166
|
+
)
|
109
167
|
if 200 <= _response.status_code < 300:
|
110
168
|
return pydantic.parse_obj_as(PaginatedSlimDocumentList, _response.json()) # type: ignore
|
111
169
|
try:
|
@@ -123,22 +181,39 @@ class AsyncDocumentsClient:
|
|
123
181
|
contents: typing.IO,
|
124
182
|
keywords: typing.Optional[typing.List[str]] = None,
|
125
183
|
) -> UploadDocumentResponse:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
184
|
+
"""
|
185
|
+
<strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
186
|
+
|
187
|
+
Upload a document to be indexed and used for search.
|
188
|
+
|
189
|
+
**Note:** Uses a base url of `https://documents.vellum.ai`.
|
190
|
+
|
191
|
+
Parameters:
|
192
|
+
- add_to_index_names: typing.Optional[typing.List[str]].
|
193
|
+
|
194
|
+
- external_id: typing.Optional[str].
|
195
|
+
|
196
|
+
- label: str.
|
197
|
+
|
198
|
+
- contents: typing.IO.
|
199
|
+
|
200
|
+
- keywords: typing.Optional[typing.List[str]].
|
201
|
+
"""
|
202
|
+
_response = await self._client_wrapper.httpx_client.request(
|
203
|
+
"POST",
|
204
|
+
urllib.parse.urljoin(f"{self._environment.documents}/", "v1/upload-document"),
|
205
|
+
data=jsonable_encoder(
|
206
|
+
{
|
207
|
+
"add_to_index_names": add_to_index_names,
|
208
|
+
"external_id": external_id,
|
209
|
+
"label": label,
|
210
|
+
"keywords": keywords,
|
211
|
+
}
|
212
|
+
),
|
213
|
+
files={"contents": contents},
|
214
|
+
headers=self._client_wrapper.get_headers(),
|
215
|
+
timeout=None,
|
216
|
+
)
|
142
217
|
if 200 <= _response.status_code < 300:
|
143
218
|
return pydantic.parse_obj_as(UploadDocumentResponse, _response.json()) # type: ignore
|
144
219
|
if _response.status_code == 400:
|
@@ -4,27 +4,40 @@ import typing
|
|
4
4
|
import urllib.parse
|
5
5
|
from json.decoder import JSONDecodeError
|
6
6
|
|
7
|
-
import httpx
|
8
7
|
import pydantic
|
9
8
|
|
10
9
|
from ...core.api_error import ApiError
|
10
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
11
11
|
from ...core.jsonable_encoder import jsonable_encoder
|
12
|
-
from ...core.remove_none_from_headers import remove_none_from_headers
|
13
12
|
from ...environment import VellumEnvironment
|
14
13
|
from ...types.model_version_compile_prompt_response import ModelVersionCompilePromptResponse
|
15
14
|
from ...types.model_version_read import ModelVersionRead
|
16
15
|
|
16
|
+
# this is used as the default value for optional parameters
|
17
|
+
OMIT = typing.cast(typing.Any, ...)
|
18
|
+
|
17
19
|
|
18
20
|
class ModelVersionsClient:
|
19
|
-
def __init__(
|
21
|
+
def __init__(
|
22
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
|
23
|
+
):
|
20
24
|
self._environment = environment
|
21
|
-
self.
|
25
|
+
self._client_wrapper = client_wrapper
|
22
26
|
|
23
27
|
def retrieve(self, id: str) -> ModelVersionRead:
|
24
|
-
|
28
|
+
"""
|
29
|
+
|
30
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
31
|
+
|
32
|
+
Used to retrieve a model version given its ID.
|
33
|
+
|
34
|
+
Parameters:
|
35
|
+
- id: str. A UUID string identifying this model version.
|
36
|
+
"""
|
37
|
+
_response = self._client_wrapper.httpx_client.request(
|
25
38
|
"GET",
|
26
39
|
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}"),
|
27
|
-
headers=
|
40
|
+
headers=self._client_wrapper.get_headers(),
|
28
41
|
timeout=None,
|
29
42
|
)
|
30
43
|
if 200 <= _response.status_code < 300:
|
@@ -38,11 +51,21 @@ class ModelVersionsClient:
|
|
38
51
|
def model_version_compile_prompt(
|
39
52
|
self, id: str, *, input_values: typing.Dict[str, typing.Any]
|
40
53
|
) -> ModelVersionCompilePromptResponse:
|
41
|
-
|
54
|
+
"""
|
55
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
56
|
+
|
57
|
+
Compiles the prompt backing the model version using the provided input values.
|
58
|
+
|
59
|
+
Parameters:
|
60
|
+
- id: str. A UUID string identifying this model version.
|
61
|
+
|
62
|
+
- input_values: typing.Dict[str, typing.Any]. Key/value pairs for each variable found within the model version's prompt template.
|
63
|
+
"""
|
64
|
+
_response = self._client_wrapper.httpx_client.request(
|
42
65
|
"POST",
|
43
66
|
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}/compile-prompt"),
|
44
67
|
json=jsonable_encoder({"input_values": input_values}),
|
45
|
-
headers=
|
68
|
+
headers=self._client_wrapper.get_headers(),
|
46
69
|
timeout=None,
|
47
70
|
)
|
48
71
|
if 200 <= _response.status_code < 300:
|
@@ -55,18 +78,28 @@ class ModelVersionsClient:
|
|
55
78
|
|
56
79
|
|
57
80
|
class AsyncModelVersionsClient:
|
58
|
-
def __init__(
|
81
|
+
def __init__(
|
82
|
+
self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
|
83
|
+
):
|
59
84
|
self._environment = environment
|
60
|
-
self.
|
85
|
+
self._client_wrapper = client_wrapper
|
61
86
|
|
62
87
|
async def retrieve(self, id: str) -> ModelVersionRead:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
88
|
+
"""
|
89
|
+
|
90
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
91
|
+
|
92
|
+
Used to retrieve a model version given its ID.
|
93
|
+
|
94
|
+
Parameters:
|
95
|
+
- id: str. A UUID string identifying this model version.
|
96
|
+
"""
|
97
|
+
_response = await self._client_wrapper.httpx_client.request(
|
98
|
+
"GET",
|
99
|
+
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}"),
|
100
|
+
headers=self._client_wrapper.get_headers(),
|
101
|
+
timeout=None,
|
102
|
+
)
|
70
103
|
if 200 <= _response.status_code < 300:
|
71
104
|
return pydantic.parse_obj_as(ModelVersionRead, _response.json()) # type: ignore
|
72
105
|
try:
|
@@ -78,14 +111,23 @@ class AsyncModelVersionsClient:
|
|
78
111
|
async def model_version_compile_prompt(
|
79
112
|
self, id: str, *, input_values: typing.Dict[str, typing.Any]
|
80
113
|
) -> ModelVersionCompilePromptResponse:
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
114
|
+
"""
|
115
|
+
<strong style="background-color:#ffc107; color:white; padding:4px; border-radius:4px">Unstable</strong>
|
116
|
+
|
117
|
+
Compiles the prompt backing the model version using the provided input values.
|
118
|
+
|
119
|
+
Parameters:
|
120
|
+
- id: str. A UUID string identifying this model version.
|
121
|
+
|
122
|
+
- input_values: typing.Dict[str, typing.Any]. Key/value pairs for each variable found within the model version's prompt template.
|
123
|
+
"""
|
124
|
+
_response = await self._client_wrapper.httpx_client.request(
|
125
|
+
"POST",
|
126
|
+
urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}/compile-prompt"),
|
127
|
+
json=jsonable_encoder({"input_values": input_values}),
|
128
|
+
headers=self._client_wrapper.get_headers(),
|
129
|
+
timeout=None,
|
130
|
+
)
|
89
131
|
if 200 <= _response.status_code < 300:
|
90
132
|
return pydantic.parse_obj_as(ModelVersionCompilePromptResponse, _response.json()) # type: ignore
|
91
133
|
try:
|