|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import Dict, List, Union, Mapping, Iterable, Optional, cast |
| 5 | +from typing import Dict, List, Union, Iterable, Optional |
6 | 6 | from datetime import datetime |
7 | 7 | from typing_extensions import Literal |
8 | 8 |
|
|
16 | 16 | memory_upload_params, |
17 | 17 | memory_add_bulk_params, |
18 | 18 | ) |
19 | | -from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given |
20 | | -from .._utils import extract_files, path_template, maybe_transform, deepcopy_minimal, async_maybe_transform |
| 19 | +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 20 | +from .._utils import path_template, maybe_transform, async_maybe_transform |
21 | 21 | from .._compat import cached_property |
22 | 22 | from .._resource import SyncAPIResource, AsyncAPIResource |
23 | 23 | from .._response import ( |
@@ -549,7 +549,7 @@ def status( |
549 | 549 | def upload( |
550 | 550 | self, |
551 | 551 | *, |
552 | | - file: FileTypes, |
| 552 | + file: str, |
553 | 553 | collection: Optional[str] | Omit = omit, |
554 | 554 | metadata: Optional[str] | Omit = omit, |
555 | 555 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -583,22 +583,20 @@ def upload( |
583 | 583 |
|
584 | 584 | timeout: Override the client-level default timeout for this request, in seconds |
585 | 585 | """ |
586 | | - body = deepcopy_minimal( |
587 | | - { |
588 | | - "file": file, |
589 | | - "collection": collection, |
590 | | - "metadata": metadata, |
591 | | - } |
592 | | - ) |
593 | | - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) |
594 | 586 | # It should be noted that the actual Content-Type header that will be |
595 | 587 | # sent to the server will contain a `boundary` parameter, e.g. |
596 | 588 | # multipart/form-data; boundary=---abc-- |
597 | 589 | extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} |
598 | 590 | return self._post( |
599 | 591 | "/memories/upload", |
600 | | - body=maybe_transform(body, memory_upload_params.MemoryUploadParams), |
601 | | - files=files, |
| 592 | + body=maybe_transform( |
| 593 | + { |
| 594 | + "file": file, |
| 595 | + "collection": collection, |
| 596 | + "metadata": metadata, |
| 597 | + }, |
| 598 | + memory_upload_params.MemoryUploadParams, |
| 599 | + ), |
602 | 600 | options=make_request_options( |
603 | 601 | extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
604 | 602 | ), |
@@ -1116,7 +1114,7 @@ async def status( |
1116 | 1114 | async def upload( |
1117 | 1115 | self, |
1118 | 1116 | *, |
1119 | | - file: FileTypes, |
| 1117 | + file: str, |
1120 | 1118 | collection: Optional[str] | Omit = omit, |
1121 | 1119 | metadata: Optional[str] | Omit = omit, |
1122 | 1120 | # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
@@ -1150,22 +1148,20 @@ async def upload( |
1150 | 1148 |
|
1151 | 1149 | timeout: Override the client-level default timeout for this request, in seconds |
1152 | 1150 | """ |
1153 | | - body = deepcopy_minimal( |
1154 | | - { |
1155 | | - "file": file, |
1156 | | - "collection": collection, |
1157 | | - "metadata": metadata, |
1158 | | - } |
1159 | | - ) |
1160 | | - files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) |
1161 | 1151 | # It should be noted that the actual Content-Type header that will be |
1162 | 1152 | # sent to the server will contain a `boundary` parameter, e.g. |
1163 | 1153 | # multipart/form-data; boundary=---abc-- |
1164 | 1154 | extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} |
1165 | 1155 | return await self._post( |
1166 | 1156 | "/memories/upload", |
1167 | | - body=await async_maybe_transform(body, memory_upload_params.MemoryUploadParams), |
1168 | | - files=files, |
| 1157 | + body=await async_maybe_transform( |
| 1158 | + { |
| 1159 | + "file": file, |
| 1160 | + "collection": collection, |
| 1161 | + "metadata": metadata, |
| 1162 | + }, |
| 1163 | + memory_upload_params.MemoryUploadParams, |
| 1164 | + ), |
1169 | 1165 | options=make_request_options( |
1170 | 1166 | extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
1171 | 1167 | ), |
|
0 commit comments