supermemory 3.0.0a2__py3-none-any.whl → 3.0.0a19__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.
- supermemory/_files.py +1 -1
- supermemory/_version.py +1 -1
- supermemory/resources/memories.py +95 -4
- supermemory/types/__init__.py +2 -0
- supermemory/types/memory_upload_file_params.py +13 -0
- supermemory/types/memory_upload_file_response.py +11 -0
- {supermemory-3.0.0a2.dist-info → supermemory-3.0.0a19.dist-info}/METADATA +18 -1
- {supermemory-3.0.0a2.dist-info → supermemory-3.0.0a19.dist-info}/RECORD +10 -8
- {supermemory-3.0.0a2.dist-info → supermemory-3.0.0a19.dist-info}/WHEEL +0 -0
- {supermemory-3.0.0a2.dist-info → supermemory-3.0.0a19.dist-info}/licenses/LICENSE +0 -0
supermemory/_files.py
CHANGED
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
|
|
34
34
|
if not is_file_content(obj):
|
35
35
|
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
|
36
36
|
raise RuntimeError(
|
37
|
-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
|
37
|
+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/supermemoryai/python-sdk/tree/main#file-uploads"
|
38
38
|
) from None
|
39
39
|
|
40
40
|
|
supermemory/_version.py
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
-
from typing import Dict, List, Union
|
5
|
+
from typing import Dict, List, Union, Mapping, cast
|
6
6
|
|
7
7
|
import httpx
|
8
8
|
|
9
|
-
from ..types import memory_add_params, memory_update_params
|
10
|
-
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
|
11
|
-
from .._utils import maybe_transform, async_maybe_transform
|
9
|
+
from ..types import memory_add_params, memory_update_params, memory_upload_file_params
|
10
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
|
11
|
+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
12
12
|
from .._compat import cached_property
|
13
13
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
14
14
|
from .._response import (
|
@@ -21,6 +21,7 @@ from .._base_client import make_request_options
|
|
21
21
|
from ..types.memory_add_response import MemoryAddResponse
|
22
22
|
from ..types.memory_get_response import MemoryGetResponse
|
23
23
|
from ..types.memory_update_response import MemoryUpdateResponse
|
24
|
+
from ..types.memory_upload_file_response import MemoryUploadFileResponse
|
24
25
|
|
25
26
|
__all__ = ["MemoriesResource", "AsyncMemoriesResource"]
|
26
27
|
|
@@ -243,6 +244,45 @@ class MemoriesResource(SyncAPIResource):
|
|
243
244
|
cast_to=MemoryGetResponse,
|
244
245
|
)
|
245
246
|
|
247
|
+
def upload_file(
|
248
|
+
self,
|
249
|
+
*,
|
250
|
+
file: FileTypes,
|
251
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
252
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
253
|
+
extra_headers: Headers | None = None,
|
254
|
+
extra_query: Query | None = None,
|
255
|
+
extra_body: Body | None = None,
|
256
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
257
|
+
) -> MemoryUploadFileResponse:
|
258
|
+
"""
|
259
|
+
Upload a file to be processed
|
260
|
+
|
261
|
+
Args:
|
262
|
+
extra_headers: Send extra headers
|
263
|
+
|
264
|
+
extra_query: Add additional query parameters to the request
|
265
|
+
|
266
|
+
extra_body: Add additional JSON properties to the request
|
267
|
+
|
268
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
269
|
+
"""
|
270
|
+
body = deepcopy_minimal({"file": file})
|
271
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
272
|
+
# It should be noted that the actual Content-Type header that will be
|
273
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
274
|
+
# multipart/form-data; boundary=---abc--
|
275
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
276
|
+
return self._post(
|
277
|
+
"/v3/memories/file",
|
278
|
+
body=maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
279
|
+
files=files,
|
280
|
+
options=make_request_options(
|
281
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
282
|
+
),
|
283
|
+
cast_to=MemoryUploadFileResponse,
|
284
|
+
)
|
285
|
+
|
246
286
|
|
247
287
|
class AsyncMemoriesResource(AsyncAPIResource):
|
248
288
|
@cached_property
|
@@ -462,6 +502,45 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
462
502
|
cast_to=MemoryGetResponse,
|
463
503
|
)
|
464
504
|
|
505
|
+
async def upload_file(
|
506
|
+
self,
|
507
|
+
*,
|
508
|
+
file: FileTypes,
|
509
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
510
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
511
|
+
extra_headers: Headers | None = None,
|
512
|
+
extra_query: Query | None = None,
|
513
|
+
extra_body: Body | None = None,
|
514
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
515
|
+
) -> MemoryUploadFileResponse:
|
516
|
+
"""
|
517
|
+
Upload a file to be processed
|
518
|
+
|
519
|
+
Args:
|
520
|
+
extra_headers: Send extra headers
|
521
|
+
|
522
|
+
extra_query: Add additional query parameters to the request
|
523
|
+
|
524
|
+
extra_body: Add additional JSON properties to the request
|
525
|
+
|
526
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
527
|
+
"""
|
528
|
+
body = deepcopy_minimal({"file": file})
|
529
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
530
|
+
# It should be noted that the actual Content-Type header that will be
|
531
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
532
|
+
# multipart/form-data; boundary=---abc--
|
533
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
534
|
+
return await self._post(
|
535
|
+
"/v3/memories/file",
|
536
|
+
body=await async_maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
537
|
+
files=files,
|
538
|
+
options=make_request_options(
|
539
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
540
|
+
),
|
541
|
+
cast_to=MemoryUploadFileResponse,
|
542
|
+
)
|
543
|
+
|
465
544
|
|
466
545
|
class MemoriesResourceWithRawResponse:
|
467
546
|
def __init__(self, memories: MemoriesResource) -> None:
|
@@ -479,6 +558,9 @@ class MemoriesResourceWithRawResponse:
|
|
479
558
|
self.get = to_raw_response_wrapper(
|
480
559
|
memories.get,
|
481
560
|
)
|
561
|
+
self.upload_file = to_raw_response_wrapper(
|
562
|
+
memories.upload_file,
|
563
|
+
)
|
482
564
|
|
483
565
|
|
484
566
|
class AsyncMemoriesResourceWithRawResponse:
|
@@ -497,6 +579,9 @@ class AsyncMemoriesResourceWithRawResponse:
|
|
497
579
|
self.get = async_to_raw_response_wrapper(
|
498
580
|
memories.get,
|
499
581
|
)
|
582
|
+
self.upload_file = async_to_raw_response_wrapper(
|
583
|
+
memories.upload_file,
|
584
|
+
)
|
500
585
|
|
501
586
|
|
502
587
|
class MemoriesResourceWithStreamingResponse:
|
@@ -515,6 +600,9 @@ class MemoriesResourceWithStreamingResponse:
|
|
515
600
|
self.get = to_streamed_response_wrapper(
|
516
601
|
memories.get,
|
517
602
|
)
|
603
|
+
self.upload_file = to_streamed_response_wrapper(
|
604
|
+
memories.upload_file,
|
605
|
+
)
|
518
606
|
|
519
607
|
|
520
608
|
class AsyncMemoriesResourceWithStreamingResponse:
|
@@ -533,3 +621,6 @@ class AsyncMemoriesResourceWithStreamingResponse:
|
|
533
621
|
self.get = async_to_streamed_response_wrapper(
|
534
622
|
memories.get,
|
535
623
|
)
|
624
|
+
self.upload_file = async_to_streamed_response_wrapper(
|
625
|
+
memories.upload_file,
|
626
|
+
)
|
supermemory/types/__init__.py
CHANGED
@@ -12,4 +12,6 @@ from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
|
|
12
12
|
from .connection_get_response import ConnectionGetResponse as ConnectionGetResponse
|
13
13
|
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
|
14
14
|
from .connection_create_params import ConnectionCreateParams as ConnectionCreateParams
|
15
|
+
from .memory_upload_file_params import MemoryUploadFileParams as MemoryUploadFileParams
|
15
16
|
from .connection_create_response import ConnectionCreateResponse as ConnectionCreateResponse
|
17
|
+
from .memory_upload_file_response import MemoryUploadFileResponse as MemoryUploadFileResponse
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing_extensions import Required, TypedDict
|
6
|
+
|
7
|
+
from .._types import FileTypes
|
8
|
+
|
9
|
+
__all__ = ["MemoryUploadFileParams"]
|
10
|
+
|
11
|
+
|
12
|
+
class MemoryUploadFileParams(TypedDict, total=False):
|
13
|
+
file: Required[FileTypes]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: supermemory
|
3
|
-
Version: 3.0.
|
3
|
+
Version: 3.0.0a19
|
4
4
|
Summary: The official Python library for the supermemory API
|
5
5
|
Project-URL: Homepage, https://github.com/supermemoryai/python-sdk
|
6
6
|
Project-URL: Repository, https://github.com/supermemoryai/python-sdk
|
@@ -145,6 +145,23 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
|
|
145
145
|
|
146
146
|
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
|
147
147
|
|
148
|
+
## File uploads
|
149
|
+
|
150
|
+
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
|
151
|
+
|
152
|
+
```python
|
153
|
+
from pathlib import Path
|
154
|
+
from supermemory import Supermemory
|
155
|
+
|
156
|
+
client = Supermemory()
|
157
|
+
|
158
|
+
client.memories.upload_file(
|
159
|
+
file=Path("/path/to/file"),
|
160
|
+
)
|
161
|
+
```
|
162
|
+
|
163
|
+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
|
164
|
+
|
148
165
|
## Handling errors
|
149
166
|
|
150
167
|
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `supermemory.APIConnectionError` is raised.
|
@@ -4,14 +4,14 @@ supermemory/_client.py,sha256=IMo1vJ8G5Ha05IPVyuUEFXrCOY83gKJGB6sdyAb-rUk,16388
|
|
4
4
|
supermemory/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
|
5
5
|
supermemory/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
6
6
|
supermemory/_exceptions.py,sha256=5nnX7W8L_eA6LkX3SBl7csJy5d9QEcDqRVuwDq8wVh8,3230
|
7
|
-
supermemory/_files.py,sha256=
|
7
|
+
supermemory/_files.py,sha256=GME47rR56vqhHb7qh5NZtaLIWsA6ZrCHHGdBKjB0Q3s,3620
|
8
8
|
supermemory/_models.py,sha256=G1vczEodX0vUySeVKbF-mbzlaObNL1oVAYH4c65agRk,29131
|
9
9
|
supermemory/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
10
10
|
supermemory/_resource.py,sha256=_wuaB1exMy-l-qqdJJdTv15hH5qBSN2Rj9CFwjXTZJU,1130
|
11
11
|
supermemory/_response.py,sha256=Yh869-U8INkojKZHFsNw69z5Y2BrK2isgRJ8mifEURM,28848
|
12
12
|
supermemory/_streaming.py,sha256=MGbosxSTqq0_JG52hvH2Z-Mr_Y95ws5UdFw77_iYukc,10120
|
13
13
|
supermemory/_types.py,sha256=ohS8PFDHBFM-0ua6YsUlS55BPHft3xY6DhiIKaYrlN0,6202
|
14
|
-
supermemory/_version.py,sha256=
|
14
|
+
supermemory/_version.py,sha256=b3QTl7IoxrDY0LUsi8hUlqp9Xdg6gXtmipq5XSqohNg,172
|
15
15
|
supermemory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
supermemory/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
|
17
17
|
supermemory/_utils/_logs.py,sha256=iceljYaEUb4Q4q1SgbSzwSrlJA64ISbaccczzZ8Z9Vg,789
|
@@ -26,9 +26,9 @@ supermemory/_utils/_utils.py,sha256=ts4CiiuNpFiGB6YMdkQRh2SZvYvsl7mAF-JWHCcLDf4,
|
|
26
26
|
supermemory/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
27
27
|
supermemory/resources/__init__.py,sha256=iYwzfeiqmu2Lorat88bYVkp4CobBt60Gq_6GcygldLE,1569
|
28
28
|
supermemory/resources/connections.py,sha256=PERpnnUiu2hQjDvX_toy1thiipXu25RQaahTIeUwb3w,10656
|
29
|
-
supermemory/resources/memories.py,sha256
|
29
|
+
supermemory/resources/memories.py,sha256=-CdL69kAKk5ANyAt4YiDksrxPI1KM2fU5hNddk9JK_U,25244
|
30
30
|
supermemory/resources/settings.py,sha256=hzijwhQ9U_W5zDRbDjW27QdQU4CwqLkPRWkcALYSCok,12175
|
31
|
-
supermemory/types/__init__.py,sha256=
|
31
|
+
supermemory/types/__init__.py,sha256=s2RgV_b8Nyhy9md8w6ZvmBekOtaKEFz8CuFWCx0y6LA,1172
|
32
32
|
supermemory/types/connection_create_params.py,sha256=bYYKu3ns60PX6Mt34UQUpYwThB3SBZsKn5tW0c46DUM,630
|
33
33
|
supermemory/types/connection_create_response.py,sha256=i4sb0DSRs7wVVd8xDBOtr7vw-YbaeZ7MydlQLYvlvJs,468
|
34
34
|
supermemory/types/connection_get_response.py,sha256=9ujakZecSs89sItCpsyDQWWB59BtymxspKQKVJBofIg,606
|
@@ -37,10 +37,12 @@ supermemory/types/memory_add_response.py,sha256=5lim8sVXM7WzG8tUuKORHEe2lJc6yVWv
|
|
37
37
|
supermemory/types/memory_get_response.py,sha256=sSCvX54IIoaVuifygi0IxiwHMKNNIGgg8eJJ-xu37BI,2850
|
38
38
|
supermemory/types/memory_update_params.py,sha256=swEIF-CfcxWGzsiT8O_AbtzkyujMiafZpbi2GEXPuuw,1534
|
39
39
|
supermemory/types/memory_update_response.py,sha256=fvfO9lGM8xv2EUOQfOSxqig6fx6-ykq7syW69er_2ng,225
|
40
|
+
supermemory/types/memory_upload_file_params.py,sha256=vZUYsfyzEMxESmfSOPBcDINXN_Ts4rdFvdaDiIMkme0,329
|
41
|
+
supermemory/types/memory_upload_file_response.py,sha256=KTq6AExBMz7eMt8az1TgMSSNMTktKk0d0xItCwHRNl0,233
|
40
42
|
supermemory/types/setting_get_response.py,sha256=_CWSr9_-0alw57qSQOaMm-e_FsdXmxIRYhcmTMpdado,1789
|
41
43
|
supermemory/types/setting_update_params.py,sha256=EWbqdSsoTJohQ1nbEbBdAvtR5co_hh7huH6XZ-t7MRM,1854
|
42
44
|
supermemory/types/setting_update_response.py,sha256=Evd1U6QQDYyhD_hpKqS9k7ctvh0GNX4GHPdwBChVB44,1947
|
43
|
-
supermemory-3.0.
|
44
|
-
supermemory-3.0.
|
45
|
-
supermemory-3.0.
|
46
|
-
supermemory-3.0.
|
45
|
+
supermemory-3.0.0a19.dist-info/METADATA,sha256=B8VKJteQgOwRzxM4rSedi_UHgc5_ubx7SfvBSIGGEa8,14958
|
46
|
+
supermemory-3.0.0a19.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
47
|
+
supermemory-3.0.0a19.dist-info/licenses/LICENSE,sha256=M2NcpYEBpakciOULpWzo-xO2Lincf74gGwfaU00Sct0,11341
|
48
|
+
supermemory-3.0.0a19.dist-info/RECORD,,
|
File without changes
|
File without changes
|