groundx 2.0.15__py3-none-any.whl → 2.7.7__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.
- groundx/__init__.py +73 -21
- groundx/buckets/__init__.py +2 -0
- groundx/buckets/client.py +55 -388
- groundx/buckets/raw_client.py +628 -0
- groundx/client.py +22 -21
- groundx/core/__init__.py +5 -0
- groundx/core/api_error.py +13 -5
- groundx/core/client_wrapper.py +4 -3
- groundx/core/force_multipart.py +16 -0
- groundx/core/http_client.py +76 -32
- groundx/core/http_response.py +55 -0
- groundx/core/jsonable_encoder.py +0 -1
- groundx/core/pydantic_utilities.py +71 -112
- groundx/core/serialization.py +7 -3
- groundx/csv_splitter.py +64 -0
- groundx/customer/__init__.py +2 -0
- groundx/customer/client.py +31 -43
- groundx/customer/raw_client.py +91 -0
- groundx/documents/__init__.py +1 -2
- groundx/documents/client.py +455 -953
- groundx/documents/raw_client.py +1450 -0
- groundx/errors/__init__.py +2 -0
- groundx/errors/bad_request_error.py +4 -3
- groundx/errors/unauthorized_error.py +4 -3
- groundx/extract/__init__.py +48 -0
- groundx/extract/agents/__init__.py +7 -0
- groundx/extract/agents/agent.py +202 -0
- groundx/extract/classes/__init__.py +24 -0
- groundx/extract/classes/agent.py +23 -0
- groundx/extract/classes/api.py +15 -0
- groundx/extract/classes/document.py +338 -0
- groundx/extract/classes/field.py +88 -0
- groundx/extract/classes/groundx.py +147 -0
- groundx/extract/classes/prompt.py +36 -0
- groundx/extract/classes/test_document.py +109 -0
- groundx/extract/classes/test_field.py +43 -0
- groundx/extract/classes/test_groundx.py +223 -0
- groundx/extract/classes/test_prompt.py +68 -0
- groundx/extract/post_process/__init__.py +7 -0
- groundx/extract/post_process/post_process.py +33 -0
- groundx/extract/services/.DS_Store +0 -0
- groundx/extract/services/__init__.py +14 -0
- groundx/extract/services/csv.py +76 -0
- groundx/extract/services/logger.py +126 -0
- groundx/extract/services/logging_cfg.py +53 -0
- groundx/extract/services/ratelimit.py +104 -0
- groundx/extract/services/sheets_client.py +160 -0
- groundx/extract/services/status.py +197 -0
- groundx/extract/services/upload.py +68 -0
- groundx/extract/services/upload_minio.py +122 -0
- groundx/extract/services/upload_s3.py +91 -0
- groundx/extract/services/utility.py +52 -0
- groundx/extract/settings/__init__.py +15 -0
- groundx/extract/settings/settings.py +212 -0
- groundx/extract/settings/test_settings.py +512 -0
- groundx/extract/tasks/__init__.py +6 -0
- groundx/extract/tasks/utility.py +27 -0
- groundx/extract/utility/__init__.py +15 -0
- groundx/extract/utility/classes.py +193 -0
- groundx/extract/utility/test_utility.py +81 -0
- groundx/groups/__init__.py +2 -0
- groundx/groups/client.py +63 -550
- groundx/groups/raw_client.py +901 -0
- groundx/health/__init__.py +2 -0
- groundx/health/client.py +35 -101
- groundx/health/raw_client.py +193 -0
- groundx/ingest.py +771 -0
- groundx/search/__init__.py +2 -0
- groundx/search/client.py +94 -227
- groundx/search/raw_client.py +442 -0
- groundx/search/types/__init__.py +2 -0
- groundx/types/__init__.py +68 -16
- groundx/types/bounding_box_detail.py +4 -4
- groundx/types/bucket_detail.py +5 -5
- groundx/types/bucket_list_response.py +17 -3
- groundx/types/bucket_response.py +3 -3
- groundx/types/bucket_update_detail.py +4 -4
- groundx/types/bucket_update_response.py +3 -3
- groundx/types/customer_detail.py +2 -2
- groundx/types/customer_response.py +3 -3
- groundx/types/document.py +54 -0
- groundx/types/document_detail.py +16 -4
- groundx/types/document_list_response.py +4 -4
- groundx/types/document_local_ingest_request.py +7 -0
- groundx/types/document_lookup_response.py +8 -3
- groundx/types/document_response.py +3 -3
- groundx/types/document_type.py +21 -1
- groundx/types/group_detail.py +4 -4
- groundx/types/group_list_response.py +17 -3
- groundx/types/group_response.py +3 -3
- groundx/types/health_response.py +3 -3
- groundx/types/health_response_health.py +3 -3
- groundx/types/health_service.py +5 -5
- groundx/types/ingest_local_document.py +25 -0
- groundx/types/ingest_local_document_metadata.py +51 -0
- groundx/types/ingest_remote_document.py +15 -6
- groundx/types/ingest_response.py +4 -4
- groundx/types/{process_status_response_ingest.py → ingest_status.py} +8 -7
- groundx/types/{ingest_response_ingest.py → ingest_status_light.py} +7 -5
- groundx/types/ingest_status_progress.py +26 -0
- groundx/types/{process_status_response_ingest_progress_errors.py → ingest_status_progress_cancelled.py} +4 -4
- groundx/types/{process_status_response_ingest_progress_complete.py → ingest_status_progress_complete.py} +4 -4
- groundx/types/{process_status_response_ingest_progress_cancelled.py → ingest_status_progress_errors.py} +4 -4
- groundx/types/{process_status_response_ingest_progress_processing.py → ingest_status_progress_processing.py} +4 -4
- groundx/types/message_response.py +2 -2
- groundx/types/meter_detail.py +2 -2
- groundx/types/process_level.py +5 -0
- groundx/types/{process_status_response.py → processes_status_response.py} +8 -5
- groundx/types/processing_status.py +3 -1
- groundx/types/search_response.py +3 -3
- groundx/types/search_response_search.py +3 -3
- groundx/types/search_result_item.py +7 -5
- groundx/types/search_result_item_pages_item.py +41 -0
- groundx/types/subscription_detail.py +3 -3
- groundx/types/subscription_detail_meters.py +5 -5
- groundx/{documents/types/website_crawl_request_websites_item.py → types/website_source.py} +7 -7
- groundx/types/workflow_apply_request.py +24 -0
- groundx/types/workflow_detail.py +59 -0
- groundx/types/workflow_detail_chunk_strategy.py +5 -0
- groundx/types/workflow_detail_relationships.py +36 -0
- groundx/types/workflow_engine.py +58 -0
- groundx/types/workflow_engine_reasoning_effort.py +5 -0
- groundx/types/workflow_engine_service.py +7 -0
- groundx/types/workflow_prompt.py +37 -0
- groundx/types/workflow_prompt_group.py +25 -0
- groundx/types/workflow_prompt_role.py +5 -0
- groundx/types/workflow_request.py +31 -0
- groundx/types/workflow_request_chunk_strategy.py +5 -0
- groundx/types/workflow_response.py +20 -0
- groundx/types/workflow_step.py +33 -0
- groundx/types/workflow_step_config.py +33 -0
- groundx/types/workflow_step_config_field.py +8 -0
- groundx/types/workflow_steps.py +38 -0
- groundx/types/workflows_response.py +20 -0
- groundx/workflows/__init__.py +7 -0
- groundx/workflows/client.py +736 -0
- groundx/workflows/raw_client.py +841 -0
- groundx/workflows/types/__init__.py +7 -0
- groundx/workflows/types/workflows_get_request_id.py +5 -0
- {groundx-2.0.15.dist-info → groundx-2.7.7.dist-info}/LICENSE +1 -1
- {groundx-2.0.15.dist-info → groundx-2.7.7.dist-info}/METADATA +39 -22
- groundx-2.7.7.dist-info/RECORD +155 -0
- groundx/documents/types/__init__.py +0 -6
- groundx/documents/types/documents_ingest_local_request_files_item.py +0 -43
- groundx/types/process_status_response_ingest_progress.py +0 -26
- groundx-2.0.15.dist-info/RECORD +0 -82
- {groundx-2.0.15.dist-info → groundx-2.7.7.dist-info}/WHEEL +0 -0
groundx/client.py
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import httpx
|
|
6
|
-
from .
|
|
7
|
-
from .
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
12
|
-
from .health.client import HealthClient
|
|
13
|
-
from .
|
|
14
|
-
from .
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
from .customer.client import AsyncCustomerClient
|
|
19
|
-
from .health.client import AsyncHealthClient
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class GroundX:
|
|
6
|
+
from .buckets.client import AsyncBucketsClient, BucketsClient
|
|
7
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from .customer.client import AsyncCustomerClient, CustomerClient
|
|
9
|
+
from .documents.client import AsyncDocumentsClient, DocumentsClient
|
|
10
|
+
from .environment import GroundXEnvironment
|
|
11
|
+
from .groups.client import AsyncGroupsClient, GroupsClient
|
|
12
|
+
from .health.client import AsyncHealthClient, HealthClient
|
|
13
|
+
from .search.client import AsyncSearchClient, SearchClient
|
|
14
|
+
from .workflows.client import AsyncWorkflowsClient, WorkflowsClient
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GroundXBase:
|
|
23
18
|
"""
|
|
24
19
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
25
20
|
|
|
@@ -66,7 +61,9 @@ class GroundX:
|
|
|
66
61
|
follow_redirects: typing.Optional[bool] = True,
|
|
67
62
|
httpx_client: typing.Optional[httpx.Client] = None,
|
|
68
63
|
):
|
|
69
|
-
_defaulted_timeout =
|
|
64
|
+
_defaulted_timeout = (
|
|
65
|
+
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
66
|
+
)
|
|
70
67
|
self._client_wrapper = SyncClientWrapper(
|
|
71
68
|
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
72
69
|
api_key=api_key,
|
|
@@ -81,11 +78,12 @@ class GroundX:
|
|
|
81
78
|
self.search = SearchClient(client_wrapper=self._client_wrapper)
|
|
82
79
|
self.buckets = BucketsClient(client_wrapper=self._client_wrapper)
|
|
83
80
|
self.groups = GroupsClient(client_wrapper=self._client_wrapper)
|
|
81
|
+
self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
|
|
84
82
|
self.customer = CustomerClient(client_wrapper=self._client_wrapper)
|
|
85
83
|
self.health = HealthClient(client_wrapper=self._client_wrapper)
|
|
86
84
|
|
|
87
85
|
|
|
88
|
-
class
|
|
86
|
+
class AsyncGroundXBase:
|
|
89
87
|
"""
|
|
90
88
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
91
89
|
|
|
@@ -132,7 +130,9 @@ class AsyncGroundX:
|
|
|
132
130
|
follow_redirects: typing.Optional[bool] = True,
|
|
133
131
|
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
134
132
|
):
|
|
135
|
-
_defaulted_timeout =
|
|
133
|
+
_defaulted_timeout = (
|
|
134
|
+
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
|
135
|
+
)
|
|
136
136
|
self._client_wrapper = AsyncClientWrapper(
|
|
137
137
|
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
138
138
|
api_key=api_key,
|
|
@@ -147,6 +147,7 @@ class AsyncGroundX:
|
|
|
147
147
|
self.search = AsyncSearchClient(client_wrapper=self._client_wrapper)
|
|
148
148
|
self.buckets = AsyncBucketsClient(client_wrapper=self._client_wrapper)
|
|
149
149
|
self.groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
|
|
150
|
+
self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
|
|
150
151
|
self.customer = AsyncCustomerClient(client_wrapper=self._client_wrapper)
|
|
151
152
|
self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
|
|
152
153
|
|
groundx/core/__init__.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
3
5
|
from .api_error import ApiError
|
|
4
6
|
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
|
|
5
7
|
from .datetime_utils import serialize_datetime
|
|
6
8
|
from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
|
|
7
9
|
from .http_client import AsyncHttpClient, HttpClient
|
|
10
|
+
from .http_response import AsyncHttpResponse, HttpResponse
|
|
8
11
|
from .jsonable_encoder import jsonable_encoder
|
|
9
12
|
from .pydantic_utilities import (
|
|
10
13
|
IS_PYDANTIC_V2,
|
|
@@ -24,10 +27,12 @@ __all__ = [
|
|
|
24
27
|
"ApiError",
|
|
25
28
|
"AsyncClientWrapper",
|
|
26
29
|
"AsyncHttpClient",
|
|
30
|
+
"AsyncHttpResponse",
|
|
27
31
|
"BaseClientWrapper",
|
|
28
32
|
"FieldMetadata",
|
|
29
33
|
"File",
|
|
30
34
|
"HttpClient",
|
|
35
|
+
"HttpResponse",
|
|
31
36
|
"IS_PYDANTIC_V2",
|
|
32
37
|
"RequestOptions",
|
|
33
38
|
"SyncClientWrapper",
|
groundx/core/api_error.py
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class ApiError(Exception):
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
headers: Optional[Dict[str, str]]
|
|
8
|
+
status_code: Optional[int]
|
|
9
|
+
body: Any
|
|
9
10
|
|
|
10
|
-
def __init__(
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
headers: Optional[Dict[str, str]] = None,
|
|
15
|
+
status_code: Optional[int] = None,
|
|
16
|
+
body: Any = None,
|
|
17
|
+
) -> None:
|
|
18
|
+
self.headers = headers
|
|
11
19
|
self.status_code = status_code
|
|
12
20
|
self.body = body
|
|
13
21
|
|
|
14
22
|
def __str__(self) -> str:
|
|
15
|
-
return f"status_code: {self.status_code}, body: {self.body}"
|
|
23
|
+
return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
|
groundx/core/client_wrapper.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
+
|
|
4
5
|
import httpx
|
|
5
|
-
from .http_client import HttpClient
|
|
6
|
-
from .http_client import AsyncHttpClient
|
|
6
|
+
from .http_client import AsyncHttpClient, HttpClient
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class BaseClientWrapper:
|
|
@@ -14,9 +14,10 @@ class BaseClientWrapper:
|
|
|
14
14
|
|
|
15
15
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
16
16
|
headers: typing.Dict[str, str] = {
|
|
17
|
+
"User-Agent": "groundx/2.7.7",
|
|
17
18
|
"X-Fern-Language": "Python",
|
|
18
19
|
"X-Fern-SDK-Name": "groundx",
|
|
19
|
-
"X-Fern-SDK-Version": "2.
|
|
20
|
+
"X-Fern-SDK-Version": "2.7.7",
|
|
20
21
|
}
|
|
21
22
|
headers["X-API-Key"] = self.api_key
|
|
22
23
|
return headers
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ForceMultipartDict(dict):
|
|
5
|
+
"""
|
|
6
|
+
A dictionary subclass that always evaluates to True in boolean contexts.
|
|
7
|
+
|
|
8
|
+
This is used to force multipart/form-data encoding in HTTP requests even when
|
|
9
|
+
the dictionary is empty, which would normally evaluate to False.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __bool__(self):
|
|
13
|
+
return True
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
FORCE_MULTIPART = ForceMultipartDict()
|
groundx/core/http_client.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import email.utils
|
|
5
|
-
import json
|
|
6
5
|
import re
|
|
7
6
|
import time
|
|
8
7
|
import typing
|
|
@@ -11,12 +10,13 @@ from contextlib import asynccontextmanager, contextmanager
|
|
|
11
10
|
from random import random
|
|
12
11
|
|
|
13
12
|
import httpx
|
|
14
|
-
|
|
15
13
|
from .file import File, convert_file_dict_to_httpx_tuples
|
|
14
|
+
from .force_multipart import FORCE_MULTIPART
|
|
16
15
|
from .jsonable_encoder import jsonable_encoder
|
|
17
16
|
from .query_encoder import encode_query
|
|
18
17
|
from .remove_none_from_dict import remove_none_from_dict
|
|
19
18
|
from .request_options import RequestOptions
|
|
19
|
+
from httpx._types import RequestFiles
|
|
20
20
|
|
|
21
21
|
INITIAL_RETRY_DELAY_SECONDS = 0.5
|
|
22
22
|
MAX_RETRY_DELAY_SECONDS = 10
|
|
@@ -85,8 +85,8 @@ def _retry_timeout(response: httpx.Response, retries: int) -> float:
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def _should_retry(response: httpx.Response) -> bool:
|
|
88
|
-
|
|
89
|
-
return response.status_code >= 500 or response.status_code in
|
|
88
|
+
retryable_400s = [429, 408, 409]
|
|
89
|
+
return response.status_code >= 500 or response.status_code in retryable_400s
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
def remove_omit_from_dict(
|
|
@@ -180,11 +180,17 @@ class HttpClient:
|
|
|
180
180
|
json: typing.Optional[typing.Any] = None,
|
|
181
181
|
data: typing.Optional[typing.Any] = None,
|
|
182
182
|
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
183
|
-
files: typing.Optional[
|
|
183
|
+
files: typing.Optional[
|
|
184
|
+
typing.Union[
|
|
185
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
186
|
+
typing.List[typing.Tuple[str, File]],
|
|
187
|
+
]
|
|
188
|
+
] = None,
|
|
184
189
|
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
185
190
|
request_options: typing.Optional[RequestOptions] = None,
|
|
186
|
-
retries: int =
|
|
191
|
+
retries: int = 2,
|
|
187
192
|
omit: typing.Optional[typing.Any] = None,
|
|
193
|
+
force_multipart: typing.Optional[bool] = None,
|
|
188
194
|
) -> httpx.Response:
|
|
189
195
|
base_url = self.get_base_url(base_url)
|
|
190
196
|
timeout = (
|
|
@@ -195,6 +201,15 @@ class HttpClient:
|
|
|
195
201
|
|
|
196
202
|
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
197
203
|
|
|
204
|
+
request_files: typing.Optional[RequestFiles] = (
|
|
205
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
206
|
+
if (files is not None and files is not omit and isinstance(files, dict))
|
|
207
|
+
else None
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
211
|
+
request_files = FORCE_MULTIPART
|
|
212
|
+
|
|
198
213
|
response = self.httpx_client.request(
|
|
199
214
|
method=method,
|
|
200
215
|
url=urllib.parse.urljoin(f"{base_url}/", path),
|
|
@@ -227,11 +242,7 @@ class HttpClient:
|
|
|
227
242
|
json=json_body,
|
|
228
243
|
data=data_body,
|
|
229
244
|
content=content,
|
|
230
|
-
files=
|
|
231
|
-
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
232
|
-
if (files is not None and files is not omit)
|
|
233
|
-
else None
|
|
234
|
-
),
|
|
245
|
+
files=request_files,
|
|
235
246
|
timeout=timeout,
|
|
236
247
|
)
|
|
237
248
|
|
|
@@ -266,11 +277,17 @@ class HttpClient:
|
|
|
266
277
|
json: typing.Optional[typing.Any] = None,
|
|
267
278
|
data: typing.Optional[typing.Any] = None,
|
|
268
279
|
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
269
|
-
files: typing.Optional[
|
|
280
|
+
files: typing.Optional[
|
|
281
|
+
typing.Union[
|
|
282
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
283
|
+
typing.List[typing.Tuple[str, File]],
|
|
284
|
+
]
|
|
285
|
+
] = None,
|
|
270
286
|
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
271
287
|
request_options: typing.Optional[RequestOptions] = None,
|
|
272
|
-
retries: int =
|
|
288
|
+
retries: int = 2,
|
|
273
289
|
omit: typing.Optional[typing.Any] = None,
|
|
290
|
+
force_multipart: typing.Optional[bool] = None,
|
|
274
291
|
) -> typing.Iterator[httpx.Response]:
|
|
275
292
|
base_url = self.get_base_url(base_url)
|
|
276
293
|
timeout = (
|
|
@@ -279,6 +296,15 @@ class HttpClient:
|
|
|
279
296
|
else self.base_timeout()
|
|
280
297
|
)
|
|
281
298
|
|
|
299
|
+
request_files: typing.Optional[RequestFiles] = (
|
|
300
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
301
|
+
if (files is not None and files is not omit and isinstance(files, dict))
|
|
302
|
+
else None
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
306
|
+
request_files = FORCE_MULTIPART
|
|
307
|
+
|
|
282
308
|
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
283
309
|
|
|
284
310
|
with self.httpx_client.stream(
|
|
@@ -313,11 +339,7 @@ class HttpClient:
|
|
|
313
339
|
json=json_body,
|
|
314
340
|
data=data_body,
|
|
315
341
|
content=content,
|
|
316
|
-
files=
|
|
317
|
-
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
318
|
-
if (files is not None and files is not omit)
|
|
319
|
-
else None
|
|
320
|
-
),
|
|
342
|
+
files=request_files,
|
|
321
343
|
timeout=timeout,
|
|
322
344
|
) as stream:
|
|
323
345
|
yield stream
|
|
@@ -356,11 +378,17 @@ class AsyncHttpClient:
|
|
|
356
378
|
json: typing.Optional[typing.Any] = None,
|
|
357
379
|
data: typing.Optional[typing.Any] = None,
|
|
358
380
|
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
359
|
-
files: typing.Optional[
|
|
381
|
+
files: typing.Optional[
|
|
382
|
+
typing.Union[
|
|
383
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
384
|
+
typing.List[typing.Tuple[str, File]],
|
|
385
|
+
]
|
|
386
|
+
] = None,
|
|
360
387
|
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
361
388
|
request_options: typing.Optional[RequestOptions] = None,
|
|
362
|
-
retries: int =
|
|
389
|
+
retries: int = 2,
|
|
363
390
|
omit: typing.Optional[typing.Any] = None,
|
|
391
|
+
force_multipart: typing.Optional[bool] = None,
|
|
364
392
|
) -> httpx.Response:
|
|
365
393
|
base_url = self.get_base_url(base_url)
|
|
366
394
|
timeout = (
|
|
@@ -369,6 +397,15 @@ class AsyncHttpClient:
|
|
|
369
397
|
else self.base_timeout()
|
|
370
398
|
)
|
|
371
399
|
|
|
400
|
+
request_files: typing.Optional[RequestFiles] = (
|
|
401
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
402
|
+
if (files is not None and files is not omit and isinstance(files, dict))
|
|
403
|
+
else None
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
407
|
+
request_files = FORCE_MULTIPART
|
|
408
|
+
|
|
372
409
|
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
373
410
|
|
|
374
411
|
# Add the input to each of these and do None-safety checks
|
|
@@ -404,11 +441,7 @@ class AsyncHttpClient:
|
|
|
404
441
|
json=json_body,
|
|
405
442
|
data=data_body,
|
|
406
443
|
content=content,
|
|
407
|
-
files=
|
|
408
|
-
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
409
|
-
if files is not None
|
|
410
|
-
else None
|
|
411
|
-
),
|
|
444
|
+
files=request_files,
|
|
412
445
|
timeout=timeout,
|
|
413
446
|
)
|
|
414
447
|
|
|
@@ -442,11 +475,17 @@ class AsyncHttpClient:
|
|
|
442
475
|
json: typing.Optional[typing.Any] = None,
|
|
443
476
|
data: typing.Optional[typing.Any] = None,
|
|
444
477
|
content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None,
|
|
445
|
-
files: typing.Optional[
|
|
478
|
+
files: typing.Optional[
|
|
479
|
+
typing.Union[
|
|
480
|
+
typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]],
|
|
481
|
+
typing.List[typing.Tuple[str, File]],
|
|
482
|
+
]
|
|
483
|
+
] = None,
|
|
446
484
|
headers: typing.Optional[typing.Dict[str, typing.Any]] = None,
|
|
447
485
|
request_options: typing.Optional[RequestOptions] = None,
|
|
448
|
-
retries: int =
|
|
486
|
+
retries: int = 2,
|
|
449
487
|
omit: typing.Optional[typing.Any] = None,
|
|
488
|
+
force_multipart: typing.Optional[bool] = None,
|
|
450
489
|
) -> typing.AsyncIterator[httpx.Response]:
|
|
451
490
|
base_url = self.get_base_url(base_url)
|
|
452
491
|
timeout = (
|
|
@@ -455,6 +494,15 @@ class AsyncHttpClient:
|
|
|
455
494
|
else self.base_timeout()
|
|
456
495
|
)
|
|
457
496
|
|
|
497
|
+
request_files: typing.Optional[RequestFiles] = (
|
|
498
|
+
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
499
|
+
if (files is not None and files is not omit and isinstance(files, dict))
|
|
500
|
+
else None
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
if (request_files is None or len(request_files) == 0) and force_multipart:
|
|
504
|
+
request_files = FORCE_MULTIPART
|
|
505
|
+
|
|
458
506
|
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)
|
|
459
507
|
|
|
460
508
|
async with self.httpx_client.stream(
|
|
@@ -489,11 +537,7 @@ class AsyncHttpClient:
|
|
|
489
537
|
json=json_body,
|
|
490
538
|
data=data_body,
|
|
491
539
|
content=content,
|
|
492
|
-
files=
|
|
493
|
-
convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit))
|
|
494
|
-
if files is not None
|
|
495
|
-
else None
|
|
496
|
-
),
|
|
540
|
+
files=request_files,
|
|
497
541
|
timeout=timeout,
|
|
498
542
|
) as stream:
|
|
499
543
|
yield stream
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Generic, TypeVar
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
8
|
+
"""Generic to represent the underlying type of the data wrapped by the HTTP response."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BaseHttpResponse:
|
|
12
|
+
"""Minimalist HTTP response wrapper that exposes response headers."""
|
|
13
|
+
|
|
14
|
+
_response: httpx.Response
|
|
15
|
+
|
|
16
|
+
def __init__(self, response: httpx.Response):
|
|
17
|
+
self._response = response
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def headers(self) -> Dict[str, str]:
|
|
21
|
+
return dict(self._response.headers)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class HttpResponse(Generic[T], BaseHttpResponse):
|
|
25
|
+
"""HTTP response wrapper that exposes response headers and data."""
|
|
26
|
+
|
|
27
|
+
_data: T
|
|
28
|
+
|
|
29
|
+
def __init__(self, response: httpx.Response, data: T):
|
|
30
|
+
super().__init__(response)
|
|
31
|
+
self._data = data
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def data(self) -> T:
|
|
35
|
+
return self._data
|
|
36
|
+
|
|
37
|
+
def close(self) -> None:
|
|
38
|
+
self._response.close()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class AsyncHttpResponse(Generic[T], BaseHttpResponse):
|
|
42
|
+
"""HTTP response wrapper that exposes response headers and data."""
|
|
43
|
+
|
|
44
|
+
_data: T
|
|
45
|
+
|
|
46
|
+
def __init__(self, response: httpx.Response, data: T):
|
|
47
|
+
super().__init__(response)
|
|
48
|
+
self._data = data
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def data(self) -> T:
|
|
52
|
+
return self._data
|
|
53
|
+
|
|
54
|
+
async def close(self) -> None:
|
|
55
|
+
await self._response.aclose()
|
groundx/core/jsonable_encoder.py
CHANGED