lightningrod-ai 0.1.6__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.
- lightningrod/__init__.py +66 -0
- lightningrod/_display.py +204 -0
- lightningrod/_errors.py +67 -0
- lightningrod/_generated/__init__.py +8 -0
- lightningrod/_generated/api/__init__.py +1 -0
- lightningrod/_generated/api/datasets/__init__.py +1 -0
- lightningrod/_generated/api/datasets/create_dataset_datasets_post.py +133 -0
- lightningrod/_generated/api/datasets/get_dataset_datasets_dataset_id_get.py +168 -0
- lightningrod/_generated/api/datasets/get_dataset_samples_datasets_dataset_id_samples_get.py +209 -0
- lightningrod/_generated/api/datasets/upload_samples_datasets_dataset_id_samples_post.py +190 -0
- lightningrod/_generated/api/file_sets/__init__.py +1 -0
- lightningrod/_generated/api/file_sets/add_file_to_set_filesets_file_set_id_files_post.py +190 -0
- lightningrod/_generated/api/file_sets/create_file_set_filesets_post.py +174 -0
- lightningrod/_generated/api/file_sets/get_file_set_filesets_file_set_id_get.py +168 -0
- lightningrod/_generated/api/file_sets/list_file_sets_filesets_get.py +173 -0
- lightningrod/_generated/api/file_sets/list_files_in_set_filesets_file_set_id_files_get.py +209 -0
- lightningrod/_generated/api/files/__init__.py +1 -0
- lightningrod/_generated/api/files/create_file_upload_files_post.py +174 -0
- lightningrod/_generated/api/open_ai_compatible/__init__.py +1 -0
- lightningrod/_generated/api/open_ai_compatible/chat_completions_openai_chat_completions_post.py +174 -0
- lightningrod/_generated/api/organizations/__init__.py +1 -0
- lightningrod/_generated/api/organizations/get_balance_organizations_balance_get.py +131 -0
- lightningrod/_generated/api/samples/__init__.py +1 -0
- lightningrod/_generated/api/samples/validate_sample_samples_validate_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/__init__.py +1 -0
- lightningrod/_generated/api/transform_jobs/cost_estimation_transform_jobs_cost_estimation_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/create_transform_job_transform_jobs_post.py +174 -0
- lightningrod/_generated/api/transform_jobs/get_transform_job_metrics_transform_jobs_job_id_metrics_get.py +172 -0
- lightningrod/_generated/api/transform_jobs/get_transform_job_transform_jobs_job_id_get.py +168 -0
- lightningrod/_generated/client.py +268 -0
- lightningrod/_generated/errors.py +16 -0
- lightningrod/_generated/models/__init__.py +147 -0
- lightningrod/_generated/models/answer_type.py +129 -0
- lightningrod/_generated/models/answer_type_enum.py +11 -0
- lightningrod/_generated/models/balance_response.py +61 -0
- lightningrod/_generated/models/chat_completion_request.py +216 -0
- lightningrod/_generated/models/chat_completion_response.py +146 -0
- lightningrod/_generated/models/chat_message.py +69 -0
- lightningrod/_generated/models/choice.py +97 -0
- lightningrod/_generated/models/create_dataset_response.py +61 -0
- lightningrod/_generated/models/create_file_set_file_request.py +101 -0
- lightningrod/_generated/models/create_file_set_file_request_metadata_type_0.py +46 -0
- lightningrod/_generated/models/create_file_set_request.py +83 -0
- lightningrod/_generated/models/create_file_upload_request.py +91 -0
- lightningrod/_generated/models/create_file_upload_response.py +165 -0
- lightningrod/_generated/models/create_file_upload_response_metadata_type_0.py +46 -0
- lightningrod/_generated/models/create_transform_job_request.py +312 -0
- lightningrod/_generated/models/dataset_metadata.py +69 -0
- lightningrod/_generated/models/estimate_cost_request.py +243 -0
- lightningrod/_generated/models/estimate_cost_response.py +117 -0
- lightningrod/_generated/models/event_usage_summary.py +80 -0
- lightningrod/_generated/models/file_set.py +128 -0
- lightningrod/_generated/models/file_set_file.py +203 -0
- lightningrod/_generated/models/file_set_file_metadata_type_0.py +57 -0
- lightningrod/_generated/models/file_set_query_seed_generator.py +136 -0
- lightningrod/_generated/models/file_set_seed_generator.py +126 -0
- lightningrod/_generated/models/filter_criteria.py +83 -0
- lightningrod/_generated/models/forward_looking_question.py +130 -0
- lightningrod/_generated/models/forward_looking_question_generator.py +217 -0
- lightningrod/_generated/models/gdelt_seed_generator.py +103 -0
- lightningrod/_generated/models/http_validation_error.py +79 -0
- lightningrod/_generated/models/job_usage.py +185 -0
- lightningrod/_generated/models/job_usage_by_step_type_0.py +59 -0
- lightningrod/_generated/models/label.py +143 -0
- lightningrod/_generated/models/list_file_set_files_response.py +113 -0
- lightningrod/_generated/models/list_file_sets_response.py +75 -0
- lightningrod/_generated/models/llm_model_usage_summary.py +98 -0
- lightningrod/_generated/models/mock_transform_config.py +243 -0
- lightningrod/_generated/models/mock_transform_config_metadata_additions.py +46 -0
- lightningrod/_generated/models/model_config.py +316 -0
- lightningrod/_generated/models/model_source_type.py +16 -0
- lightningrod/_generated/models/news_context.py +82 -0
- lightningrod/_generated/models/news_context_generator.py +127 -0
- lightningrod/_generated/models/news_seed_generator.py +220 -0
- lightningrod/_generated/models/paginated_samples_response.py +113 -0
- lightningrod/_generated/models/pipeline_metrics_response.py +99 -0
- lightningrod/_generated/models/question.py +74 -0
- lightningrod/_generated/models/question_and_label_generator.py +217 -0
- lightningrod/_generated/models/question_generator.py +217 -0
- lightningrod/_generated/models/question_pipeline.py +417 -0
- lightningrod/_generated/models/question_renderer.py +123 -0
- lightningrod/_generated/models/rag_context.py +82 -0
- lightningrod/_generated/models/response_message.py +69 -0
- lightningrod/_generated/models/rollout.py +130 -0
- lightningrod/_generated/models/rollout_generator.py +139 -0
- lightningrod/_generated/models/rollout_parsed_output_type_0.py +46 -0
- lightningrod/_generated/models/sample.py +323 -0
- lightningrod/_generated/models/sample_meta.py +46 -0
- lightningrod/_generated/models/seed.py +135 -0
- lightningrod/_generated/models/step_cost_breakdown.py +109 -0
- lightningrod/_generated/models/transform_job.py +268 -0
- lightningrod/_generated/models/transform_job_status.py +11 -0
- lightningrod/_generated/models/transform_step_metrics_response.py +131 -0
- lightningrod/_generated/models/transform_type.py +25 -0
- lightningrod/_generated/models/upload_samples_request.py +75 -0
- lightningrod/_generated/models/upload_samples_response.py +69 -0
- lightningrod/_generated/models/usage.py +77 -0
- lightningrod/_generated/models/usage_summary.py +102 -0
- lightningrod/_generated/models/usage_summary_events.py +59 -0
- lightningrod/_generated/models/usage_summary_llm_by_model.py +59 -0
- lightningrod/_generated/models/validate_sample_response.py +69 -0
- lightningrod/_generated/models/validation_error.py +90 -0
- lightningrod/_generated/models/web_search_labeler.py +120 -0
- lightningrod/_generated/py.typed +1 -0
- lightningrod/_generated/types.py +54 -0
- lightningrod/client.py +48 -0
- lightningrod/datasets/__init__.py +4 -0
- lightningrod/datasets/client.py +174 -0
- lightningrod/datasets/dataset.py +255 -0
- lightningrod/files/__init__.py +0 -0
- lightningrod/files/client.py +58 -0
- lightningrod/filesets/__init__.py +0 -0
- lightningrod/filesets/client.py +106 -0
- lightningrod/organization/__init__.py +0 -0
- lightningrod/organization/client.py +17 -0
- lightningrod/py.typed +0 -0
- lightningrod/transforms/__init__.py +0 -0
- lightningrod/transforms/client.py +154 -0
- lightningrod_ai-0.1.6.dist-info/METADATA +122 -0
- lightningrod_ai-0.1.6.dist-info/RECORD +123 -0
- lightningrod_ai-0.1.6.dist-info/WHEEL +5 -0
- lightningrod_ai-0.1.6.dist-info/licenses/LICENSE +23 -0
- lightningrod_ai-0.1.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from attrs import define, evolve, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@define
|
|
9
|
+
class Client:
|
|
10
|
+
"""A class for keeping track of data related to the API
|
|
11
|
+
|
|
12
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
13
|
+
|
|
14
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
15
|
+
|
|
16
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
17
|
+
|
|
18
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
19
|
+
|
|
20
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
21
|
+
httpx.TimeoutException if this is exceeded.
|
|
22
|
+
|
|
23
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
24
|
+
but can be set to False for testing purposes.
|
|
25
|
+
|
|
26
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
27
|
+
|
|
28
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
33
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
34
|
+
argument to the constructor.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
38
|
+
_base_url: str = field(alias="base_url")
|
|
39
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
40
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
41
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
42
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
|
|
43
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
44
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
45
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
46
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
47
|
+
|
|
48
|
+
def with_headers(self, headers: dict[str, str]) -> "Client":
|
|
49
|
+
"""Get a new client matching this one with additional headers"""
|
|
50
|
+
if self._client is not None:
|
|
51
|
+
self._client.headers.update(headers)
|
|
52
|
+
if self._async_client is not None:
|
|
53
|
+
self._async_client.headers.update(headers)
|
|
54
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
55
|
+
|
|
56
|
+
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
|
57
|
+
"""Get a new client matching this one with additional cookies"""
|
|
58
|
+
if self._client is not None:
|
|
59
|
+
self._client.cookies.update(cookies)
|
|
60
|
+
if self._async_client is not None:
|
|
61
|
+
self._async_client.cookies.update(cookies)
|
|
62
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
63
|
+
|
|
64
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
|
65
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
66
|
+
if self._client is not None:
|
|
67
|
+
self._client.timeout = timeout
|
|
68
|
+
if self._async_client is not None:
|
|
69
|
+
self._async_client.timeout = timeout
|
|
70
|
+
return evolve(self, timeout=timeout)
|
|
71
|
+
|
|
72
|
+
def set_httpx_client(self, client: httpx.Client) -> "Client":
|
|
73
|
+
"""Manually set the underlying httpx.Client
|
|
74
|
+
|
|
75
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
76
|
+
"""
|
|
77
|
+
self._client = client
|
|
78
|
+
return self
|
|
79
|
+
|
|
80
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
81
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
82
|
+
if self._client is None:
|
|
83
|
+
self._client = httpx.Client(
|
|
84
|
+
base_url=self._base_url,
|
|
85
|
+
cookies=self._cookies,
|
|
86
|
+
headers=self._headers,
|
|
87
|
+
timeout=self._timeout,
|
|
88
|
+
verify=self._verify_ssl,
|
|
89
|
+
follow_redirects=self._follow_redirects,
|
|
90
|
+
**self._httpx_args,
|
|
91
|
+
)
|
|
92
|
+
return self._client
|
|
93
|
+
|
|
94
|
+
def __enter__(self) -> "Client":
|
|
95
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
96
|
+
self.get_httpx_client().__enter__()
|
|
97
|
+
return self
|
|
98
|
+
|
|
99
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
100
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
101
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
102
|
+
|
|
103
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
|
|
104
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
105
|
+
|
|
106
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
107
|
+
"""
|
|
108
|
+
self._async_client = async_client
|
|
109
|
+
return self
|
|
110
|
+
|
|
111
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
112
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
113
|
+
if self._async_client is None:
|
|
114
|
+
self._async_client = httpx.AsyncClient(
|
|
115
|
+
base_url=self._base_url,
|
|
116
|
+
cookies=self._cookies,
|
|
117
|
+
headers=self._headers,
|
|
118
|
+
timeout=self._timeout,
|
|
119
|
+
verify=self._verify_ssl,
|
|
120
|
+
follow_redirects=self._follow_redirects,
|
|
121
|
+
**self._httpx_args,
|
|
122
|
+
)
|
|
123
|
+
return self._async_client
|
|
124
|
+
|
|
125
|
+
async def __aenter__(self) -> "Client":
|
|
126
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
127
|
+
await self.get_async_httpx_client().__aenter__()
|
|
128
|
+
return self
|
|
129
|
+
|
|
130
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
131
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
132
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@define
|
|
136
|
+
class AuthenticatedClient:
|
|
137
|
+
"""A Client which has been authenticated for use on secured endpoints
|
|
138
|
+
|
|
139
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
140
|
+
|
|
141
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
142
|
+
|
|
143
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
144
|
+
|
|
145
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
146
|
+
|
|
147
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
148
|
+
httpx.TimeoutException if this is exceeded.
|
|
149
|
+
|
|
150
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
151
|
+
but can be set to False for testing purposes.
|
|
152
|
+
|
|
153
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
154
|
+
|
|
155
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
Attributes:
|
|
159
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
160
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
161
|
+
argument to the constructor.
|
|
162
|
+
token: The token to use for authentication
|
|
163
|
+
prefix: The prefix to use for the Authorization header
|
|
164
|
+
auth_header_name: The name of the Authorization header
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
168
|
+
_base_url: str = field(alias="base_url")
|
|
169
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
170
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
171
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
172
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
|
|
173
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
174
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
175
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
176
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
177
|
+
|
|
178
|
+
token: str
|
|
179
|
+
prefix: str = "Bearer"
|
|
180
|
+
auth_header_name: str = "Authorization"
|
|
181
|
+
|
|
182
|
+
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
|
183
|
+
"""Get a new client matching this one with additional headers"""
|
|
184
|
+
if self._client is not None:
|
|
185
|
+
self._client.headers.update(headers)
|
|
186
|
+
if self._async_client is not None:
|
|
187
|
+
self._async_client.headers.update(headers)
|
|
188
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
189
|
+
|
|
190
|
+
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
|
191
|
+
"""Get a new client matching this one with additional cookies"""
|
|
192
|
+
if self._client is not None:
|
|
193
|
+
self._client.cookies.update(cookies)
|
|
194
|
+
if self._async_client is not None:
|
|
195
|
+
self._async_client.cookies.update(cookies)
|
|
196
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
197
|
+
|
|
198
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
|
199
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
200
|
+
if self._client is not None:
|
|
201
|
+
self._client.timeout = timeout
|
|
202
|
+
if self._async_client is not None:
|
|
203
|
+
self._async_client.timeout = timeout
|
|
204
|
+
return evolve(self, timeout=timeout)
|
|
205
|
+
|
|
206
|
+
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
|
|
207
|
+
"""Manually set the underlying httpx.Client
|
|
208
|
+
|
|
209
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
210
|
+
"""
|
|
211
|
+
self._client = client
|
|
212
|
+
return self
|
|
213
|
+
|
|
214
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
215
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
216
|
+
if self._client is None:
|
|
217
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
218
|
+
self._client = httpx.Client(
|
|
219
|
+
base_url=self._base_url,
|
|
220
|
+
cookies=self._cookies,
|
|
221
|
+
headers=self._headers,
|
|
222
|
+
timeout=self._timeout,
|
|
223
|
+
verify=self._verify_ssl,
|
|
224
|
+
follow_redirects=self._follow_redirects,
|
|
225
|
+
**self._httpx_args,
|
|
226
|
+
)
|
|
227
|
+
return self._client
|
|
228
|
+
|
|
229
|
+
def __enter__(self) -> "AuthenticatedClient":
|
|
230
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
231
|
+
self.get_httpx_client().__enter__()
|
|
232
|
+
return self
|
|
233
|
+
|
|
234
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
235
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
236
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
237
|
+
|
|
238
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
|
|
239
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
240
|
+
|
|
241
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
242
|
+
"""
|
|
243
|
+
self._async_client = async_client
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
247
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
248
|
+
if self._async_client is None:
|
|
249
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
250
|
+
self._async_client = httpx.AsyncClient(
|
|
251
|
+
base_url=self._base_url,
|
|
252
|
+
cookies=self._cookies,
|
|
253
|
+
headers=self._headers,
|
|
254
|
+
timeout=self._timeout,
|
|
255
|
+
verify=self._verify_ssl,
|
|
256
|
+
follow_redirects=self._follow_redirects,
|
|
257
|
+
**self._httpx_args,
|
|
258
|
+
)
|
|
259
|
+
return self._async_client
|
|
260
|
+
|
|
261
|
+
async def __aenter__(self) -> "AuthenticatedClient":
|
|
262
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
263
|
+
await self.get_async_httpx_client().__aenter__()
|
|
264
|
+
return self
|
|
265
|
+
|
|
266
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
267
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
268
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Contains shared errors types that can be raised from API functions"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnexpectedStatus(Exception):
|
|
5
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
6
|
+
|
|
7
|
+
def __init__(self, status_code: int, content: bytes):
|
|
8
|
+
self.status_code = status_code
|
|
9
|
+
self.content = content
|
|
10
|
+
|
|
11
|
+
super().__init__(
|
|
12
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""Contains all the data models used in inputs/outputs"""
|
|
2
|
+
|
|
3
|
+
from .answer_type import AnswerType
|
|
4
|
+
from .answer_type_enum import AnswerTypeEnum
|
|
5
|
+
from .balance_response import BalanceResponse
|
|
6
|
+
from .chat_completion_request import ChatCompletionRequest
|
|
7
|
+
from .chat_completion_response import ChatCompletionResponse
|
|
8
|
+
from .chat_message import ChatMessage
|
|
9
|
+
from .choice import Choice
|
|
10
|
+
from .create_dataset_response import CreateDatasetResponse
|
|
11
|
+
from .create_file_set_file_request import CreateFileSetFileRequest
|
|
12
|
+
from .create_file_set_file_request_metadata_type_0 import CreateFileSetFileRequestMetadataType0
|
|
13
|
+
from .create_file_set_request import CreateFileSetRequest
|
|
14
|
+
from .create_file_upload_request import CreateFileUploadRequest
|
|
15
|
+
from .create_file_upload_response import CreateFileUploadResponse
|
|
16
|
+
from .create_file_upload_response_metadata_type_0 import CreateFileUploadResponseMetadataType0
|
|
17
|
+
from .create_transform_job_request import CreateTransformJobRequest
|
|
18
|
+
from .dataset_metadata import DatasetMetadata
|
|
19
|
+
from .estimate_cost_request import EstimateCostRequest
|
|
20
|
+
from .estimate_cost_response import EstimateCostResponse
|
|
21
|
+
from .event_usage_summary import EventUsageSummary
|
|
22
|
+
from .file_set import FileSet
|
|
23
|
+
from .file_set_file import FileSetFile
|
|
24
|
+
from .file_set_file_metadata_type_0 import FileSetFileMetadataType0
|
|
25
|
+
from .file_set_query_seed_generator import FileSetQuerySeedGenerator
|
|
26
|
+
from .file_set_seed_generator import FileSetSeedGenerator
|
|
27
|
+
from .filter_criteria import FilterCriteria
|
|
28
|
+
from .forward_looking_question import ForwardLookingQuestion
|
|
29
|
+
from .forward_looking_question_generator import ForwardLookingQuestionGenerator
|
|
30
|
+
from .gdelt_seed_generator import GdeltSeedGenerator
|
|
31
|
+
from .http_validation_error import HTTPValidationError
|
|
32
|
+
from .job_usage import JobUsage
|
|
33
|
+
from .job_usage_by_step_type_0 import JobUsageByStepType0
|
|
34
|
+
from .label import Label
|
|
35
|
+
from .list_file_set_files_response import ListFileSetFilesResponse
|
|
36
|
+
from .list_file_sets_response import ListFileSetsResponse
|
|
37
|
+
from .llm_model_usage_summary import LLMModelUsageSummary
|
|
38
|
+
from .mock_transform_config import MockTransformConfig
|
|
39
|
+
from .mock_transform_config_metadata_additions import MockTransformConfigMetadataAdditions
|
|
40
|
+
from .model_config import ModelConfig
|
|
41
|
+
from .model_source_type import ModelSourceType
|
|
42
|
+
from .news_context import NewsContext
|
|
43
|
+
from .news_context_generator import NewsContextGenerator
|
|
44
|
+
from .news_seed_generator import NewsSeedGenerator
|
|
45
|
+
from .paginated_samples_response import PaginatedSamplesResponse
|
|
46
|
+
from .pipeline_metrics_response import PipelineMetricsResponse
|
|
47
|
+
from .question import Question
|
|
48
|
+
from .question_and_label_generator import QuestionAndLabelGenerator
|
|
49
|
+
from .question_generator import QuestionGenerator
|
|
50
|
+
from .question_pipeline import QuestionPipeline
|
|
51
|
+
from .question_renderer import QuestionRenderer
|
|
52
|
+
from .rag_context import RAGContext
|
|
53
|
+
from .response_message import ResponseMessage
|
|
54
|
+
from .rollout import Rollout
|
|
55
|
+
from .rollout_generator import RolloutGenerator
|
|
56
|
+
from .rollout_parsed_output_type_0 import RolloutParsedOutputType0
|
|
57
|
+
from .sample import Sample
|
|
58
|
+
from .sample_meta import SampleMeta
|
|
59
|
+
from .seed import Seed
|
|
60
|
+
from .step_cost_breakdown import StepCostBreakdown
|
|
61
|
+
from .transform_job import TransformJob
|
|
62
|
+
from .transform_job_status import TransformJobStatus
|
|
63
|
+
from .transform_step_metrics_response import TransformStepMetricsResponse
|
|
64
|
+
from .transform_type import TransformType
|
|
65
|
+
from .upload_samples_request import UploadSamplesRequest
|
|
66
|
+
from .upload_samples_response import UploadSamplesResponse
|
|
67
|
+
from .usage import Usage
|
|
68
|
+
from .usage_summary import UsageSummary
|
|
69
|
+
from .usage_summary_events import UsageSummaryEvents
|
|
70
|
+
from .usage_summary_llm_by_model import UsageSummaryLlmByModel
|
|
71
|
+
from .validate_sample_response import ValidateSampleResponse
|
|
72
|
+
from .validation_error import ValidationError
|
|
73
|
+
from .web_search_labeler import WebSearchLabeler
|
|
74
|
+
|
|
75
|
+
__all__ = (
|
|
76
|
+
"AnswerType",
|
|
77
|
+
"AnswerTypeEnum",
|
|
78
|
+
"BalanceResponse",
|
|
79
|
+
"ChatCompletionRequest",
|
|
80
|
+
"ChatCompletionResponse",
|
|
81
|
+
"ChatMessage",
|
|
82
|
+
"Choice",
|
|
83
|
+
"CreateDatasetResponse",
|
|
84
|
+
"CreateFileSetFileRequest",
|
|
85
|
+
"CreateFileSetFileRequestMetadataType0",
|
|
86
|
+
"CreateFileSetRequest",
|
|
87
|
+
"CreateFileUploadRequest",
|
|
88
|
+
"CreateFileUploadResponse",
|
|
89
|
+
"CreateFileUploadResponseMetadataType0",
|
|
90
|
+
"CreateTransformJobRequest",
|
|
91
|
+
"DatasetMetadata",
|
|
92
|
+
"EstimateCostRequest",
|
|
93
|
+
"EstimateCostResponse",
|
|
94
|
+
"EventUsageSummary",
|
|
95
|
+
"FileSet",
|
|
96
|
+
"FileSetFile",
|
|
97
|
+
"FileSetFileMetadataType0",
|
|
98
|
+
"FileSetQuerySeedGenerator",
|
|
99
|
+
"FileSetSeedGenerator",
|
|
100
|
+
"FilterCriteria",
|
|
101
|
+
"ForwardLookingQuestion",
|
|
102
|
+
"ForwardLookingQuestionGenerator",
|
|
103
|
+
"GdeltSeedGenerator",
|
|
104
|
+
"HTTPValidationError",
|
|
105
|
+
"JobUsage",
|
|
106
|
+
"JobUsageByStepType0",
|
|
107
|
+
"Label",
|
|
108
|
+
"ListFileSetFilesResponse",
|
|
109
|
+
"ListFileSetsResponse",
|
|
110
|
+
"LLMModelUsageSummary",
|
|
111
|
+
"MockTransformConfig",
|
|
112
|
+
"MockTransformConfigMetadataAdditions",
|
|
113
|
+
"ModelConfig",
|
|
114
|
+
"ModelSourceType",
|
|
115
|
+
"NewsContext",
|
|
116
|
+
"NewsContextGenerator",
|
|
117
|
+
"NewsSeedGenerator",
|
|
118
|
+
"PaginatedSamplesResponse",
|
|
119
|
+
"PipelineMetricsResponse",
|
|
120
|
+
"Question",
|
|
121
|
+
"QuestionAndLabelGenerator",
|
|
122
|
+
"QuestionGenerator",
|
|
123
|
+
"QuestionPipeline",
|
|
124
|
+
"QuestionRenderer",
|
|
125
|
+
"RAGContext",
|
|
126
|
+
"ResponseMessage",
|
|
127
|
+
"Rollout",
|
|
128
|
+
"RolloutGenerator",
|
|
129
|
+
"RolloutParsedOutputType0",
|
|
130
|
+
"Sample",
|
|
131
|
+
"SampleMeta",
|
|
132
|
+
"Seed",
|
|
133
|
+
"StepCostBreakdown",
|
|
134
|
+
"TransformJob",
|
|
135
|
+
"TransformJobStatus",
|
|
136
|
+
"TransformStepMetricsResponse",
|
|
137
|
+
"TransformType",
|
|
138
|
+
"UploadSamplesRequest",
|
|
139
|
+
"UploadSamplesResponse",
|
|
140
|
+
"Usage",
|
|
141
|
+
"UsageSummary",
|
|
142
|
+
"UsageSummaryEvents",
|
|
143
|
+
"UsageSummaryLlmByModel",
|
|
144
|
+
"ValidateSampleResponse",
|
|
145
|
+
"ValidationError",
|
|
146
|
+
"WebSearchLabeler",
|
|
147
|
+
)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
from ..models.answer_type_enum import AnswerTypeEnum
|
|
10
|
+
from ..types import UNSET, Unset
|
|
11
|
+
|
|
12
|
+
T = TypeVar("T", bound="AnswerType")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@_attrs_define
|
|
16
|
+
class AnswerType:
|
|
17
|
+
"""
|
|
18
|
+
Attributes:
|
|
19
|
+
answer_type (AnswerTypeEnum):
|
|
20
|
+
answer_format_instruction (None | str | Unset): Instructions describing how the answer should be formatted and
|
|
21
|
+
given. If not set, uses default based on answer_type.
|
|
22
|
+
labeler_instruction (None | str | Unset): Custom instructions for the labeler. If not set, uses default based on
|
|
23
|
+
answer_type.
|
|
24
|
+
question_generation_instruction (None | str | Unset): Custom instructions for generating questions of this type.
|
|
25
|
+
If not set, uses default based on answer_type.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
answer_type: AnswerTypeEnum
|
|
29
|
+
answer_format_instruction: None | str | Unset = UNSET
|
|
30
|
+
labeler_instruction: None | str | Unset = UNSET
|
|
31
|
+
question_generation_instruction: None | str | Unset = UNSET
|
|
32
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
33
|
+
|
|
34
|
+
def to_dict(self) -> dict[str, Any]:
|
|
35
|
+
answer_type = self.answer_type.value
|
|
36
|
+
|
|
37
|
+
answer_format_instruction: None | str | Unset
|
|
38
|
+
if isinstance(self.answer_format_instruction, Unset):
|
|
39
|
+
answer_format_instruction = UNSET
|
|
40
|
+
else:
|
|
41
|
+
answer_format_instruction = self.answer_format_instruction
|
|
42
|
+
|
|
43
|
+
labeler_instruction: None | str | Unset
|
|
44
|
+
if isinstance(self.labeler_instruction, Unset):
|
|
45
|
+
labeler_instruction = UNSET
|
|
46
|
+
else:
|
|
47
|
+
labeler_instruction = self.labeler_instruction
|
|
48
|
+
|
|
49
|
+
question_generation_instruction: None | str | Unset
|
|
50
|
+
if isinstance(self.question_generation_instruction, Unset):
|
|
51
|
+
question_generation_instruction = UNSET
|
|
52
|
+
else:
|
|
53
|
+
question_generation_instruction = self.question_generation_instruction
|
|
54
|
+
|
|
55
|
+
field_dict: dict[str, Any] = {}
|
|
56
|
+
field_dict.update(self.additional_properties)
|
|
57
|
+
field_dict.update(
|
|
58
|
+
{
|
|
59
|
+
"answer_type": answer_type,
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
if answer_format_instruction is not UNSET:
|
|
63
|
+
field_dict["answer_format_instruction"] = answer_format_instruction
|
|
64
|
+
if labeler_instruction is not UNSET:
|
|
65
|
+
field_dict["labeler_instruction"] = labeler_instruction
|
|
66
|
+
if question_generation_instruction is not UNSET:
|
|
67
|
+
field_dict["question_generation_instruction"] = question_generation_instruction
|
|
68
|
+
|
|
69
|
+
return field_dict
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
73
|
+
d = dict(src_dict)
|
|
74
|
+
answer_type = AnswerTypeEnum(d.pop("answer_type"))
|
|
75
|
+
|
|
76
|
+
def _parse_answer_format_instruction(data: object) -> None | str | Unset:
|
|
77
|
+
if data is None:
|
|
78
|
+
return data
|
|
79
|
+
if isinstance(data, Unset):
|
|
80
|
+
return data
|
|
81
|
+
return cast(None | str | Unset, data)
|
|
82
|
+
|
|
83
|
+
answer_format_instruction = _parse_answer_format_instruction(d.pop("answer_format_instruction", UNSET))
|
|
84
|
+
|
|
85
|
+
def _parse_labeler_instruction(data: object) -> None | str | Unset:
|
|
86
|
+
if data is None:
|
|
87
|
+
return data
|
|
88
|
+
if isinstance(data, Unset):
|
|
89
|
+
return data
|
|
90
|
+
return cast(None | str | Unset, data)
|
|
91
|
+
|
|
92
|
+
labeler_instruction = _parse_labeler_instruction(d.pop("labeler_instruction", UNSET))
|
|
93
|
+
|
|
94
|
+
def _parse_question_generation_instruction(data: object) -> None | str | Unset:
|
|
95
|
+
if data is None:
|
|
96
|
+
return data
|
|
97
|
+
if isinstance(data, Unset):
|
|
98
|
+
return data
|
|
99
|
+
return cast(None | str | Unset, data)
|
|
100
|
+
|
|
101
|
+
question_generation_instruction = _parse_question_generation_instruction(
|
|
102
|
+
d.pop("question_generation_instruction", UNSET)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
answer_type = cls(
|
|
106
|
+
answer_type=answer_type,
|
|
107
|
+
answer_format_instruction=answer_format_instruction,
|
|
108
|
+
labeler_instruction=labeler_instruction,
|
|
109
|
+
question_generation_instruction=question_generation_instruction,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
answer_type.additional_properties = d
|
|
113
|
+
return answer_type
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def additional_keys(self) -> list[str]:
|
|
117
|
+
return list(self.additional_properties.keys())
|
|
118
|
+
|
|
119
|
+
def __getitem__(self, key: str) -> Any:
|
|
120
|
+
return self.additional_properties[key]
|
|
121
|
+
|
|
122
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
123
|
+
self.additional_properties[key] = value
|
|
124
|
+
|
|
125
|
+
def __delitem__(self, key: str) -> None:
|
|
126
|
+
del self.additional_properties[key]
|
|
127
|
+
|
|
128
|
+
def __contains__(self, key: str) -> bool:
|
|
129
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any, TypeVar
|
|
5
|
+
|
|
6
|
+
from attrs import define as _attrs_define
|
|
7
|
+
from attrs import field as _attrs_field
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="BalanceResponse")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class BalanceResponse:
|
|
14
|
+
"""
|
|
15
|
+
Attributes:
|
|
16
|
+
balance_dollars (float):
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
balance_dollars: float
|
|
20
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
21
|
+
|
|
22
|
+
def to_dict(self) -> dict[str, Any]:
|
|
23
|
+
balance_dollars = self.balance_dollars
|
|
24
|
+
|
|
25
|
+
field_dict: dict[str, Any] = {}
|
|
26
|
+
field_dict.update(self.additional_properties)
|
|
27
|
+
field_dict.update(
|
|
28
|
+
{
|
|
29
|
+
"balance_dollars": balance_dollars,
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return field_dict
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
37
|
+
d = dict(src_dict)
|
|
38
|
+
balance_dollars = d.pop("balance_dollars")
|
|
39
|
+
|
|
40
|
+
balance_response = cls(
|
|
41
|
+
balance_dollars=balance_dollars,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
balance_response.additional_properties = d
|
|
45
|
+
return balance_response
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def additional_keys(self) -> list[str]:
|
|
49
|
+
return list(self.additional_properties.keys())
|
|
50
|
+
|
|
51
|
+
def __getitem__(self, key: str) -> Any:
|
|
52
|
+
return self.additional_properties[key]
|
|
53
|
+
|
|
54
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
55
|
+
self.additional_properties[key] = value
|
|
56
|
+
|
|
57
|
+
def __delitem__(self, key: str) -> None:
|
|
58
|
+
del self.additional_properties[key]
|
|
59
|
+
|
|
60
|
+
def __contains__(self, key: str) -> bool:
|
|
61
|
+
return key in self.additional_properties
|