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.
Files changed (84) hide show
  1. vellum/__init__.py +38 -20
  2. vellum/client.py +278 -101
  3. vellum/core/__init__.py +11 -2
  4. vellum/core/client_wrapper.py +27 -0
  5. vellum/core/remove_none_from_dict.py +11 -0
  6. vellum/resources/deployments/client.py +35 -15
  7. vellum/resources/document_indexes/client.py +64 -16
  8. vellum/resources/documents/client.py +110 -35
  9. vellum/resources/model_versions/client.py +67 -25
  10. vellum/resources/registered_prompts/client.py +80 -16
  11. vellum/resources/sandboxes/client.py +90 -25
  12. vellum/resources/test_suites/client.py +90 -25
  13. vellum/types/__init__.py +24 -4
  14. vellum/types/deployment_read.py +2 -6
  15. vellum/types/document.py +3 -7
  16. vellum/types/document_document_to_document_index.py +2 -2
  17. vellum/types/document_index_read.py +3 -7
  18. vellum/types/enriched_normalized_completion.py +5 -9
  19. vellum/types/evaluation_params.py +1 -3
  20. vellum/types/evaluation_params_request.py +1 -3
  21. vellum/types/execute_workflow_stream_error_response.py +24 -0
  22. vellum/types/generate_error_response.py +1 -1
  23. vellum/types/generate_request.py +3 -7
  24. vellum/types/generate_result.py +2 -6
  25. vellum/types/generate_result_data.py +1 -1
  26. vellum/types/generate_result_error.py +1 -1
  27. vellum/types/model_version_build_config.py +2 -6
  28. vellum/types/model_version_compile_prompt_response.py +1 -1
  29. vellum/types/model_version_compiled_prompt.py +2 -4
  30. vellum/types/model_version_exec_config.py +3 -3
  31. vellum/types/model_version_read.py +7 -10
  32. vellum/types/model_version_sandbox_snapshot.py +3 -5
  33. vellum/types/prompt_template_block_properties.py +1 -0
  34. vellum/types/prompt_template_block_properties_request.py +3 -2
  35. vellum/types/prompt_template_block_request.py +1 -1
  36. vellum/types/prompt_template_input_variable.py +1 -1
  37. vellum/types/prompt_template_input_variable_request.py +1 -1
  38. vellum/types/provider_enum.py +5 -0
  39. vellum/types/register_prompt_error_response.py +1 -1
  40. vellum/types/register_prompt_prompt.py +2 -2
  41. vellum/types/register_prompt_prompt_info_request.py +1 -1
  42. vellum/types/register_prompt_response.py +5 -7
  43. vellum/types/registered_prompt_deployment.py +3 -3
  44. vellum/types/registered_prompt_model_version.py +2 -2
  45. vellum/types/registered_prompt_sandbox.py +2 -2
  46. vellum/types/registered_prompt_sandbox_snapshot.py +1 -1
  47. vellum/types/sandbox_scenario.py +2 -2
  48. vellum/types/scenario_input_request.py +1 -1
  49. vellum/types/search_error_response.py +1 -1
  50. vellum/types/search_filters_request.py +1 -1
  51. vellum/types/search_request_options_request.py +4 -6
  52. vellum/types/search_response.py +1 -1
  53. vellum/types/search_result.py +3 -3
  54. vellum/types/search_result_merging_request.py +1 -1
  55. vellum/types/search_weights_request.py +2 -2
  56. vellum/types/slim_document.py +5 -9
  57. vellum/types/submit_completion_actual_request.py +5 -15
  58. vellum/types/terminal_node_chat_history_result.py +1 -1
  59. vellum/types/terminal_node_json_result.py +1 -1
  60. vellum/types/terminal_node_result_output.py +2 -4
  61. vellum/types/terminal_node_string_result.py +1 -1
  62. vellum/types/test_suite_test_case.py +4 -8
  63. vellum/types/upload_document_response.py +1 -1
  64. vellum/types/workflow_event_error.py +26 -0
  65. vellum/types/workflow_execution_event_error_code.py +31 -0
  66. vellum/types/workflow_node_result_data.py +7 -11
  67. vellum/types/workflow_node_result_event.py +4 -3
  68. vellum/types/{workflow_node_result_event_state_enum.py → workflow_node_result_event_state.py} +5 -5
  69. vellum/types/workflow_request_chat_history_input_request.py +1 -3
  70. vellum/types/workflow_request_input_request.py +2 -6
  71. vellum/types/workflow_request_json_input_request.py +1 -3
  72. vellum/types/workflow_request_string_input_request.py +1 -3
  73. vellum/types/workflow_result_event.py +6 -3
  74. vellum/types/workflow_result_event_output_data.py +40 -0
  75. vellum/types/workflow_result_event_output_data_chat_history.py +32 -0
  76. vellum/types/workflow_result_event_output_data_json.py +31 -0
  77. vellum/types/workflow_result_event_output_data_string.py +33 -0
  78. vellum/types/workflow_stream_event.py +1 -4
  79. {vellum_ai-0.0.20.dist-info → vellum_ai-0.0.25.dist-info}/METADATA +1 -1
  80. vellum_ai-0.0.25.dist-info/RECORD +149 -0
  81. vellum/core/remove_none_from_headers.py +0 -11
  82. vellum/types/workflow_result_event_state_enum.py +0 -31
  83. vellum_ai-0.0.20.dist-info/RECORD +0 -142
  84. {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.remove_none_from_headers import remove_none_from_headers
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
15
+ def __init__(
16
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
17
+ ):
17
18
  self._environment = environment
18
- self.api_key = api_key
19
+ self._client_wrapper = client_wrapper
19
20
 
20
21
  def retrieve(self, id: str) -> DeploymentRead:
21
- _response = httpx.request(
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=remove_none_from_headers({"X_API_KEY": self.api_key}),
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
47
+ def __init__(
48
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
49
+ ):
38
50
  self._environment = environment
39
- self.api_key = api_key
51
+ self._client_wrapper = client_wrapper
40
52
 
41
53
  async def retrieve(self, id: str) -> DeploymentRead:
42
- async with httpx.AsyncClient() as _client:
43
- _response = await _client.request(
44
- "GET",
45
- urllib.parse.urljoin(f"{self._environment.default}/", f"v1/deployments/{id}"),
46
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
47
- timeout=None,
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
22
+ def __init__(
23
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
24
+ ):
24
25
  self._environment = environment
25
- self.api_key = api_key
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 = httpx.request(
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=remove_none_from_headers({"X_API_KEY": self.api_key}),
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
85
+ def __init__(
86
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
87
+ ):
62
88
  self._environment = environment
63
- self.api_key = api_key
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
- async with httpx.AsyncClient() as _client:
83
- _response = await _client.request(
84
- "POST",
85
- urllib.parse.urljoin(f"{self._environment.default}/", "v1/document-indexes"),
86
- json=jsonable_encoder(_request),
87
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
88
- timeout=None,
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.remove_none_from_headers import remove_none_from_headers
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
25
+ def __init__(
26
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
27
+ ):
23
28
  self._environment = environment
24
- self.api_key = api_key
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
- _response = httpx.request(
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={"document_index_id": document_index_id, "limit": limit, "offset": offset, "ordering": ordering},
38
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
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
- _response = httpx.request(
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=remove_none_from_headers({"X_API_KEY": self.api_key}),
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
129
+ def __init__(
130
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
131
+ ):
90
132
  self._environment = environment
91
- self.api_key = api_key
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
- async with httpx.AsyncClient() as _client:
102
- _response = await _client.request(
103
- "GET",
104
- urllib.parse.urljoin(f"{self._environment.default}/", "v1/documents"),
105
- params={"document_index_id": document_index_id, "limit": limit, "offset": offset, "ordering": ordering},
106
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
107
- timeout=None,
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
- async with httpx.AsyncClient() as _client:
127
- _response = await _client.request(
128
- "POST",
129
- urllib.parse.urljoin(f"{self._environment.documents}/", "v1/upload-document"),
130
- data=jsonable_encoder(
131
- {
132
- "add_to_index_names": add_to_index_names,
133
- "external_id": external_id,
134
- "label": label,
135
- "keywords": keywords,
136
- }
137
- ),
138
- files={"contents": contents},
139
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
140
- timeout=None,
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
21
+ def __init__(
22
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: SyncClientWrapper
23
+ ):
20
24
  self._environment = environment
21
- self.api_key = api_key
25
+ self._client_wrapper = client_wrapper
22
26
 
23
27
  def retrieve(self, id: str) -> ModelVersionRead:
24
- _response = httpx.request(
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=remove_none_from_headers({"X_API_KEY": self.api_key}),
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
- _response = httpx.request(
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=remove_none_from_headers({"X_API_KEY": self.api_key}),
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__(self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, api_key: str):
81
+ def __init__(
82
+ self, *, environment: VellumEnvironment = VellumEnvironment.PRODUCTION, client_wrapper: AsyncClientWrapper
83
+ ):
59
84
  self._environment = environment
60
- self.api_key = api_key
85
+ self._client_wrapper = client_wrapper
61
86
 
62
87
  async def retrieve(self, id: str) -> ModelVersionRead:
63
- async with httpx.AsyncClient() as _client:
64
- _response = await _client.request(
65
- "GET",
66
- urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}"),
67
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
68
- timeout=None,
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
- async with httpx.AsyncClient() as _client:
82
- _response = await _client.request(
83
- "POST",
84
- urllib.parse.urljoin(f"{self._environment.default}/", f"v1/model-versions/{id}/compile-prompt"),
85
- json=jsonable_encoder({"input_values": input_values}),
86
- headers=remove_none_from_headers({"X_API_KEY": self.api_key}),
87
- timeout=None,
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: