supermemory 3.7.0__py3-none-any.whl → 3.19.0__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/_base_client.py +140 -11
- supermemory/_client.py +226 -52
- supermemory/_models.py +16 -1
- supermemory/_streaming.py +12 -10
- supermemory/_types.py +12 -2
- supermemory/_version.py +1 -1
- supermemory/resources/connections.py +219 -29
- supermemory/resources/documents.py +306 -2
- supermemory/resources/memories.py +270 -1
- supermemory/resources/search.py +14 -0
- supermemory/resources/settings.py +12 -0
- supermemory/types/__init__.py +15 -2
- supermemory/types/client_profile_params.py +6 -0
- supermemory/types/connection_configure_params.py +12 -0
- supermemory/types/connection_configure_response.py +17 -0
- supermemory/types/connection_get_by_id_response.py +3 -1
- supermemory/types/{connection_get_by_tags_params.py → connection_get_by_tag_params.py} +2 -2
- supermemory/types/{connection_get_by_tags_response.py → connection_get_by_tag_response.py} +5 -3
- supermemory/types/connection_list_response.py +2 -0
- supermemory/types/connection_resources_params.py +13 -0
- supermemory/types/connection_resources_response.py +13 -0
- supermemory/types/document_batch_add_params.py +84 -0
- supermemory/types/document_batch_add_response.py +19 -0
- supermemory/types/document_delete_bulk_params.py +18 -0
- supermemory/types/document_delete_bulk_response.py +37 -0
- supermemory/types/document_get_response.py +7 -0
- supermemory/types/document_list_params.py +3790 -3
- supermemory/types/document_list_processing_response.py +75 -0
- supermemory/types/document_list_response.py +5 -0
- supermemory/types/document_upload_file_params.py +8 -0
- supermemory/types/memory_forget_params.py +26 -0
- supermemory/types/memory_forget_response.py +15 -0
- supermemory/types/memory_get_response.py +7 -0
- supermemory/types/memory_list_params.py +3790 -3
- supermemory/types/memory_list_response.py +5 -0
- supermemory/types/memory_update_memory_params.py +31 -0
- supermemory/types/memory_update_memory_response.py +31 -0
- supermemory/types/memory_upload_file_params.py +8 -0
- supermemory/types/profile_response.py +2 -0
- supermemory/types/search_documents_params.py +3791 -4
- supermemory/types/search_documents_response.py +2 -0
- supermemory/types/search_execute_params.py +3791 -4
- supermemory/types/search_execute_response.py +2 -0
- supermemory/types/search_memories_params.py +3809 -8
- supermemory/types/search_memories_response.py +33 -5
- supermemory/types/setting_get_response.py +6 -0
- supermemory/types/setting_update_params.py +6 -0
- supermemory/types/setting_update_response.py +6 -0
- {supermemory-3.7.0.dist-info → supermemory-3.19.0.dist-info}/METADATA +12 -2
- supermemory-3.19.0.dist-info/RECORD +97 -0
- {supermemory-3.7.0.dist-info → supermemory-3.19.0.dist-info}/licenses/LICENSE +1 -1
- supermemory-3.7.0.dist-info/RECORD +0 -84
- {supermemory-3.7.0.dist-info → supermemory-3.19.0.dist-info}/WHEEL +0 -0
supermemory/_client.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
-
from typing import Any, Dict, Union, Mapping
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Dict, Union, Mapping
|
|
7
7
|
from typing_extensions import Self, override
|
|
8
8
|
|
|
9
9
|
import httpx
|
|
@@ -31,6 +31,7 @@ from ._utils import (
|
|
|
31
31
|
get_async_library,
|
|
32
32
|
async_maybe_transform,
|
|
33
33
|
)
|
|
34
|
+
from ._compat import cached_property
|
|
34
35
|
from ._version import __version__
|
|
35
36
|
from ._response import (
|
|
36
37
|
to_raw_response_wrapper,
|
|
@@ -38,7 +39,6 @@ from ._response import (
|
|
|
38
39
|
async_to_raw_response_wrapper,
|
|
39
40
|
async_to_streamed_response_wrapper,
|
|
40
41
|
)
|
|
41
|
-
from .resources import search, memories, settings, documents, connections
|
|
42
42
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
43
43
|
from ._exceptions import APIStatusError, SupermemoryError
|
|
44
44
|
from ._base_client import (
|
|
@@ -50,6 +50,14 @@ from ._base_client import (
|
|
|
50
50
|
from .types.add_response import AddResponse
|
|
51
51
|
from .types.profile_response import ProfileResponse
|
|
52
52
|
|
|
53
|
+
if TYPE_CHECKING:
|
|
54
|
+
from .resources import search, memories, settings, documents, connections
|
|
55
|
+
from .resources.search import SearchResource, AsyncSearchResource
|
|
56
|
+
from .resources.memories import MemoriesResource, AsyncMemoriesResource
|
|
57
|
+
from .resources.settings import SettingsResource, AsyncSettingsResource
|
|
58
|
+
from .resources.documents import DocumentsResource, AsyncDocumentsResource
|
|
59
|
+
from .resources.connections import ConnectionsResource, AsyncConnectionsResource
|
|
60
|
+
|
|
53
61
|
__all__ = [
|
|
54
62
|
"Timeout",
|
|
55
63
|
"Transport",
|
|
@@ -63,14 +71,6 @@ __all__ = [
|
|
|
63
71
|
|
|
64
72
|
|
|
65
73
|
class Supermemory(SyncAPIClient):
|
|
66
|
-
memories: memories.MemoriesResource
|
|
67
|
-
documents: documents.DocumentsResource
|
|
68
|
-
search: search.SearchResource
|
|
69
|
-
settings: settings.SettingsResource
|
|
70
|
-
connections: connections.ConnectionsResource
|
|
71
|
-
with_raw_response: SupermemoryWithRawResponse
|
|
72
|
-
with_streaming_response: SupermemoryWithStreamedResponse
|
|
73
|
-
|
|
74
74
|
# client options
|
|
75
75
|
api_key: str
|
|
76
76
|
|
|
@@ -125,13 +125,43 @@ class Supermemory(SyncAPIClient):
|
|
|
125
125
|
_strict_response_validation=_strict_response_validation,
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
@cached_property
|
|
129
|
+
def memories(self) -> MemoriesResource:
|
|
130
|
+
from .resources.memories import MemoriesResource
|
|
131
|
+
|
|
132
|
+
return MemoriesResource(self)
|
|
133
|
+
|
|
134
|
+
@cached_property
|
|
135
|
+
def documents(self) -> DocumentsResource:
|
|
136
|
+
from .resources.documents import DocumentsResource
|
|
137
|
+
|
|
138
|
+
return DocumentsResource(self)
|
|
139
|
+
|
|
140
|
+
@cached_property
|
|
141
|
+
def search(self) -> SearchResource:
|
|
142
|
+
from .resources.search import SearchResource
|
|
143
|
+
|
|
144
|
+
return SearchResource(self)
|
|
145
|
+
|
|
146
|
+
@cached_property
|
|
147
|
+
def settings(self) -> SettingsResource:
|
|
148
|
+
from .resources.settings import SettingsResource
|
|
149
|
+
|
|
150
|
+
return SettingsResource(self)
|
|
151
|
+
|
|
152
|
+
@cached_property
|
|
153
|
+
def connections(self) -> ConnectionsResource:
|
|
154
|
+
from .resources.connections import ConnectionsResource
|
|
155
|
+
|
|
156
|
+
return ConnectionsResource(self)
|
|
157
|
+
|
|
158
|
+
@cached_property
|
|
159
|
+
def with_raw_response(self) -> SupermemoryWithRawResponse:
|
|
160
|
+
return SupermemoryWithRawResponse(self)
|
|
161
|
+
|
|
162
|
+
@cached_property
|
|
163
|
+
def with_streaming_response(self) -> SupermemoryWithStreamedResponse:
|
|
164
|
+
return SupermemoryWithStreamedResponse(self)
|
|
135
165
|
|
|
136
166
|
@property
|
|
137
167
|
@override
|
|
@@ -265,6 +295,7 @@ class Supermemory(SyncAPIClient):
|
|
|
265
295
|
*,
|
|
266
296
|
container_tag: str,
|
|
267
297
|
q: str | Omit = omit,
|
|
298
|
+
threshold: float | Omit = omit,
|
|
268
299
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
269
300
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
270
301
|
extra_headers: Headers | None = None,
|
|
@@ -281,6 +312,9 @@ class Supermemory(SyncAPIClient):
|
|
|
281
312
|
|
|
282
313
|
q: Optional search query to include search results in the response
|
|
283
314
|
|
|
315
|
+
threshold: Threshold for search results. Only results with a score above this threshold
|
|
316
|
+
will be included.
|
|
317
|
+
|
|
284
318
|
extra_headers: Send extra headers
|
|
285
319
|
|
|
286
320
|
extra_query: Add additional query parameters to the request
|
|
@@ -295,6 +329,7 @@ class Supermemory(SyncAPIClient):
|
|
|
295
329
|
{
|
|
296
330
|
"container_tag": container_tag,
|
|
297
331
|
"q": q,
|
|
332
|
+
"threshold": threshold,
|
|
298
333
|
},
|
|
299
334
|
client_profile_params.ClientProfileParams,
|
|
300
335
|
),
|
|
@@ -339,14 +374,6 @@ class Supermemory(SyncAPIClient):
|
|
|
339
374
|
|
|
340
375
|
|
|
341
376
|
class AsyncSupermemory(AsyncAPIClient):
|
|
342
|
-
memories: memories.AsyncMemoriesResource
|
|
343
|
-
documents: documents.AsyncDocumentsResource
|
|
344
|
-
search: search.AsyncSearchResource
|
|
345
|
-
settings: settings.AsyncSettingsResource
|
|
346
|
-
connections: connections.AsyncConnectionsResource
|
|
347
|
-
with_raw_response: AsyncSupermemoryWithRawResponse
|
|
348
|
-
with_streaming_response: AsyncSupermemoryWithStreamedResponse
|
|
349
|
-
|
|
350
377
|
# client options
|
|
351
378
|
api_key: str
|
|
352
379
|
|
|
@@ -401,13 +428,43 @@ class AsyncSupermemory(AsyncAPIClient):
|
|
|
401
428
|
_strict_response_validation=_strict_response_validation,
|
|
402
429
|
)
|
|
403
430
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
431
|
+
@cached_property
|
|
432
|
+
def memories(self) -> AsyncMemoriesResource:
|
|
433
|
+
from .resources.memories import AsyncMemoriesResource
|
|
434
|
+
|
|
435
|
+
return AsyncMemoriesResource(self)
|
|
436
|
+
|
|
437
|
+
@cached_property
|
|
438
|
+
def documents(self) -> AsyncDocumentsResource:
|
|
439
|
+
from .resources.documents import AsyncDocumentsResource
|
|
440
|
+
|
|
441
|
+
return AsyncDocumentsResource(self)
|
|
442
|
+
|
|
443
|
+
@cached_property
|
|
444
|
+
def search(self) -> AsyncSearchResource:
|
|
445
|
+
from .resources.search import AsyncSearchResource
|
|
446
|
+
|
|
447
|
+
return AsyncSearchResource(self)
|
|
448
|
+
|
|
449
|
+
@cached_property
|
|
450
|
+
def settings(self) -> AsyncSettingsResource:
|
|
451
|
+
from .resources.settings import AsyncSettingsResource
|
|
452
|
+
|
|
453
|
+
return AsyncSettingsResource(self)
|
|
454
|
+
|
|
455
|
+
@cached_property
|
|
456
|
+
def connections(self) -> AsyncConnectionsResource:
|
|
457
|
+
from .resources.connections import AsyncConnectionsResource
|
|
458
|
+
|
|
459
|
+
return AsyncConnectionsResource(self)
|
|
460
|
+
|
|
461
|
+
@cached_property
|
|
462
|
+
def with_raw_response(self) -> AsyncSupermemoryWithRawResponse:
|
|
463
|
+
return AsyncSupermemoryWithRawResponse(self)
|
|
464
|
+
|
|
465
|
+
@cached_property
|
|
466
|
+
def with_streaming_response(self) -> AsyncSupermemoryWithStreamedResponse:
|
|
467
|
+
return AsyncSupermemoryWithStreamedResponse(self)
|
|
411
468
|
|
|
412
469
|
@property
|
|
413
470
|
@override
|
|
@@ -541,6 +598,7 @@ class AsyncSupermemory(AsyncAPIClient):
|
|
|
541
598
|
*,
|
|
542
599
|
container_tag: str,
|
|
543
600
|
q: str | Omit = omit,
|
|
601
|
+
threshold: float | Omit = omit,
|
|
544
602
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
545
603
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
546
604
|
extra_headers: Headers | None = None,
|
|
@@ -557,6 +615,9 @@ class AsyncSupermemory(AsyncAPIClient):
|
|
|
557
615
|
|
|
558
616
|
q: Optional search query to include search results in the response
|
|
559
617
|
|
|
618
|
+
threshold: Threshold for search results. Only results with a score above this threshold
|
|
619
|
+
will be included.
|
|
620
|
+
|
|
560
621
|
extra_headers: Send extra headers
|
|
561
622
|
|
|
562
623
|
extra_query: Add additional query parameters to the request
|
|
@@ -571,6 +632,7 @@ class AsyncSupermemory(AsyncAPIClient):
|
|
|
571
632
|
{
|
|
572
633
|
"container_tag": container_tag,
|
|
573
634
|
"q": q,
|
|
635
|
+
"threshold": threshold,
|
|
574
636
|
},
|
|
575
637
|
client_profile_params.ClientProfileParams,
|
|
576
638
|
),
|
|
@@ -615,12 +677,10 @@ class AsyncSupermemory(AsyncAPIClient):
|
|
|
615
677
|
|
|
616
678
|
|
|
617
679
|
class SupermemoryWithRawResponse:
|
|
680
|
+
_client: Supermemory
|
|
681
|
+
|
|
618
682
|
def __init__(self, client: Supermemory) -> None:
|
|
619
|
-
self.
|
|
620
|
-
self.documents = documents.DocumentsResourceWithRawResponse(client.documents)
|
|
621
|
-
self.search = search.SearchResourceWithRawResponse(client.search)
|
|
622
|
-
self.settings = settings.SettingsResourceWithRawResponse(client.settings)
|
|
623
|
-
self.connections = connections.ConnectionsResourceWithRawResponse(client.connections)
|
|
683
|
+
self._client = client
|
|
624
684
|
|
|
625
685
|
self.add = to_raw_response_wrapper(
|
|
626
686
|
client.add,
|
|
@@ -629,14 +689,42 @@ class SupermemoryWithRawResponse:
|
|
|
629
689
|
client.profile,
|
|
630
690
|
)
|
|
631
691
|
|
|
692
|
+
@cached_property
|
|
693
|
+
def memories(self) -> memories.MemoriesResourceWithRawResponse:
|
|
694
|
+
from .resources.memories import MemoriesResourceWithRawResponse
|
|
695
|
+
|
|
696
|
+
return MemoriesResourceWithRawResponse(self._client.memories)
|
|
697
|
+
|
|
698
|
+
@cached_property
|
|
699
|
+
def documents(self) -> documents.DocumentsResourceWithRawResponse:
|
|
700
|
+
from .resources.documents import DocumentsResourceWithRawResponse
|
|
701
|
+
|
|
702
|
+
return DocumentsResourceWithRawResponse(self._client.documents)
|
|
703
|
+
|
|
704
|
+
@cached_property
|
|
705
|
+
def search(self) -> search.SearchResourceWithRawResponse:
|
|
706
|
+
from .resources.search import SearchResourceWithRawResponse
|
|
707
|
+
|
|
708
|
+
return SearchResourceWithRawResponse(self._client.search)
|
|
709
|
+
|
|
710
|
+
@cached_property
|
|
711
|
+
def settings(self) -> settings.SettingsResourceWithRawResponse:
|
|
712
|
+
from .resources.settings import SettingsResourceWithRawResponse
|
|
713
|
+
|
|
714
|
+
return SettingsResourceWithRawResponse(self._client.settings)
|
|
715
|
+
|
|
716
|
+
@cached_property
|
|
717
|
+
def connections(self) -> connections.ConnectionsResourceWithRawResponse:
|
|
718
|
+
from .resources.connections import ConnectionsResourceWithRawResponse
|
|
719
|
+
|
|
720
|
+
return ConnectionsResourceWithRawResponse(self._client.connections)
|
|
721
|
+
|
|
632
722
|
|
|
633
723
|
class AsyncSupermemoryWithRawResponse:
|
|
724
|
+
_client: AsyncSupermemory
|
|
725
|
+
|
|
634
726
|
def __init__(self, client: AsyncSupermemory) -> None:
|
|
635
|
-
self.
|
|
636
|
-
self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents)
|
|
637
|
-
self.search = search.AsyncSearchResourceWithRawResponse(client.search)
|
|
638
|
-
self.settings = settings.AsyncSettingsResourceWithRawResponse(client.settings)
|
|
639
|
-
self.connections = connections.AsyncConnectionsResourceWithRawResponse(client.connections)
|
|
727
|
+
self._client = client
|
|
640
728
|
|
|
641
729
|
self.add = async_to_raw_response_wrapper(
|
|
642
730
|
client.add,
|
|
@@ -645,14 +733,42 @@ class AsyncSupermemoryWithRawResponse:
|
|
|
645
733
|
client.profile,
|
|
646
734
|
)
|
|
647
735
|
|
|
736
|
+
@cached_property
|
|
737
|
+
def memories(self) -> memories.AsyncMemoriesResourceWithRawResponse:
|
|
738
|
+
from .resources.memories import AsyncMemoriesResourceWithRawResponse
|
|
739
|
+
|
|
740
|
+
return AsyncMemoriesResourceWithRawResponse(self._client.memories)
|
|
741
|
+
|
|
742
|
+
@cached_property
|
|
743
|
+
def documents(self) -> documents.AsyncDocumentsResourceWithRawResponse:
|
|
744
|
+
from .resources.documents import AsyncDocumentsResourceWithRawResponse
|
|
745
|
+
|
|
746
|
+
return AsyncDocumentsResourceWithRawResponse(self._client.documents)
|
|
747
|
+
|
|
748
|
+
@cached_property
|
|
749
|
+
def search(self) -> search.AsyncSearchResourceWithRawResponse:
|
|
750
|
+
from .resources.search import AsyncSearchResourceWithRawResponse
|
|
751
|
+
|
|
752
|
+
return AsyncSearchResourceWithRawResponse(self._client.search)
|
|
753
|
+
|
|
754
|
+
@cached_property
|
|
755
|
+
def settings(self) -> settings.AsyncSettingsResourceWithRawResponse:
|
|
756
|
+
from .resources.settings import AsyncSettingsResourceWithRawResponse
|
|
757
|
+
|
|
758
|
+
return AsyncSettingsResourceWithRawResponse(self._client.settings)
|
|
759
|
+
|
|
760
|
+
@cached_property
|
|
761
|
+
def connections(self) -> connections.AsyncConnectionsResourceWithRawResponse:
|
|
762
|
+
from .resources.connections import AsyncConnectionsResourceWithRawResponse
|
|
763
|
+
|
|
764
|
+
return AsyncConnectionsResourceWithRawResponse(self._client.connections)
|
|
765
|
+
|
|
648
766
|
|
|
649
767
|
class SupermemoryWithStreamedResponse:
|
|
768
|
+
_client: Supermemory
|
|
769
|
+
|
|
650
770
|
def __init__(self, client: Supermemory) -> None:
|
|
651
|
-
self.
|
|
652
|
-
self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents)
|
|
653
|
-
self.search = search.SearchResourceWithStreamingResponse(client.search)
|
|
654
|
-
self.settings = settings.SettingsResourceWithStreamingResponse(client.settings)
|
|
655
|
-
self.connections = connections.ConnectionsResourceWithStreamingResponse(client.connections)
|
|
771
|
+
self._client = client
|
|
656
772
|
|
|
657
773
|
self.add = to_streamed_response_wrapper(
|
|
658
774
|
client.add,
|
|
@@ -661,14 +777,42 @@ class SupermemoryWithStreamedResponse:
|
|
|
661
777
|
client.profile,
|
|
662
778
|
)
|
|
663
779
|
|
|
780
|
+
@cached_property
|
|
781
|
+
def memories(self) -> memories.MemoriesResourceWithStreamingResponse:
|
|
782
|
+
from .resources.memories import MemoriesResourceWithStreamingResponse
|
|
783
|
+
|
|
784
|
+
return MemoriesResourceWithStreamingResponse(self._client.memories)
|
|
785
|
+
|
|
786
|
+
@cached_property
|
|
787
|
+
def documents(self) -> documents.DocumentsResourceWithStreamingResponse:
|
|
788
|
+
from .resources.documents import DocumentsResourceWithStreamingResponse
|
|
789
|
+
|
|
790
|
+
return DocumentsResourceWithStreamingResponse(self._client.documents)
|
|
791
|
+
|
|
792
|
+
@cached_property
|
|
793
|
+
def search(self) -> search.SearchResourceWithStreamingResponse:
|
|
794
|
+
from .resources.search import SearchResourceWithStreamingResponse
|
|
795
|
+
|
|
796
|
+
return SearchResourceWithStreamingResponse(self._client.search)
|
|
797
|
+
|
|
798
|
+
@cached_property
|
|
799
|
+
def settings(self) -> settings.SettingsResourceWithStreamingResponse:
|
|
800
|
+
from .resources.settings import SettingsResourceWithStreamingResponse
|
|
801
|
+
|
|
802
|
+
return SettingsResourceWithStreamingResponse(self._client.settings)
|
|
803
|
+
|
|
804
|
+
@cached_property
|
|
805
|
+
def connections(self) -> connections.ConnectionsResourceWithStreamingResponse:
|
|
806
|
+
from .resources.connections import ConnectionsResourceWithStreamingResponse
|
|
807
|
+
|
|
808
|
+
return ConnectionsResourceWithStreamingResponse(self._client.connections)
|
|
809
|
+
|
|
664
810
|
|
|
665
811
|
class AsyncSupermemoryWithStreamedResponse:
|
|
812
|
+
_client: AsyncSupermemory
|
|
813
|
+
|
|
666
814
|
def __init__(self, client: AsyncSupermemory) -> None:
|
|
667
|
-
self.
|
|
668
|
-
self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents)
|
|
669
|
-
self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
|
|
670
|
-
self.settings = settings.AsyncSettingsResourceWithStreamingResponse(client.settings)
|
|
671
|
-
self.connections = connections.AsyncConnectionsResourceWithStreamingResponse(client.connections)
|
|
815
|
+
self._client = client
|
|
672
816
|
|
|
673
817
|
self.add = async_to_streamed_response_wrapper(
|
|
674
818
|
client.add,
|
|
@@ -677,6 +821,36 @@ class AsyncSupermemoryWithStreamedResponse:
|
|
|
677
821
|
client.profile,
|
|
678
822
|
)
|
|
679
823
|
|
|
824
|
+
@cached_property
|
|
825
|
+
def memories(self) -> memories.AsyncMemoriesResourceWithStreamingResponse:
|
|
826
|
+
from .resources.memories import AsyncMemoriesResourceWithStreamingResponse
|
|
827
|
+
|
|
828
|
+
return AsyncMemoriesResourceWithStreamingResponse(self._client.memories)
|
|
829
|
+
|
|
830
|
+
@cached_property
|
|
831
|
+
def documents(self) -> documents.AsyncDocumentsResourceWithStreamingResponse:
|
|
832
|
+
from .resources.documents import AsyncDocumentsResourceWithStreamingResponse
|
|
833
|
+
|
|
834
|
+
return AsyncDocumentsResourceWithStreamingResponse(self._client.documents)
|
|
835
|
+
|
|
836
|
+
@cached_property
|
|
837
|
+
def search(self) -> search.AsyncSearchResourceWithStreamingResponse:
|
|
838
|
+
from .resources.search import AsyncSearchResourceWithStreamingResponse
|
|
839
|
+
|
|
840
|
+
return AsyncSearchResourceWithStreamingResponse(self._client.search)
|
|
841
|
+
|
|
842
|
+
@cached_property
|
|
843
|
+
def settings(self) -> settings.AsyncSettingsResourceWithStreamingResponse:
|
|
844
|
+
from .resources.settings import AsyncSettingsResourceWithStreamingResponse
|
|
845
|
+
|
|
846
|
+
return AsyncSettingsResourceWithStreamingResponse(self._client.settings)
|
|
847
|
+
|
|
848
|
+
@cached_property
|
|
849
|
+
def connections(self) -> connections.AsyncConnectionsResourceWithStreamingResponse:
|
|
850
|
+
from .resources.connections import AsyncConnectionsResourceWithStreamingResponse
|
|
851
|
+
|
|
852
|
+
return AsyncConnectionsResourceWithStreamingResponse(self._client.connections)
|
|
853
|
+
|
|
680
854
|
|
|
681
855
|
Client = Supermemory
|
|
682
856
|
|
supermemory/_models.py
CHANGED
|
@@ -3,7 +3,20 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
import inspect
|
|
5
5
|
import weakref
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import (
|
|
7
|
+
IO,
|
|
8
|
+
TYPE_CHECKING,
|
|
9
|
+
Any,
|
|
10
|
+
Type,
|
|
11
|
+
Union,
|
|
12
|
+
Generic,
|
|
13
|
+
TypeVar,
|
|
14
|
+
Callable,
|
|
15
|
+
Iterable,
|
|
16
|
+
Optional,
|
|
17
|
+
AsyncIterable,
|
|
18
|
+
cast,
|
|
19
|
+
)
|
|
7
20
|
from datetime import date, datetime
|
|
8
21
|
from typing_extensions import (
|
|
9
22
|
List,
|
|
@@ -787,6 +800,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
|
|
|
787
800
|
timeout: float | Timeout | None
|
|
788
801
|
files: HttpxRequestFiles | None
|
|
789
802
|
idempotency_key: str
|
|
803
|
+
content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None]
|
|
790
804
|
json_data: Body
|
|
791
805
|
extra_json: AnyMapping
|
|
792
806
|
follow_redirects: bool
|
|
@@ -805,6 +819,7 @@ class FinalRequestOptions(pydantic.BaseModel):
|
|
|
805
819
|
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
|
|
806
820
|
follow_redirects: Union[bool, None] = None
|
|
807
821
|
|
|
822
|
+
content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None
|
|
808
823
|
# It should be noted that we cannot use `json` here as that would override
|
|
809
824
|
# a BaseModel method in an incompatible fashion.
|
|
810
825
|
json_data: Union[Body, None] = None
|
supermemory/_streaming.py
CHANGED
|
@@ -54,11 +54,12 @@ class Stream(Generic[_T]):
|
|
|
54
54
|
process_data = self._client._process_response_data
|
|
55
55
|
iterator = self._iter_events()
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
try:
|
|
58
|
+
for sse in iterator:
|
|
59
|
+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
60
|
+
finally:
|
|
61
|
+
# Ensure the response is closed even if the consumer doesn't read all data
|
|
62
|
+
response.close()
|
|
62
63
|
|
|
63
64
|
def __enter__(self) -> Self:
|
|
64
65
|
return self
|
|
@@ -117,11 +118,12 @@ class AsyncStream(Generic[_T]):
|
|
|
117
118
|
process_data = self._client._process_response_data
|
|
118
119
|
iterator = self._iter_events()
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
try:
|
|
122
|
+
async for sse in iterator:
|
|
123
|
+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
124
|
+
finally:
|
|
125
|
+
# Ensure the response is closed even if the consumer doesn't read all data
|
|
126
|
+
await response.aclose()
|
|
125
127
|
|
|
126
128
|
async def __aenter__(self) -> Self:
|
|
127
129
|
return self
|
supermemory/_types.py
CHANGED
|
@@ -13,9 +13,11 @@ from typing import (
|
|
|
13
13
|
Mapping,
|
|
14
14
|
TypeVar,
|
|
15
15
|
Callable,
|
|
16
|
+
Iterable,
|
|
16
17
|
Iterator,
|
|
17
18
|
Optional,
|
|
18
19
|
Sequence,
|
|
20
|
+
AsyncIterable,
|
|
19
21
|
)
|
|
20
22
|
from typing_extensions import (
|
|
21
23
|
Set,
|
|
@@ -56,6 +58,13 @@ if TYPE_CHECKING:
|
|
|
56
58
|
else:
|
|
57
59
|
Base64FileInput = Union[IO[bytes], PathLike]
|
|
58
60
|
FileContent = Union[IO[bytes], bytes, PathLike] # PathLike is not subscriptable in Python 3.8.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# Used for sending raw binary data / streaming data in request bodies
|
|
64
|
+
# e.g. for file uploads without multipart encoding
|
|
65
|
+
BinaryTypes = Union[bytes, bytearray, IO[bytes], Iterable[bytes]]
|
|
66
|
+
AsyncBinaryTypes = Union[bytes, bytearray, IO[bytes], AsyncIterable[bytes]]
|
|
67
|
+
|
|
59
68
|
FileTypes = Union[
|
|
60
69
|
# file (or bytes)
|
|
61
70
|
FileContent,
|
|
@@ -243,6 +252,9 @@ _T_co = TypeVar("_T_co", covariant=True)
|
|
|
243
252
|
if TYPE_CHECKING:
|
|
244
253
|
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
|
|
245
254
|
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
|
|
255
|
+
#
|
|
256
|
+
# Note: index() and count() methods are intentionally omitted to allow pyright to properly
|
|
257
|
+
# infer TypedDict types when dict literals are used in lists assigned to SequenceNotStr.
|
|
246
258
|
class SequenceNotStr(Protocol[_T_co]):
|
|
247
259
|
@overload
|
|
248
260
|
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
|
|
@@ -251,8 +263,6 @@ if TYPE_CHECKING:
|
|
|
251
263
|
def __contains__(self, value: object, /) -> bool: ...
|
|
252
264
|
def __len__(self) -> int: ...
|
|
253
265
|
def __iter__(self) -> Iterator[_T_co]: ...
|
|
254
|
-
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
|
255
|
-
def count(self, value: Any, /) -> int: ...
|
|
256
266
|
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
257
267
|
else:
|
|
258
268
|
# just point this to a normal `Sequence` at runtime to avoid having to special case
|
supermemory/_version.py
CHANGED