supermemory 3.0.0a24__py3-none-any.whl → 3.0.0a26__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.
Potentially problematic release.
This version of supermemory might be problematic. Click here for more details.
- supermemory/_files.py +1 -1
- supermemory/_version.py +1 -1
- supermemory/resources/memories.py +107 -4
- supermemory/resources/search.py +365 -1
- supermemory/types/__init__.py +6 -0
- supermemory/types/memory_upload_file_params.py +16 -0
- supermemory/types/memory_upload_file_response.py +11 -0
- supermemory/types/search_documents_params.py +93 -0
- supermemory/types/search_documents_response.py +61 -0
- supermemory/types/search_execute_response.py +3 -0
- supermemory/types/search_memories_params.py +66 -0
- supermemory/types/search_memories_response.py +121 -0
- {supermemory-3.0.0a24.dist-info → supermemory-3.0.0a26.dist-info}/METADATA +37 -4
- {supermemory-3.0.0a24.dist-info → supermemory-3.0.0a26.dist-info}/RECORD +16 -10
- {supermemory-3.0.0a24.dist-info → supermemory-3.0.0a26.dist-info}/WHEEL +0 -0
- {supermemory-3.0.0a24.dist-info → supermemory-3.0.0a26.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,14 +2,14 @@
|
|
|
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
|
from typing_extensions import Literal
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
|
-
from ..types import memory_add_params, memory_list_params, memory_update_params
|
|
11
|
-
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
|
|
12
|
-
from .._utils import maybe_transform, async_maybe_transform
|
|
10
|
+
from ..types import memory_add_params, memory_list_params, memory_update_params, memory_upload_file_params
|
|
11
|
+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
|
|
12
|
+
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
14
14
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
15
15
|
from .._response import (
|
|
@@ -23,6 +23,7 @@ from ..types.memory_add_response import MemoryAddResponse
|
|
|
23
23
|
from ..types.memory_get_response import MemoryGetResponse
|
|
24
24
|
from ..types.memory_list_response import MemoryListResponse
|
|
25
25
|
from ..types.memory_update_response import MemoryUpdateResponse
|
|
26
|
+
from ..types.memory_upload_file_response import MemoryUploadFileResponse
|
|
26
27
|
|
|
27
28
|
__all__ = ["MemoriesResource", "AsyncMemoriesResource"]
|
|
28
29
|
|
|
@@ -305,6 +306,51 @@ class MemoriesResource(SyncAPIResource):
|
|
|
305
306
|
cast_to=MemoryGetResponse,
|
|
306
307
|
)
|
|
307
308
|
|
|
309
|
+
def upload_file(
|
|
310
|
+
self,
|
|
311
|
+
*,
|
|
312
|
+
file: FileTypes,
|
|
313
|
+
container_tags: str | NotGiven = NOT_GIVEN,
|
|
314
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
315
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
316
|
+
extra_headers: Headers | None = None,
|
|
317
|
+
extra_query: Query | None = None,
|
|
318
|
+
extra_body: Body | None = None,
|
|
319
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
320
|
+
) -> MemoryUploadFileResponse:
|
|
321
|
+
"""
|
|
322
|
+
Upload a file to be processed
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
extra_headers: Send extra headers
|
|
326
|
+
|
|
327
|
+
extra_query: Add additional query parameters to the request
|
|
328
|
+
|
|
329
|
+
extra_body: Add additional JSON properties to the request
|
|
330
|
+
|
|
331
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
332
|
+
"""
|
|
333
|
+
body = deepcopy_minimal(
|
|
334
|
+
{
|
|
335
|
+
"file": file,
|
|
336
|
+
"container_tags": container_tags,
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
340
|
+
# It should be noted that the actual Content-Type header that will be
|
|
341
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
342
|
+
# multipart/form-data; boundary=---abc--
|
|
343
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
344
|
+
return self._post(
|
|
345
|
+
"/v3/memories/file",
|
|
346
|
+
body=maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
|
347
|
+
files=files,
|
|
348
|
+
options=make_request_options(
|
|
349
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
350
|
+
),
|
|
351
|
+
cast_to=MemoryUploadFileResponse,
|
|
352
|
+
)
|
|
353
|
+
|
|
308
354
|
|
|
309
355
|
class AsyncMemoriesResource(AsyncAPIResource):
|
|
310
356
|
@cached_property
|
|
@@ -584,6 +630,51 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
584
630
|
cast_to=MemoryGetResponse,
|
|
585
631
|
)
|
|
586
632
|
|
|
633
|
+
async def upload_file(
|
|
634
|
+
self,
|
|
635
|
+
*,
|
|
636
|
+
file: FileTypes,
|
|
637
|
+
container_tags: str | NotGiven = NOT_GIVEN,
|
|
638
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
639
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
640
|
+
extra_headers: Headers | None = None,
|
|
641
|
+
extra_query: Query | None = None,
|
|
642
|
+
extra_body: Body | None = None,
|
|
643
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
644
|
+
) -> MemoryUploadFileResponse:
|
|
645
|
+
"""
|
|
646
|
+
Upload a file to be processed
|
|
647
|
+
|
|
648
|
+
Args:
|
|
649
|
+
extra_headers: Send extra headers
|
|
650
|
+
|
|
651
|
+
extra_query: Add additional query parameters to the request
|
|
652
|
+
|
|
653
|
+
extra_body: Add additional JSON properties to the request
|
|
654
|
+
|
|
655
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
656
|
+
"""
|
|
657
|
+
body = deepcopy_minimal(
|
|
658
|
+
{
|
|
659
|
+
"file": file,
|
|
660
|
+
"container_tags": container_tags,
|
|
661
|
+
}
|
|
662
|
+
)
|
|
663
|
+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
664
|
+
# It should be noted that the actual Content-Type header that will be
|
|
665
|
+
# sent to the server will contain a `boundary` parameter, e.g.
|
|
666
|
+
# multipart/form-data; boundary=---abc--
|
|
667
|
+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
668
|
+
return await self._post(
|
|
669
|
+
"/v3/memories/file",
|
|
670
|
+
body=await async_maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
|
671
|
+
files=files,
|
|
672
|
+
options=make_request_options(
|
|
673
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
674
|
+
),
|
|
675
|
+
cast_to=MemoryUploadFileResponse,
|
|
676
|
+
)
|
|
677
|
+
|
|
587
678
|
|
|
588
679
|
class MemoriesResourceWithRawResponse:
|
|
589
680
|
def __init__(self, memories: MemoriesResource) -> None:
|
|
@@ -604,6 +695,9 @@ class MemoriesResourceWithRawResponse:
|
|
|
604
695
|
self.get = to_raw_response_wrapper(
|
|
605
696
|
memories.get,
|
|
606
697
|
)
|
|
698
|
+
self.upload_file = to_raw_response_wrapper(
|
|
699
|
+
memories.upload_file,
|
|
700
|
+
)
|
|
607
701
|
|
|
608
702
|
|
|
609
703
|
class AsyncMemoriesResourceWithRawResponse:
|
|
@@ -625,6 +719,9 @@ class AsyncMemoriesResourceWithRawResponse:
|
|
|
625
719
|
self.get = async_to_raw_response_wrapper(
|
|
626
720
|
memories.get,
|
|
627
721
|
)
|
|
722
|
+
self.upload_file = async_to_raw_response_wrapper(
|
|
723
|
+
memories.upload_file,
|
|
724
|
+
)
|
|
628
725
|
|
|
629
726
|
|
|
630
727
|
class MemoriesResourceWithStreamingResponse:
|
|
@@ -646,6 +743,9 @@ class MemoriesResourceWithStreamingResponse:
|
|
|
646
743
|
self.get = to_streamed_response_wrapper(
|
|
647
744
|
memories.get,
|
|
648
745
|
)
|
|
746
|
+
self.upload_file = to_streamed_response_wrapper(
|
|
747
|
+
memories.upload_file,
|
|
748
|
+
)
|
|
649
749
|
|
|
650
750
|
|
|
651
751
|
class AsyncMemoriesResourceWithStreamingResponse:
|
|
@@ -667,3 +767,6 @@ class AsyncMemoriesResourceWithStreamingResponse:
|
|
|
667
767
|
self.get = async_to_streamed_response_wrapper(
|
|
668
768
|
memories.get,
|
|
669
769
|
)
|
|
770
|
+
self.upload_file = async_to_streamed_response_wrapper(
|
|
771
|
+
memories.upload_file,
|
|
772
|
+
)
|
supermemory/resources/search.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing_extensions import Literal
|
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
|
-
from ..types import search_execute_params
|
|
10
|
+
from ..types import search_execute_params, search_memories_params, search_documents_params
|
|
11
11
|
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
|
12
12
|
from .._utils import maybe_transform, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
@@ -20,6 +20,8 @@ from .._response import (
|
|
|
20
20
|
)
|
|
21
21
|
from .._base_client import make_request_options
|
|
22
22
|
from ..types.search_execute_response import SearchExecuteResponse
|
|
23
|
+
from ..types.search_memories_response import SearchMemoriesResponse
|
|
24
|
+
from ..types.search_documents_response import SearchDocumentsResponse
|
|
23
25
|
|
|
24
26
|
__all__ = ["SearchResource", "AsyncSearchResource"]
|
|
25
27
|
|
|
@@ -44,6 +46,105 @@ class SearchResource(SyncAPIResource):
|
|
|
44
46
|
"""
|
|
45
47
|
return SearchResourceWithStreamingResponse(self)
|
|
46
48
|
|
|
49
|
+
def documents(
|
|
50
|
+
self,
|
|
51
|
+
*,
|
|
52
|
+
q: str,
|
|
53
|
+
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
|
|
54
|
+
chunk_threshold: float | NotGiven = NOT_GIVEN,
|
|
55
|
+
container_tags: List[str] | NotGiven = NOT_GIVEN,
|
|
56
|
+
doc_id: str | NotGiven = NOT_GIVEN,
|
|
57
|
+
document_threshold: float | NotGiven = NOT_GIVEN,
|
|
58
|
+
filters: search_documents_params.Filters | NotGiven = NOT_GIVEN,
|
|
59
|
+
include_full_docs: bool | NotGiven = NOT_GIVEN,
|
|
60
|
+
include_summary: bool | NotGiven = NOT_GIVEN,
|
|
61
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
62
|
+
only_matching_chunks: bool | NotGiven = NOT_GIVEN,
|
|
63
|
+
rerank: bool | NotGiven = NOT_GIVEN,
|
|
64
|
+
rewrite_query: bool | NotGiven = NOT_GIVEN,
|
|
65
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
66
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
67
|
+
extra_headers: Headers | None = None,
|
|
68
|
+
extra_query: Query | None = None,
|
|
69
|
+
extra_body: Body | None = None,
|
|
70
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
71
|
+
) -> SearchDocumentsResponse:
|
|
72
|
+
"""
|
|
73
|
+
Search memories with advanced filtering
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
q: Search query string
|
|
77
|
+
|
|
78
|
+
categories_filter: Optional category filters
|
|
79
|
+
|
|
80
|
+
chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
|
|
81
|
+
chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
|
|
82
|
+
results)
|
|
83
|
+
|
|
84
|
+
container_tags: Optional tags this search should be containerized by. This can be an ID for your
|
|
85
|
+
user, a project ID, or any other identifier you wish to use to filter memories.
|
|
86
|
+
|
|
87
|
+
doc_id: Optional document ID to search within. You can use this to find chunks in a very
|
|
88
|
+
large document.
|
|
89
|
+
|
|
90
|
+
document_threshold: Threshold / sensitivity for document selection. 0 is least sensitive (returns
|
|
91
|
+
most documents, more results), 1 is most sensitive (returns lesser documents,
|
|
92
|
+
accurate results)
|
|
93
|
+
|
|
94
|
+
filters: Optional filters to apply to the search
|
|
95
|
+
|
|
96
|
+
include_full_docs: If true, include full document in the response. This is helpful if you want a
|
|
97
|
+
chatbot to know the full context of the document.
|
|
98
|
+
|
|
99
|
+
include_summary: If true, include document summary in the response. This is helpful if you want a
|
|
100
|
+
chatbot to know the full context of the document.
|
|
101
|
+
|
|
102
|
+
limit: Maximum number of results to return
|
|
103
|
+
|
|
104
|
+
only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
|
|
105
|
+
previous and next chunk to provide more context for LLMs. If you only want the
|
|
106
|
+
matching chunk, set this to true.
|
|
107
|
+
|
|
108
|
+
rerank: If true, rerank the results based on the query. This is helpful if you want to
|
|
109
|
+
ensure the most relevant results are returned.
|
|
110
|
+
|
|
111
|
+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
|
|
112
|
+
the latency by about 400ms
|
|
113
|
+
|
|
114
|
+
extra_headers: Send extra headers
|
|
115
|
+
|
|
116
|
+
extra_query: Add additional query parameters to the request
|
|
117
|
+
|
|
118
|
+
extra_body: Add additional JSON properties to the request
|
|
119
|
+
|
|
120
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
121
|
+
"""
|
|
122
|
+
return self._post(
|
|
123
|
+
"/v3/search",
|
|
124
|
+
body=maybe_transform(
|
|
125
|
+
{
|
|
126
|
+
"q": q,
|
|
127
|
+
"categories_filter": categories_filter,
|
|
128
|
+
"chunk_threshold": chunk_threshold,
|
|
129
|
+
"container_tags": container_tags,
|
|
130
|
+
"doc_id": doc_id,
|
|
131
|
+
"document_threshold": document_threshold,
|
|
132
|
+
"filters": filters,
|
|
133
|
+
"include_full_docs": include_full_docs,
|
|
134
|
+
"include_summary": include_summary,
|
|
135
|
+
"limit": limit,
|
|
136
|
+
"only_matching_chunks": only_matching_chunks,
|
|
137
|
+
"rerank": rerank,
|
|
138
|
+
"rewrite_query": rewrite_query,
|
|
139
|
+
},
|
|
140
|
+
search_documents_params.SearchDocumentsParams,
|
|
141
|
+
),
|
|
142
|
+
options=make_request_options(
|
|
143
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
144
|
+
),
|
|
145
|
+
cast_to=SearchDocumentsResponse,
|
|
146
|
+
)
|
|
147
|
+
|
|
47
148
|
def execute(
|
|
48
149
|
self,
|
|
49
150
|
*,
|
|
@@ -143,6 +244,76 @@ class SearchResource(SyncAPIResource):
|
|
|
143
244
|
cast_to=SearchExecuteResponse,
|
|
144
245
|
)
|
|
145
246
|
|
|
247
|
+
def memories(
|
|
248
|
+
self,
|
|
249
|
+
*,
|
|
250
|
+
q: str,
|
|
251
|
+
container_tag: str | NotGiven = NOT_GIVEN,
|
|
252
|
+
filters: search_memories_params.Filters | NotGiven = NOT_GIVEN,
|
|
253
|
+
include: search_memories_params.Include | NotGiven = NOT_GIVEN,
|
|
254
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
255
|
+
rerank: bool | NotGiven = NOT_GIVEN,
|
|
256
|
+
rewrite_query: bool | NotGiven = NOT_GIVEN,
|
|
257
|
+
threshold: float | NotGiven = NOT_GIVEN,
|
|
258
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
259
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
260
|
+
extra_headers: Headers | None = None,
|
|
261
|
+
extra_query: Query | None = None,
|
|
262
|
+
extra_body: Body | None = None,
|
|
263
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
264
|
+
) -> SearchMemoriesResponse:
|
|
265
|
+
"""
|
|
266
|
+
Search memory entries - Low latency for conversational
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
q: Search query string
|
|
270
|
+
|
|
271
|
+
container_tag: Optional tag this search should be containerized by. This can be an ID for your
|
|
272
|
+
user, a project ID, or any other identifier you wish to use to filter memories.
|
|
273
|
+
|
|
274
|
+
filters: Optional filters to apply to the search
|
|
275
|
+
|
|
276
|
+
limit: Maximum number of results to return
|
|
277
|
+
|
|
278
|
+
rerank: If true, rerank the results based on the query. This is helpful if you want to
|
|
279
|
+
ensure the most relevant results are returned.
|
|
280
|
+
|
|
281
|
+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
|
|
282
|
+
the latency by about 400ms
|
|
283
|
+
|
|
284
|
+
threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
|
|
285
|
+
most memories, more results), 1 is most sensitive (returns lesser memories,
|
|
286
|
+
accurate results)
|
|
287
|
+
|
|
288
|
+
extra_headers: Send extra headers
|
|
289
|
+
|
|
290
|
+
extra_query: Add additional query parameters to the request
|
|
291
|
+
|
|
292
|
+
extra_body: Add additional JSON properties to the request
|
|
293
|
+
|
|
294
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
295
|
+
"""
|
|
296
|
+
return self._post(
|
|
297
|
+
"/v4/search",
|
|
298
|
+
body=maybe_transform(
|
|
299
|
+
{
|
|
300
|
+
"q": q,
|
|
301
|
+
"container_tag": container_tag,
|
|
302
|
+
"filters": filters,
|
|
303
|
+
"include": include,
|
|
304
|
+
"limit": limit,
|
|
305
|
+
"rerank": rerank,
|
|
306
|
+
"rewrite_query": rewrite_query,
|
|
307
|
+
"threshold": threshold,
|
|
308
|
+
},
|
|
309
|
+
search_memories_params.SearchMemoriesParams,
|
|
310
|
+
),
|
|
311
|
+
options=make_request_options(
|
|
312
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
313
|
+
),
|
|
314
|
+
cast_to=SearchMemoriesResponse,
|
|
315
|
+
)
|
|
316
|
+
|
|
146
317
|
|
|
147
318
|
class AsyncSearchResource(AsyncAPIResource):
|
|
148
319
|
@cached_property
|
|
@@ -164,6 +335,105 @@ class AsyncSearchResource(AsyncAPIResource):
|
|
|
164
335
|
"""
|
|
165
336
|
return AsyncSearchResourceWithStreamingResponse(self)
|
|
166
337
|
|
|
338
|
+
async def documents(
|
|
339
|
+
self,
|
|
340
|
+
*,
|
|
341
|
+
q: str,
|
|
342
|
+
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
|
|
343
|
+
chunk_threshold: float | NotGiven = NOT_GIVEN,
|
|
344
|
+
container_tags: List[str] | NotGiven = NOT_GIVEN,
|
|
345
|
+
doc_id: str | NotGiven = NOT_GIVEN,
|
|
346
|
+
document_threshold: float | NotGiven = NOT_GIVEN,
|
|
347
|
+
filters: search_documents_params.Filters | NotGiven = NOT_GIVEN,
|
|
348
|
+
include_full_docs: bool | NotGiven = NOT_GIVEN,
|
|
349
|
+
include_summary: bool | NotGiven = NOT_GIVEN,
|
|
350
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
351
|
+
only_matching_chunks: bool | NotGiven = NOT_GIVEN,
|
|
352
|
+
rerank: bool | NotGiven = NOT_GIVEN,
|
|
353
|
+
rewrite_query: bool | NotGiven = NOT_GIVEN,
|
|
354
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
355
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
356
|
+
extra_headers: Headers | None = None,
|
|
357
|
+
extra_query: Query | None = None,
|
|
358
|
+
extra_body: Body | None = None,
|
|
359
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
360
|
+
) -> SearchDocumentsResponse:
|
|
361
|
+
"""
|
|
362
|
+
Search memories with advanced filtering
|
|
363
|
+
|
|
364
|
+
Args:
|
|
365
|
+
q: Search query string
|
|
366
|
+
|
|
367
|
+
categories_filter: Optional category filters
|
|
368
|
+
|
|
369
|
+
chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
|
|
370
|
+
chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
|
|
371
|
+
results)
|
|
372
|
+
|
|
373
|
+
container_tags: Optional tags this search should be containerized by. This can be an ID for your
|
|
374
|
+
user, a project ID, or any other identifier you wish to use to filter memories.
|
|
375
|
+
|
|
376
|
+
doc_id: Optional document ID to search within. You can use this to find chunks in a very
|
|
377
|
+
large document.
|
|
378
|
+
|
|
379
|
+
document_threshold: Threshold / sensitivity for document selection. 0 is least sensitive (returns
|
|
380
|
+
most documents, more results), 1 is most sensitive (returns lesser documents,
|
|
381
|
+
accurate results)
|
|
382
|
+
|
|
383
|
+
filters: Optional filters to apply to the search
|
|
384
|
+
|
|
385
|
+
include_full_docs: If true, include full document in the response. This is helpful if you want a
|
|
386
|
+
chatbot to know the full context of the document.
|
|
387
|
+
|
|
388
|
+
include_summary: If true, include document summary in the response. This is helpful if you want a
|
|
389
|
+
chatbot to know the full context of the document.
|
|
390
|
+
|
|
391
|
+
limit: Maximum number of results to return
|
|
392
|
+
|
|
393
|
+
only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
|
|
394
|
+
previous and next chunk to provide more context for LLMs. If you only want the
|
|
395
|
+
matching chunk, set this to true.
|
|
396
|
+
|
|
397
|
+
rerank: If true, rerank the results based on the query. This is helpful if you want to
|
|
398
|
+
ensure the most relevant results are returned.
|
|
399
|
+
|
|
400
|
+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
|
|
401
|
+
the latency by about 400ms
|
|
402
|
+
|
|
403
|
+
extra_headers: Send extra headers
|
|
404
|
+
|
|
405
|
+
extra_query: Add additional query parameters to the request
|
|
406
|
+
|
|
407
|
+
extra_body: Add additional JSON properties to the request
|
|
408
|
+
|
|
409
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
410
|
+
"""
|
|
411
|
+
return await self._post(
|
|
412
|
+
"/v3/search",
|
|
413
|
+
body=await async_maybe_transform(
|
|
414
|
+
{
|
|
415
|
+
"q": q,
|
|
416
|
+
"categories_filter": categories_filter,
|
|
417
|
+
"chunk_threshold": chunk_threshold,
|
|
418
|
+
"container_tags": container_tags,
|
|
419
|
+
"doc_id": doc_id,
|
|
420
|
+
"document_threshold": document_threshold,
|
|
421
|
+
"filters": filters,
|
|
422
|
+
"include_full_docs": include_full_docs,
|
|
423
|
+
"include_summary": include_summary,
|
|
424
|
+
"limit": limit,
|
|
425
|
+
"only_matching_chunks": only_matching_chunks,
|
|
426
|
+
"rerank": rerank,
|
|
427
|
+
"rewrite_query": rewrite_query,
|
|
428
|
+
},
|
|
429
|
+
search_documents_params.SearchDocumentsParams,
|
|
430
|
+
),
|
|
431
|
+
options=make_request_options(
|
|
432
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
433
|
+
),
|
|
434
|
+
cast_to=SearchDocumentsResponse,
|
|
435
|
+
)
|
|
436
|
+
|
|
167
437
|
async def execute(
|
|
168
438
|
self,
|
|
169
439
|
*,
|
|
@@ -263,38 +533,132 @@ class AsyncSearchResource(AsyncAPIResource):
|
|
|
263
533
|
cast_to=SearchExecuteResponse,
|
|
264
534
|
)
|
|
265
535
|
|
|
536
|
+
async def memories(
|
|
537
|
+
self,
|
|
538
|
+
*,
|
|
539
|
+
q: str,
|
|
540
|
+
container_tag: str | NotGiven = NOT_GIVEN,
|
|
541
|
+
filters: search_memories_params.Filters | NotGiven = NOT_GIVEN,
|
|
542
|
+
include: search_memories_params.Include | NotGiven = NOT_GIVEN,
|
|
543
|
+
limit: int | NotGiven = NOT_GIVEN,
|
|
544
|
+
rerank: bool | NotGiven = NOT_GIVEN,
|
|
545
|
+
rewrite_query: bool | NotGiven = NOT_GIVEN,
|
|
546
|
+
threshold: float | NotGiven = NOT_GIVEN,
|
|
547
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
548
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
549
|
+
extra_headers: Headers | None = None,
|
|
550
|
+
extra_query: Query | None = None,
|
|
551
|
+
extra_body: Body | None = None,
|
|
552
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
553
|
+
) -> SearchMemoriesResponse:
|
|
554
|
+
"""
|
|
555
|
+
Search memory entries - Low latency for conversational
|
|
556
|
+
|
|
557
|
+
Args:
|
|
558
|
+
q: Search query string
|
|
559
|
+
|
|
560
|
+
container_tag: Optional tag this search should be containerized by. This can be an ID for your
|
|
561
|
+
user, a project ID, or any other identifier you wish to use to filter memories.
|
|
562
|
+
|
|
563
|
+
filters: Optional filters to apply to the search
|
|
564
|
+
|
|
565
|
+
limit: Maximum number of results to return
|
|
566
|
+
|
|
567
|
+
rerank: If true, rerank the results based on the query. This is helpful if you want to
|
|
568
|
+
ensure the most relevant results are returned.
|
|
569
|
+
|
|
570
|
+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
|
|
571
|
+
the latency by about 400ms
|
|
572
|
+
|
|
573
|
+
threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
|
|
574
|
+
most memories, more results), 1 is most sensitive (returns lesser memories,
|
|
575
|
+
accurate results)
|
|
576
|
+
|
|
577
|
+
extra_headers: Send extra headers
|
|
578
|
+
|
|
579
|
+
extra_query: Add additional query parameters to the request
|
|
580
|
+
|
|
581
|
+
extra_body: Add additional JSON properties to the request
|
|
582
|
+
|
|
583
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
584
|
+
"""
|
|
585
|
+
return await self._post(
|
|
586
|
+
"/v4/search",
|
|
587
|
+
body=await async_maybe_transform(
|
|
588
|
+
{
|
|
589
|
+
"q": q,
|
|
590
|
+
"container_tag": container_tag,
|
|
591
|
+
"filters": filters,
|
|
592
|
+
"include": include,
|
|
593
|
+
"limit": limit,
|
|
594
|
+
"rerank": rerank,
|
|
595
|
+
"rewrite_query": rewrite_query,
|
|
596
|
+
"threshold": threshold,
|
|
597
|
+
},
|
|
598
|
+
search_memories_params.SearchMemoriesParams,
|
|
599
|
+
),
|
|
600
|
+
options=make_request_options(
|
|
601
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
602
|
+
),
|
|
603
|
+
cast_to=SearchMemoriesResponse,
|
|
604
|
+
)
|
|
605
|
+
|
|
266
606
|
|
|
267
607
|
class SearchResourceWithRawResponse:
|
|
268
608
|
def __init__(self, search: SearchResource) -> None:
|
|
269
609
|
self._search = search
|
|
270
610
|
|
|
611
|
+
self.documents = to_raw_response_wrapper(
|
|
612
|
+
search.documents,
|
|
613
|
+
)
|
|
271
614
|
self.execute = to_raw_response_wrapper(
|
|
272
615
|
search.execute,
|
|
273
616
|
)
|
|
617
|
+
self.memories = to_raw_response_wrapper(
|
|
618
|
+
search.memories,
|
|
619
|
+
)
|
|
274
620
|
|
|
275
621
|
|
|
276
622
|
class AsyncSearchResourceWithRawResponse:
|
|
277
623
|
def __init__(self, search: AsyncSearchResource) -> None:
|
|
278
624
|
self._search = search
|
|
279
625
|
|
|
626
|
+
self.documents = async_to_raw_response_wrapper(
|
|
627
|
+
search.documents,
|
|
628
|
+
)
|
|
280
629
|
self.execute = async_to_raw_response_wrapper(
|
|
281
630
|
search.execute,
|
|
282
631
|
)
|
|
632
|
+
self.memories = async_to_raw_response_wrapper(
|
|
633
|
+
search.memories,
|
|
634
|
+
)
|
|
283
635
|
|
|
284
636
|
|
|
285
637
|
class SearchResourceWithStreamingResponse:
|
|
286
638
|
def __init__(self, search: SearchResource) -> None:
|
|
287
639
|
self._search = search
|
|
288
640
|
|
|
641
|
+
self.documents = to_streamed_response_wrapper(
|
|
642
|
+
search.documents,
|
|
643
|
+
)
|
|
289
644
|
self.execute = to_streamed_response_wrapper(
|
|
290
645
|
search.execute,
|
|
291
646
|
)
|
|
647
|
+
self.memories = to_streamed_response_wrapper(
|
|
648
|
+
search.memories,
|
|
649
|
+
)
|
|
292
650
|
|
|
293
651
|
|
|
294
652
|
class AsyncSearchResourceWithStreamingResponse:
|
|
295
653
|
def __init__(self, search: AsyncSearchResource) -> None:
|
|
296
654
|
self._search = search
|
|
297
655
|
|
|
656
|
+
self.documents = async_to_streamed_response_wrapper(
|
|
657
|
+
search.documents,
|
|
658
|
+
)
|
|
298
659
|
self.execute = async_to_streamed_response_wrapper(
|
|
299
660
|
search.execute,
|
|
300
661
|
)
|
|
662
|
+
self.memories = async_to_streamed_response_wrapper(
|
|
663
|
+
search.memories,
|
|
664
|
+
)
|
supermemory/types/__init__.py
CHANGED
|
@@ -13,12 +13,18 @@ from .search_execute_params import SearchExecuteParams as SearchExecuteParams
|
|
|
13
13
|
from .setting_update_params import SettingUpdateParams as SettingUpdateParams
|
|
14
14
|
from .connection_list_params import ConnectionListParams as ConnectionListParams
|
|
15
15
|
from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
|
|
16
|
+
from .search_memories_params import SearchMemoriesParams as SearchMemoriesParams
|
|
17
|
+
from .search_documents_params import SearchDocumentsParams as SearchDocumentsParams
|
|
16
18
|
from .search_execute_response import SearchExecuteResponse as SearchExecuteResponse
|
|
17
19
|
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
|
|
18
20
|
from .connection_create_params import ConnectionCreateParams as ConnectionCreateParams
|
|
19
21
|
from .connection_import_params import ConnectionImportParams as ConnectionImportParams
|
|
20
22
|
from .connection_list_response import ConnectionListResponse as ConnectionListResponse
|
|
23
|
+
from .search_memories_response import SearchMemoriesResponse as SearchMemoriesResponse
|
|
24
|
+
from .memory_upload_file_params import MemoryUploadFileParams as MemoryUploadFileParams
|
|
25
|
+
from .search_documents_response import SearchDocumentsResponse as SearchDocumentsResponse
|
|
21
26
|
from .connection_create_response import ConnectionCreateResponse as ConnectionCreateResponse
|
|
27
|
+
from .memory_upload_file_response import MemoryUploadFileResponse as MemoryUploadFileResponse
|
|
22
28
|
from .connection_get_by_id_response import ConnectionGetByIDResponse as ConnectionGetByIDResponse
|
|
23
29
|
from .connection_get_by_tags_params import ConnectionGetByTagsParams as ConnectionGetByTagsParams
|
|
24
30
|
from .connection_get_by_tags_response import ConnectionGetByTagsResponse as ConnectionGetByTagsResponse
|
|
@@ -0,0 +1,16 @@
|
|
|
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, Annotated, TypedDict
|
|
6
|
+
|
|
7
|
+
from .._types import FileTypes
|
|
8
|
+
from .._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["MemoryUploadFileParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MemoryUploadFileParams(TypedDict, total=False):
|
|
14
|
+
file: Required[FileTypes]
|
|
15
|
+
|
|
16
|
+
container_tags: Annotated[str, PropertyInfo(alias="containerTags")]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Dict, List, Union, Iterable
|
|
6
|
+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["SearchDocumentsParams", "Filters", "FiltersUnionMember0"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchDocumentsParams(TypedDict, total=False):
|
|
14
|
+
q: Required[str]
|
|
15
|
+
"""Search query string"""
|
|
16
|
+
|
|
17
|
+
categories_filter: Annotated[
|
|
18
|
+
List[Literal["technology", "science", "business", "health"]], PropertyInfo(alias="categoriesFilter")
|
|
19
|
+
]
|
|
20
|
+
"""Optional category filters"""
|
|
21
|
+
|
|
22
|
+
chunk_threshold: Annotated[float, PropertyInfo(alias="chunkThreshold")]
|
|
23
|
+
"""Threshold / sensitivity for chunk selection.
|
|
24
|
+
|
|
25
|
+
0 is least sensitive (returns most chunks, more results), 1 is most sensitive
|
|
26
|
+
(returns lesser chunks, accurate results)
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
|
|
30
|
+
"""Optional tags this search should be containerized by.
|
|
31
|
+
|
|
32
|
+
This can be an ID for your user, a project ID, or any other identifier you wish
|
|
33
|
+
to use to filter memories.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
doc_id: Annotated[str, PropertyInfo(alias="docId")]
|
|
37
|
+
"""Optional document ID to search within.
|
|
38
|
+
|
|
39
|
+
You can use this to find chunks in a very large document.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
document_threshold: Annotated[float, PropertyInfo(alias="documentThreshold")]
|
|
43
|
+
"""Threshold / sensitivity for document selection.
|
|
44
|
+
|
|
45
|
+
0 is least sensitive (returns most documents, more results), 1 is most sensitive
|
|
46
|
+
(returns lesser documents, accurate results)
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
filters: Filters
|
|
50
|
+
"""Optional filters to apply to the search"""
|
|
51
|
+
|
|
52
|
+
include_full_docs: Annotated[bool, PropertyInfo(alias="includeFullDocs")]
|
|
53
|
+
"""If true, include full document in the response.
|
|
54
|
+
|
|
55
|
+
This is helpful if you want a chatbot to know the full context of the document.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
include_summary: Annotated[bool, PropertyInfo(alias="includeSummary")]
|
|
59
|
+
"""If true, include document summary in the response.
|
|
60
|
+
|
|
61
|
+
This is helpful if you want a chatbot to know the full context of the document.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
limit: int
|
|
65
|
+
"""Maximum number of results to return"""
|
|
66
|
+
|
|
67
|
+
only_matching_chunks: Annotated[bool, PropertyInfo(alias="onlyMatchingChunks")]
|
|
68
|
+
"""If true, only return matching chunks without context.
|
|
69
|
+
|
|
70
|
+
Normally, we send the previous and next chunk to provide more context for LLMs.
|
|
71
|
+
If you only want the matching chunk, set this to true.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
rerank: bool
|
|
75
|
+
"""If true, rerank the results based on the query.
|
|
76
|
+
|
|
77
|
+
This is helpful if you want to ensure the most relevant results are returned.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
rewrite_query: Annotated[bool, PropertyInfo(alias="rewriteQuery")]
|
|
81
|
+
"""If true, rewrites the query to make it easier to find documents.
|
|
82
|
+
|
|
83
|
+
This increases the latency by about 400ms
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class FiltersUnionMember0(TypedDict, total=False):
|
|
88
|
+
and_: Annotated[Iterable[object], PropertyInfo(alias="AND")]
|
|
89
|
+
|
|
90
|
+
or_: Annotated[Iterable[object], PropertyInfo(alias="OR")]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Filters: TypeAlias = Union[FiltersUnionMember0, Dict[str, object]]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
|
|
10
|
+
__all__ = ["SearchDocumentsResponse", "Result", "ResultChunk"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ResultChunk(BaseModel):
|
|
14
|
+
content: str
|
|
15
|
+
"""Content of the matching chunk"""
|
|
16
|
+
|
|
17
|
+
is_relevant: bool = FieldInfo(alias="isRelevant")
|
|
18
|
+
"""Whether this chunk is relevant to the query"""
|
|
19
|
+
|
|
20
|
+
score: float
|
|
21
|
+
"""Similarity score for this chunk"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Result(BaseModel):
|
|
25
|
+
chunks: List[ResultChunk]
|
|
26
|
+
"""Matching content chunks from the document"""
|
|
27
|
+
|
|
28
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
29
|
+
"""Document creation date"""
|
|
30
|
+
|
|
31
|
+
document_id: str = FieldInfo(alias="documentId")
|
|
32
|
+
"""ID of the matching document"""
|
|
33
|
+
|
|
34
|
+
metadata: Optional[Dict[str, object]] = None
|
|
35
|
+
"""Document metadata"""
|
|
36
|
+
|
|
37
|
+
score: float
|
|
38
|
+
"""Relevance score of the match"""
|
|
39
|
+
|
|
40
|
+
title: Optional[str] = None
|
|
41
|
+
"""Document title"""
|
|
42
|
+
|
|
43
|
+
type: Optional[str] = None
|
|
44
|
+
"""Document type"""
|
|
45
|
+
|
|
46
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
47
|
+
"""Document last update date"""
|
|
48
|
+
|
|
49
|
+
content: Optional[str] = None
|
|
50
|
+
"""Full document content (only included when includeFullDocs=true)"""
|
|
51
|
+
|
|
52
|
+
summary: Optional[str] = None
|
|
53
|
+
"""Document summary"""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class SearchDocumentsResponse(BaseModel):
|
|
57
|
+
results: List[Result]
|
|
58
|
+
|
|
59
|
+
timing: float
|
|
60
|
+
|
|
61
|
+
total: float
|
|
@@ -46,6 +46,9 @@ class Result(BaseModel):
|
|
|
46
46
|
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
47
47
|
"""Document last update date"""
|
|
48
48
|
|
|
49
|
+
content: Optional[str] = None
|
|
50
|
+
"""Full document content (only included when includeFullDocs=true)"""
|
|
51
|
+
|
|
49
52
|
summary: Optional[str] = None
|
|
50
53
|
"""Document summary"""
|
|
51
54
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Dict, Union, Iterable
|
|
6
|
+
from typing_extensions import Required, Annotated, TypeAlias, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["SearchMemoriesParams", "Filters", "FiltersUnionMember0", "Include"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchMemoriesParams(TypedDict, total=False):
|
|
14
|
+
q: Required[str]
|
|
15
|
+
"""Search query string"""
|
|
16
|
+
|
|
17
|
+
container_tag: Annotated[str, PropertyInfo(alias="containerTag")]
|
|
18
|
+
"""Optional tag this search should be containerized by.
|
|
19
|
+
|
|
20
|
+
This can be an ID for your user, a project ID, or any other identifier you wish
|
|
21
|
+
to use to filter memories.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
filters: Filters
|
|
25
|
+
"""Optional filters to apply to the search"""
|
|
26
|
+
|
|
27
|
+
include: Include
|
|
28
|
+
|
|
29
|
+
limit: int
|
|
30
|
+
"""Maximum number of results to return"""
|
|
31
|
+
|
|
32
|
+
rerank: bool
|
|
33
|
+
"""If true, rerank the results based on the query.
|
|
34
|
+
|
|
35
|
+
This is helpful if you want to ensure the most relevant results are returned.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
rewrite_query: Annotated[bool, PropertyInfo(alias="rewriteQuery")]
|
|
39
|
+
"""If true, rewrites the query to make it easier to find documents.
|
|
40
|
+
|
|
41
|
+
This increases the latency by about 400ms
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
threshold: float
|
|
45
|
+
"""Threshold / sensitivity for memories selection.
|
|
46
|
+
|
|
47
|
+
0 is least sensitive (returns most memories, more results), 1 is most sensitive
|
|
48
|
+
(returns lesser memories, accurate results)
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class FiltersUnionMember0(TypedDict, total=False):
|
|
53
|
+
and_: Annotated[Iterable[object], PropertyInfo(alias="AND")]
|
|
54
|
+
|
|
55
|
+
or_: Annotated[Iterable[object], PropertyInfo(alias="OR")]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Filters: TypeAlias = Union[FiltersUnionMember0, Dict[str, object]]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Include(TypedDict, total=False):
|
|
62
|
+
documents: bool
|
|
63
|
+
|
|
64
|
+
related_memories: Annotated[bool, PropertyInfo(alias="relatedMemories")]
|
|
65
|
+
|
|
66
|
+
summaries: bool
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing_extensions import Literal
|
|
6
|
+
|
|
7
|
+
from pydantic import Field as FieldInfo
|
|
8
|
+
|
|
9
|
+
from .._models import BaseModel
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"SearchMemoriesResponse",
|
|
13
|
+
"Result",
|
|
14
|
+
"ResultContext",
|
|
15
|
+
"ResultContextChild",
|
|
16
|
+
"ResultContextParent",
|
|
17
|
+
"ResultDocument",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ResultContextChild(BaseModel):
|
|
22
|
+
memory: str
|
|
23
|
+
"""The contextual memory content"""
|
|
24
|
+
|
|
25
|
+
relation: Literal["updates", "extends", "derives"]
|
|
26
|
+
"""Relation type between this memory and its parent/child"""
|
|
27
|
+
|
|
28
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
29
|
+
"""Contextual memory last update date"""
|
|
30
|
+
|
|
31
|
+
metadata: Optional[Dict[str, object]] = None
|
|
32
|
+
"""Contextual memory metadata"""
|
|
33
|
+
|
|
34
|
+
version: Optional[float] = None
|
|
35
|
+
"""
|
|
36
|
+
Relative version distance from the primary memory (+1 for direct child, +2 for
|
|
37
|
+
grand-child, etc.)
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ResultContextParent(BaseModel):
|
|
42
|
+
memory: str
|
|
43
|
+
"""The contextual memory content"""
|
|
44
|
+
|
|
45
|
+
relation: Literal["updates", "extends", "derives"]
|
|
46
|
+
"""Relation type between this memory and its parent/child"""
|
|
47
|
+
|
|
48
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
49
|
+
"""Contextual memory last update date"""
|
|
50
|
+
|
|
51
|
+
metadata: Optional[Dict[str, object]] = None
|
|
52
|
+
"""Contextual memory metadata"""
|
|
53
|
+
|
|
54
|
+
version: Optional[float] = None
|
|
55
|
+
"""
|
|
56
|
+
Relative version distance from the primary memory (-1 for direct parent, -2 for
|
|
57
|
+
grand-parent, etc.)
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class ResultContext(BaseModel):
|
|
62
|
+
children: Optional[List[ResultContextChild]] = None
|
|
63
|
+
|
|
64
|
+
parents: Optional[List[ResultContextParent]] = None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ResultDocument(BaseModel):
|
|
68
|
+
id: str
|
|
69
|
+
"""Document ID"""
|
|
70
|
+
|
|
71
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
72
|
+
"""Document creation date"""
|
|
73
|
+
|
|
74
|
+
metadata: Optional[Dict[str, object]] = None
|
|
75
|
+
"""Document metadata"""
|
|
76
|
+
|
|
77
|
+
title: str
|
|
78
|
+
"""Document title"""
|
|
79
|
+
|
|
80
|
+
type: str
|
|
81
|
+
"""Document type"""
|
|
82
|
+
|
|
83
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
84
|
+
"""Document last update date"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Result(BaseModel):
|
|
88
|
+
id: str
|
|
89
|
+
"""Memory entry ID"""
|
|
90
|
+
|
|
91
|
+
memory: str
|
|
92
|
+
"""The memory content"""
|
|
93
|
+
|
|
94
|
+
metadata: Optional[Dict[str, object]] = None
|
|
95
|
+
"""Memory metadata"""
|
|
96
|
+
|
|
97
|
+
similarity: float
|
|
98
|
+
"""Similarity score between the query and memory entry"""
|
|
99
|
+
|
|
100
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
101
|
+
"""Memory last update date"""
|
|
102
|
+
|
|
103
|
+
context: Optional[ResultContext] = None
|
|
104
|
+
"""Object containing arrays of parent and child contextual memories"""
|
|
105
|
+
|
|
106
|
+
documents: Optional[List[ResultDocument]] = None
|
|
107
|
+
"""Associated documents for this memory entry"""
|
|
108
|
+
|
|
109
|
+
version: Optional[float] = None
|
|
110
|
+
"""Version number of this memory entry"""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class SearchMemoriesResponse(BaseModel):
|
|
114
|
+
results: List[Result]
|
|
115
|
+
"""Array of matching memory entries with similarity scores"""
|
|
116
|
+
|
|
117
|
+
timing: float
|
|
118
|
+
"""Search execution time in milliseconds"""
|
|
119
|
+
|
|
120
|
+
total: float
|
|
121
|
+
"""Total number of results returned"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: supermemory
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0a26
|
|
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
|
|
@@ -67,7 +67,7 @@ client = Supermemory(
|
|
|
67
67
|
api_key=os.environ.get("SUPERMEMORY_API_KEY"), # This is the default and can be omitted
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
-
response = client.search.
|
|
70
|
+
response = client.search.documents(
|
|
71
71
|
q="documents related to python",
|
|
72
72
|
)
|
|
73
73
|
print(response.results)
|
|
@@ -93,7 +93,7 @@ client = AsyncSupermemory(
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
async def main() -> None:
|
|
96
|
-
response = await client.search.
|
|
96
|
+
response = await client.search.documents(
|
|
97
97
|
q="documents related to python",
|
|
98
98
|
)
|
|
99
99
|
print(response.results)
|
|
@@ -128,7 +128,7 @@ async def main() -> None:
|
|
|
128
128
|
api_key="My API Key",
|
|
129
129
|
http_client=DefaultAioHttpClient(),
|
|
130
130
|
) as client:
|
|
131
|
-
response = await client.search.
|
|
131
|
+
response = await client.search.documents(
|
|
132
132
|
q="documents related to python",
|
|
133
133
|
)
|
|
134
134
|
print(response.results)
|
|
@@ -146,6 +146,39 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
|
|
|
146
146
|
|
|
147
147
|
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`.
|
|
148
148
|
|
|
149
|
+
## Nested params
|
|
150
|
+
|
|
151
|
+
Nested parameters are dictionaries, typed using `TypedDict`, for example:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from supermemory import Supermemory
|
|
155
|
+
|
|
156
|
+
client = Supermemory()
|
|
157
|
+
|
|
158
|
+
response = client.search.memories(
|
|
159
|
+
q="machine learning concepts",
|
|
160
|
+
include={},
|
|
161
|
+
)
|
|
162
|
+
print(response.include)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## File uploads
|
|
166
|
+
|
|
167
|
+
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)`.
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from pathlib import Path
|
|
171
|
+
from supermemory import Supermemory
|
|
172
|
+
|
|
173
|
+
client = Supermemory()
|
|
174
|
+
|
|
175
|
+
client.memories.upload_file(
|
|
176
|
+
file=Path("/path/to/file"),
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
149
182
|
## Handling errors
|
|
150
183
|
|
|
151
184
|
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=2KcNz77blgIaQddenKFBrWXUqBG7IlP4vGuVYTix5bk,16890
|
|
|
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=9QITJCyATjxJqhMXckfLrrOKltxCpKhbrlZX_NcL9WQ,3616
|
|
8
8
|
supermemory/_models.py,sha256=KvjsMfb88XZlFUKVoOxr8OyDj47MhoH2OKqWNEbBhk4,30010
|
|
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=jThVcnKccGKWmZYBKHOj6ADDGEARSb54ix862p4Q91M,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,10 +26,10 @@ supermemory/_utils/_utils.py,sha256=ts4CiiuNpFiGB6YMdkQRh2SZvYvsl7mAF-JWHCcLDf4,
|
|
|
26
26
|
supermemory/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
|
27
27
|
supermemory/resources/__init__.py,sha256=c1dal-ngMY7gwIf9PDPapYx6rHi670pREX5t3_d6298,2019
|
|
28
28
|
supermemory/resources/connections.py,sha256=-DabGIc4_3qFvFRmBOdHGtu4NkaUOaYz3y50CjpqMKQ,33199
|
|
29
|
-
supermemory/resources/memories.py,sha256=
|
|
30
|
-
supermemory/resources/search.py,sha256=
|
|
29
|
+
supermemory/resources/memories.py,sha256=sG4YD7Vkz6wRUE0cyNu1W0c7DoxZPnfteizV6T5bEWU,30772
|
|
30
|
+
supermemory/resources/search.py,sha256=Lp1SchUinbM9AyvKghz4SCqFEohr5KZTegWMqF4po2I,28497
|
|
31
31
|
supermemory/resources/settings.py,sha256=tLM7ya1CEYI_TO8DMP_KLxXHqsxOeq3R3Xs4CQnvPuU,11855
|
|
32
|
-
supermemory/types/__init__.py,sha256=
|
|
32
|
+
supermemory/types/__init__.py,sha256=xCyl1ivjR-Viae5zOWa8jmzs24ueiSz3Fw_yIAUjFGk,2875
|
|
33
33
|
supermemory/types/connection_create_params.py,sha256=bYYKu3ns60PX6Mt34UQUpYwThB3SBZsKn5tW0c46DUM,630
|
|
34
34
|
supermemory/types/connection_create_response.py,sha256=i4sb0DSRs7wVVd8xDBOtr7vw-YbaeZ7MydlQLYvlvJs,468
|
|
35
35
|
supermemory/types/connection_delete_by_id_response.py,sha256=guD1vxqV2wiQnwnWCZSQH0z2HYXQOtvicRzouPVkHXA,243
|
|
@@ -50,12 +50,18 @@ supermemory/types/memory_list_params.py,sha256=nE4fnYdubdjbGy5-7BxmSms6owZZIbv8P
|
|
|
50
50
|
supermemory/types/memory_list_response.py,sha256=Lq2ChggQ1YCFQLi2M9u61hxRwGf2ib3p9_X8mywJF78,2620
|
|
51
51
|
supermemory/types/memory_update_params.py,sha256=kyNU53my_W0wVpxgjPMY8IPDi3ccjhqYKkI1OiL6MKQ,1514
|
|
52
52
|
supermemory/types/memory_update_response.py,sha256=fvfO9lGM8xv2EUOQfOSxqig6fx6-ykq7syW69er_2ng,225
|
|
53
|
+
supermemory/types/memory_upload_file_params.py,sha256=jE3IxTOsFiuVQsi8b-ql5Q4ZT5HJG2X1ysL8mHCgdLQ,447
|
|
54
|
+
supermemory/types/memory_upload_file_response.py,sha256=KTq6AExBMz7eMt8az1TgMSSNMTktKk0d0xItCwHRNl0,233
|
|
55
|
+
supermemory/types/search_documents_params.py,sha256=ZugNc4gg8a8O_CqGL_zlHpMpEQRe91ACtTSHwGm0fsw,3134
|
|
56
|
+
supermemory/types/search_documents_response.py,sha256=dCQ1UUOALmfPqnUpX_-_kFbV4eHPFcuT1b7AVtLq5y4,1464
|
|
53
57
|
supermemory/types/search_execute_params.py,sha256=8JRtcQ7G1TmG9JW-f1XwNmvT1llM6FsPx0kkQN1Ellw,3130
|
|
54
|
-
supermemory/types/search_execute_response.py,sha256=
|
|
58
|
+
supermemory/types/search_execute_response.py,sha256=U1Fh4JX433A442Di9nnaQq6ts1olDdz3-SSbKzIFBPc,1460
|
|
59
|
+
supermemory/types/search_memories_params.py,sha256=4SI8Z3ji_E_yqKmY5Nl-mL-7xODmRVV3TPsAeVefekU,1860
|
|
60
|
+
supermemory/types/search_memories_response.py,sha256=oXy9qe9Ri-WAUcpU3RzwuHgH-_DAwppyu33Bzfm8BZY,3048
|
|
55
61
|
supermemory/types/setting_get_response.py,sha256=WvgAb9zGMsMnAhLiYk6h5NBptnq0D06TnuoI4EJg5Ds,1648
|
|
56
62
|
supermemory/types/setting_update_params.py,sha256=KsreaS35v25aRKBY5vHna3hZ31U3b1Q5ruQLoM0gcyE,1710
|
|
57
63
|
supermemory/types/setting_update_response.py,sha256=F__RcFFWiiSw11IV8PsWn6POEb1crDwO8QwHEQToVuQ,1806
|
|
58
|
-
supermemory-3.0.
|
|
59
|
-
supermemory-3.0.
|
|
60
|
-
supermemory-3.0.
|
|
61
|
-
supermemory-3.0.
|
|
64
|
+
supermemory-3.0.0a26.dist-info/METADATA,sha256=8e65Um3Ioz2Jx0yFx_Y7l0prO5iELH4YczpE6CVRxhQ,14689
|
|
65
|
+
supermemory-3.0.0a26.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
66
|
+
supermemory-3.0.0a26.dist-info/licenses/LICENSE,sha256=M2NcpYEBpakciOULpWzo-xO2Lincf74gGwfaU00Sct0,11341
|
|
67
|
+
supermemory-3.0.0a26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|