supermemory 3.0.0a30__py3-none-any.whl → 3.1.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.
Potentially problematic release.
This version of supermemory might be problematic. Click here for more details.
- supermemory/__init__.py +3 -1
- supermemory/_base_client.py +9 -9
- supermemory/_client.py +25 -9
- supermemory/_files.py +1 -1
- supermemory/_models.py +10 -4
- supermemory/_qs.py +7 -7
- supermemory/_types.py +18 -11
- supermemory/_utils/_transform.py +2 -2
- supermemory/_utils/_utils.py +4 -4
- supermemory/_version.py +1 -1
- supermemory/resources/__init__.py +28 -0
- supermemory/resources/connections.py +31 -31
- supermemory/resources/documents.py +894 -0
- supermemory/resources/memories.py +894 -0
- supermemory/resources/search.py +75 -75
- supermemory/resources/settings.py +31 -31
- supermemory/types/__init__.py +18 -0
- supermemory/types/document_add_params.py +69 -0
- supermemory/types/document_add_response.py +11 -0
- supermemory/types/document_get_response.py +104 -0
- supermemory/types/document_list_params.py +111 -0
- supermemory/types/document_list_response.py +95 -0
- supermemory/types/document_update_params.py +69 -0
- supermemory/types/document_update_response.py +11 -0
- supermemory/types/document_upload_file_params.py +36 -0
- supermemory/types/document_upload_file_response.py +11 -0
- supermemory/types/memory_add_params.py +69 -0
- supermemory/types/memory_add_response.py +11 -0
- supermemory/types/memory_get_response.py +104 -0
- supermemory/types/memory_list_params.py +111 -0
- supermemory/types/memory_list_response.py +95 -0
- supermemory/types/memory_update_params.py +69 -0
- supermemory/types/memory_update_response.py +11 -0
- supermemory/types/memory_upload_file_params.py +36 -0
- supermemory/types/memory_upload_file_response.py +11 -0
- supermemory/types/search_documents_params.py +68 -7
- supermemory/types/search_execute_params.py +68 -7
- supermemory/types/search_memories_params.py +77 -8
- {supermemory-3.0.0a30.dist-info → supermemory-3.1.0.dist-info}/METADATA +32 -15
- supermemory-3.1.0.dist-info/RECORD +80 -0
- supermemory-3.0.0a30.dist-info/RECORD +0 -60
- {supermemory-3.0.0a30.dist-info → supermemory-3.1.0.dist-info}/WHEEL +0 -0
- {supermemory-3.0.0a30.dist-info → supermemory-3.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Union, 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__ = ["MemoryListResponse", "Memory", "Pagination"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Memory(BaseModel):
|
|
15
|
+
id: str
|
|
16
|
+
"""Unique identifier of the document."""
|
|
17
|
+
|
|
18
|
+
connection_id: Optional[str] = FieldInfo(alias="connectionId", default=None)
|
|
19
|
+
"""Optional ID of connection the document was created from.
|
|
20
|
+
|
|
21
|
+
This is useful for identifying the source of the document.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
25
|
+
"""Creation timestamp"""
|
|
26
|
+
|
|
27
|
+
custom_id: Optional[str] = FieldInfo(alias="customId", default=None)
|
|
28
|
+
"""Optional custom ID of the document.
|
|
29
|
+
|
|
30
|
+
This could be an ID from your database that will uniquely identify this
|
|
31
|
+
document.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
metadata: Union[str, float, bool, Dict[str, object], List[object], None] = None
|
|
35
|
+
"""Optional metadata for the document.
|
|
36
|
+
|
|
37
|
+
This is used to store additional information about the document. You can use
|
|
38
|
+
this to store any additional information you need about the document. Metadata
|
|
39
|
+
can be filtered through. Keys must be strings and are case sensitive. Values can
|
|
40
|
+
be strings, numbers, or booleans. You cannot nest objects.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
status: Literal["unknown", "queued", "extracting", "chunking", "embedding", "indexing", "done", "failed"]
|
|
44
|
+
"""Status of the document"""
|
|
45
|
+
|
|
46
|
+
summary: Optional[str] = None
|
|
47
|
+
"""Summary of the document content"""
|
|
48
|
+
|
|
49
|
+
title: Optional[str] = None
|
|
50
|
+
"""Title of the document"""
|
|
51
|
+
|
|
52
|
+
type: Literal[
|
|
53
|
+
"text",
|
|
54
|
+
"pdf",
|
|
55
|
+
"tweet",
|
|
56
|
+
"google_doc",
|
|
57
|
+
"google_slide",
|
|
58
|
+
"google_sheet",
|
|
59
|
+
"image",
|
|
60
|
+
"video",
|
|
61
|
+
"notion_doc",
|
|
62
|
+
"webpage",
|
|
63
|
+
"onedrive",
|
|
64
|
+
]
|
|
65
|
+
"""Type of the document"""
|
|
66
|
+
|
|
67
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
68
|
+
"""Last update timestamp"""
|
|
69
|
+
|
|
70
|
+
container_tags: Optional[List[str]] = FieldInfo(alias="containerTags", default=None)
|
|
71
|
+
"""Optional tags this document should be containerized by.
|
|
72
|
+
|
|
73
|
+
This can be an ID for your user, a project ID, or any other identifier you wish
|
|
74
|
+
to use to group documents.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
content: Optional[str] = None
|
|
78
|
+
"""Content of the document (only included when includeContent=true)"""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Pagination(BaseModel):
|
|
82
|
+
current_page: float = FieldInfo(alias="currentPage")
|
|
83
|
+
|
|
84
|
+
limit: float
|
|
85
|
+
|
|
86
|
+
total_items: float = FieldInfo(alias="totalItems")
|
|
87
|
+
|
|
88
|
+
total_pages: float = FieldInfo(alias="totalPages")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class MemoryListResponse(BaseModel):
|
|
92
|
+
memories: List[Memory]
|
|
93
|
+
|
|
94
|
+
pagination: Pagination
|
|
95
|
+
"""Pagination metadata"""
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._types import SequenceNotStr
|
|
9
|
+
from .._utils import PropertyInfo
|
|
10
|
+
|
|
11
|
+
__all__ = ["MemoryUpdateParams"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MemoryUpdateParams(TypedDict, total=False):
|
|
15
|
+
container_tag: Annotated[str, PropertyInfo(alias="containerTag")]
|
|
16
|
+
"""Optional tag this document should be containerized by.
|
|
17
|
+
|
|
18
|
+
This can be an ID for your user, a project ID, or any other identifier you wish
|
|
19
|
+
to use to group documents.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
|
|
23
|
+
"""
|
|
24
|
+
(DEPRECATED: Use containerTag instead) Optional tags this document should be
|
|
25
|
+
containerized by. This can be an ID for your user, a project ID, or any other
|
|
26
|
+
identifier you wish to use to group documents.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
content: str
|
|
30
|
+
"""The content to extract and process into a document.
|
|
31
|
+
|
|
32
|
+
This can be a URL to a website, a PDF, an image, or a video.
|
|
33
|
+
|
|
34
|
+
Plaintext: Any plaintext format
|
|
35
|
+
|
|
36
|
+
URL: A URL to a website, PDF, image, or video
|
|
37
|
+
|
|
38
|
+
We automatically detect the content type from the url's response format.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
custom_id: Annotated[str, PropertyInfo(alias="customId")]
|
|
42
|
+
"""Optional custom ID of the document.
|
|
43
|
+
|
|
44
|
+
This could be an ID from your database that will uniquely identify this
|
|
45
|
+
document.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
file_type: Annotated[str, PropertyInfo(alias="fileType")]
|
|
49
|
+
"""Optional file type override to force specific processing behavior.
|
|
50
|
+
|
|
51
|
+
Valid values: text, pdf, tweet, google_doc, google_slide, google_sheet, image,
|
|
52
|
+
video, notion_doc, webpage, onedrive
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]]
|
|
56
|
+
"""Optional metadata for the document.
|
|
57
|
+
|
|
58
|
+
This is used to store additional information about the document. You can use
|
|
59
|
+
this to store any additional information you need about the document. Metadata
|
|
60
|
+
can be filtered through. Keys must be strings and are case sensitive. Values can
|
|
61
|
+
be strings, numbers, or booleans. You cannot nest objects.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
mime_type: Annotated[str, PropertyInfo(alias="mimeType")]
|
|
65
|
+
"""Required when fileType is 'image' or 'video'.
|
|
66
|
+
|
|
67
|
+
Specifies the exact MIME type to use (e.g., 'image/png', 'image/jpeg',
|
|
68
|
+
'video/mp4', 'video/webm')
|
|
69
|
+
"""
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
"""File to upload and process"""
|
|
16
|
+
|
|
17
|
+
container_tags: Annotated[str, PropertyInfo(alias="containerTags")]
|
|
18
|
+
"""Optional JSON string of container tags array.
|
|
19
|
+
|
|
20
|
+
This can be an ID for your user, a project ID, or any other identifier you wish
|
|
21
|
+
to use to group documents.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
file_type: Annotated[str, PropertyInfo(alias="fileType")]
|
|
25
|
+
"""Optional file type override to force specific processing behavior.
|
|
26
|
+
|
|
27
|
+
Valid values: text, pdf, tweet, google_doc, google_slide, google_sheet, image,
|
|
28
|
+
video, notion_doc, webpage, onedrive
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
mime_type: Annotated[str, PropertyInfo(alias="mimeType")]
|
|
32
|
+
"""Required when fileType is 'image' or 'video'.
|
|
33
|
+
|
|
34
|
+
Specifies the exact MIME type to use (e.g., 'image/png', 'image/jpeg',
|
|
35
|
+
'video/mp4', 'video/webm')
|
|
36
|
+
"""
|
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import List, Union, Iterable
|
|
6
6
|
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
|
7
7
|
|
|
8
8
|
from .._types import SequenceNotStr
|
|
9
9
|
from .._utils import PropertyInfo
|
|
10
10
|
|
|
11
|
-
__all__ = [
|
|
11
|
+
__all__ = [
|
|
12
|
+
"SearchDocumentsParams",
|
|
13
|
+
"Filters",
|
|
14
|
+
"FiltersOr",
|
|
15
|
+
"FiltersOrOr",
|
|
16
|
+
"FiltersOrOrUnionMember0",
|
|
17
|
+
"FiltersOrOrOr",
|
|
18
|
+
"FiltersOrOrAnd",
|
|
19
|
+
"FiltersAnd",
|
|
20
|
+
"FiltersAndAnd",
|
|
21
|
+
"FiltersAndAndUnionMember0",
|
|
22
|
+
"FiltersAndAndOr",
|
|
23
|
+
"FiltersAndAndAnd",
|
|
24
|
+
]
|
|
12
25
|
|
|
13
26
|
|
|
14
27
|
class SearchDocumentsParams(TypedDict, total=False):
|
|
@@ -48,7 +61,7 @@ class SearchDocumentsParams(TypedDict, total=False):
|
|
|
48
61
|
"""
|
|
49
62
|
|
|
50
63
|
filters: Filters
|
|
51
|
-
"""Optional filters to apply to the search"""
|
|
64
|
+
"""Optional filters to apply to the search. Can be a JSON string or Query object."""
|
|
52
65
|
|
|
53
66
|
include_full_docs: Annotated[bool, PropertyInfo(alias="includeFullDocs")]
|
|
54
67
|
"""If true, include full document in the response.
|
|
@@ -85,10 +98,58 @@ class SearchDocumentsParams(TypedDict, total=False):
|
|
|
85
98
|
"""
|
|
86
99
|
|
|
87
100
|
|
|
88
|
-
class
|
|
89
|
-
|
|
101
|
+
class FiltersOrOrUnionMember0(TypedDict, total=False):
|
|
102
|
+
key: Required[str]
|
|
90
103
|
|
|
91
|
-
|
|
104
|
+
value: Required[str]
|
|
92
105
|
|
|
106
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
93
107
|
|
|
94
|
-
|
|
108
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
109
|
+
|
|
110
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class FiltersOrOrOr(TypedDict, total=False):
|
|
114
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class FiltersOrOrAnd(TypedDict, total=False):
|
|
118
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
FiltersOrOr: TypeAlias = Union[FiltersOrOrUnionMember0, FiltersOrOrOr, FiltersOrOrAnd]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class FiltersOr(TypedDict, total=False):
|
|
125
|
+
or_: Required[Annotated[Iterable[FiltersOrOr], PropertyInfo(alias="OR")]]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class FiltersAndAndUnionMember0(TypedDict, total=False):
|
|
129
|
+
key: Required[str]
|
|
130
|
+
|
|
131
|
+
value: Required[str]
|
|
132
|
+
|
|
133
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
134
|
+
|
|
135
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
136
|
+
|
|
137
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class FiltersAndAndOr(TypedDict, total=False):
|
|
141
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class FiltersAndAndAnd(TypedDict, total=False):
|
|
145
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
FiltersAndAnd: TypeAlias = Union[FiltersAndAndUnionMember0, FiltersAndAndOr, FiltersAndAndAnd]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class FiltersAnd(TypedDict, total=False):
|
|
152
|
+
and_: Required[Annotated[Iterable[FiltersAndAnd], PropertyInfo(alias="AND")]]
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
Filters: TypeAlias = Union[FiltersOr, FiltersAnd]
|
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import List, Union, Iterable
|
|
6
6
|
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
|
7
7
|
|
|
8
8
|
from .._types import SequenceNotStr
|
|
9
9
|
from .._utils import PropertyInfo
|
|
10
10
|
|
|
11
|
-
__all__ = [
|
|
11
|
+
__all__ = [
|
|
12
|
+
"SearchExecuteParams",
|
|
13
|
+
"Filters",
|
|
14
|
+
"FiltersOr",
|
|
15
|
+
"FiltersOrOr",
|
|
16
|
+
"FiltersOrOrUnionMember0",
|
|
17
|
+
"FiltersOrOrOr",
|
|
18
|
+
"FiltersOrOrAnd",
|
|
19
|
+
"FiltersAnd",
|
|
20
|
+
"FiltersAndAnd",
|
|
21
|
+
"FiltersAndAndUnionMember0",
|
|
22
|
+
"FiltersAndAndOr",
|
|
23
|
+
"FiltersAndAndAnd",
|
|
24
|
+
]
|
|
12
25
|
|
|
13
26
|
|
|
14
27
|
class SearchExecuteParams(TypedDict, total=False):
|
|
@@ -48,7 +61,7 @@ class SearchExecuteParams(TypedDict, total=False):
|
|
|
48
61
|
"""
|
|
49
62
|
|
|
50
63
|
filters: Filters
|
|
51
|
-
"""Optional filters to apply to the search"""
|
|
64
|
+
"""Optional filters to apply to the search. Can be a JSON string or Query object."""
|
|
52
65
|
|
|
53
66
|
include_full_docs: Annotated[bool, PropertyInfo(alias="includeFullDocs")]
|
|
54
67
|
"""If true, include full document in the response.
|
|
@@ -85,10 +98,58 @@ class SearchExecuteParams(TypedDict, total=False):
|
|
|
85
98
|
"""
|
|
86
99
|
|
|
87
100
|
|
|
88
|
-
class
|
|
89
|
-
|
|
101
|
+
class FiltersOrOrUnionMember0(TypedDict, total=False):
|
|
102
|
+
key: Required[str]
|
|
90
103
|
|
|
91
|
-
|
|
104
|
+
value: Required[str]
|
|
92
105
|
|
|
106
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
93
107
|
|
|
94
|
-
|
|
108
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
109
|
+
|
|
110
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class FiltersOrOrOr(TypedDict, total=False):
|
|
114
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class FiltersOrOrAnd(TypedDict, total=False):
|
|
118
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
FiltersOrOr: TypeAlias = Union[FiltersOrOrUnionMember0, FiltersOrOrOr, FiltersOrOrAnd]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class FiltersOr(TypedDict, total=False):
|
|
125
|
+
or_: Required[Annotated[Iterable[FiltersOrOr], PropertyInfo(alias="OR")]]
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class FiltersAndAndUnionMember0(TypedDict, total=False):
|
|
129
|
+
key: Required[str]
|
|
130
|
+
|
|
131
|
+
value: Required[str]
|
|
132
|
+
|
|
133
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
134
|
+
|
|
135
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
136
|
+
|
|
137
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class FiltersAndAndOr(TypedDict, total=False):
|
|
141
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class FiltersAndAndAnd(TypedDict, total=False):
|
|
145
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
FiltersAndAnd: TypeAlias = Union[FiltersAndAndUnionMember0, FiltersAndAndOr, FiltersAndAndAnd]
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class FiltersAnd(TypedDict, total=False):
|
|
152
|
+
and_: Required[Annotated[Iterable[FiltersAndAnd], PropertyInfo(alias="AND")]]
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
Filters: TypeAlias = Union[FiltersOr, FiltersAnd]
|
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
6
|
-
from typing_extensions import Required, Annotated, TypeAlias, TypedDict
|
|
5
|
+
from typing import Union, Iterable
|
|
6
|
+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
|
7
7
|
|
|
8
8
|
from .._utils import PropertyInfo
|
|
9
9
|
|
|
10
|
-
__all__ = [
|
|
10
|
+
__all__ = [
|
|
11
|
+
"SearchMemoriesParams",
|
|
12
|
+
"Filters",
|
|
13
|
+
"FiltersOr",
|
|
14
|
+
"FiltersOrOr",
|
|
15
|
+
"FiltersOrOrUnionMember0",
|
|
16
|
+
"FiltersOrOrOr",
|
|
17
|
+
"FiltersOrOrAnd",
|
|
18
|
+
"FiltersAnd",
|
|
19
|
+
"FiltersAndAnd",
|
|
20
|
+
"FiltersAndAndUnionMember0",
|
|
21
|
+
"FiltersAndAndOr",
|
|
22
|
+
"FiltersAndAndAnd",
|
|
23
|
+
"Include",
|
|
24
|
+
]
|
|
11
25
|
|
|
12
26
|
|
|
13
27
|
class SearchMemoriesParams(TypedDict, total=False):
|
|
@@ -22,7 +36,7 @@ class SearchMemoriesParams(TypedDict, total=False):
|
|
|
22
36
|
"""
|
|
23
37
|
|
|
24
38
|
filters: Filters
|
|
25
|
-
"""Optional filters to apply to the search"""
|
|
39
|
+
"""Optional filters to apply to the search. Can be a JSON string or Query object."""
|
|
26
40
|
|
|
27
41
|
include: Include
|
|
28
42
|
|
|
@@ -49,18 +63,73 @@ class SearchMemoriesParams(TypedDict, total=False):
|
|
|
49
63
|
"""
|
|
50
64
|
|
|
51
65
|
|
|
52
|
-
class
|
|
53
|
-
|
|
66
|
+
class FiltersOrOrUnionMember0(TypedDict, total=False):
|
|
67
|
+
key: Required[str]
|
|
54
68
|
|
|
55
|
-
|
|
69
|
+
value: Required[str]
|
|
56
70
|
|
|
71
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
74
|
+
|
|
75
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class FiltersOrOrOr(TypedDict, total=False):
|
|
79
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class FiltersOrOrAnd(TypedDict, total=False):
|
|
83
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
FiltersOrOr: TypeAlias = Union[FiltersOrOrUnionMember0, FiltersOrOrOr, FiltersOrOrAnd]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class FiltersOr(TypedDict, total=False):
|
|
90
|
+
or_: Required[Annotated[Iterable[FiltersOrOr], PropertyInfo(alias="OR")]]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class FiltersAndAndUnionMember0(TypedDict, total=False):
|
|
94
|
+
key: Required[str]
|
|
95
|
+
|
|
96
|
+
value: Required[str]
|
|
97
|
+
|
|
98
|
+
filter_type: Annotated[Literal["metadata", "numeric", "array_contains"], PropertyInfo(alias="filterType")]
|
|
99
|
+
|
|
100
|
+
negate: Union[bool, Literal["true", "false"]]
|
|
101
|
+
|
|
102
|
+
numeric_operator: Annotated[Literal[">", "<", ">=", "<=", "="], PropertyInfo(alias="numericOperator")]
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class FiltersAndAndOr(TypedDict, total=False):
|
|
106
|
+
or_: Required[Annotated[Iterable[object], PropertyInfo(alias="OR")]]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class FiltersAndAndAnd(TypedDict, total=False):
|
|
110
|
+
and_: Required[Annotated[Iterable[object], PropertyInfo(alias="AND")]]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
FiltersAndAnd: TypeAlias = Union[FiltersAndAndUnionMember0, FiltersAndAndOr, FiltersAndAndAnd]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class FiltersAnd(TypedDict, total=False):
|
|
117
|
+
and_: Required[Annotated[Iterable[FiltersAndAnd], PropertyInfo(alias="AND")]]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Filters: TypeAlias = Union[FiltersOr, FiltersAnd]
|
|
59
121
|
|
|
60
122
|
|
|
61
123
|
class Include(TypedDict, total=False):
|
|
62
124
|
documents: bool
|
|
63
125
|
|
|
126
|
+
forgotten_memories: Annotated[bool, PropertyInfo(alias="forgottenMemories")]
|
|
127
|
+
"""If true, include forgotten memories in search results.
|
|
128
|
+
|
|
129
|
+
Forgotten memories are memories that have been explicitly forgotten or have
|
|
130
|
+
passed their expiration date.
|
|
131
|
+
"""
|
|
132
|
+
|
|
64
133
|
related_memories: Annotated[bool, PropertyInfo(alias="relatedMemories")]
|
|
65
134
|
|
|
66
135
|
summaries: bool
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: supermemory
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
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
|
|
@@ -52,7 +52,7 @@ The REST API documentation can be found on [docs.supermemory.ai](https://docs.su
|
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
54
|
# install from PyPI
|
|
55
|
-
pip install
|
|
55
|
+
pip install supermemory
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
## Usage
|
|
@@ -112,7 +112,7 @@ You can enable this by installing `aiohttp`:
|
|
|
112
112
|
|
|
113
113
|
```sh
|
|
114
114
|
# install from PyPI
|
|
115
|
-
pip install
|
|
115
|
+
pip install supermemory[aiohttp]
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
|
|
@@ -162,6 +162,23 @@ response = client.search.memories(
|
|
|
162
162
|
print(response.include)
|
|
163
163
|
```
|
|
164
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
|
+
|
|
165
182
|
## Handling errors
|
|
166
183
|
|
|
167
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.
|
|
@@ -178,8 +195,8 @@ from supermemory import Supermemory
|
|
|
178
195
|
client = Supermemory()
|
|
179
196
|
|
|
180
197
|
try:
|
|
181
|
-
client.
|
|
182
|
-
|
|
198
|
+
client.memories.add(
|
|
199
|
+
content="This is a detailed article about machine learning concepts...",
|
|
183
200
|
)
|
|
184
201
|
except supermemory.APIConnectionError as e:
|
|
185
202
|
print("The server could not be reached")
|
|
@@ -223,8 +240,8 @@ client = Supermemory(
|
|
|
223
240
|
)
|
|
224
241
|
|
|
225
242
|
# Or, configure per-request:
|
|
226
|
-
client.with_options(max_retries=5).
|
|
227
|
-
|
|
243
|
+
client.with_options(max_retries=5).memories.add(
|
|
244
|
+
content="This is a detailed article about machine learning concepts...",
|
|
228
245
|
)
|
|
229
246
|
```
|
|
230
247
|
|
|
@@ -248,8 +265,8 @@ client = Supermemory(
|
|
|
248
265
|
)
|
|
249
266
|
|
|
250
267
|
# Override per-request:
|
|
251
|
-
client.with_options(timeout=5.0).
|
|
252
|
-
|
|
268
|
+
client.with_options(timeout=5.0).memories.add(
|
|
269
|
+
content="This is a detailed article about machine learning concepts...",
|
|
253
270
|
)
|
|
254
271
|
```
|
|
255
272
|
|
|
@@ -291,13 +308,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
291
308
|
from supermemory import Supermemory
|
|
292
309
|
|
|
293
310
|
client = Supermemory()
|
|
294
|
-
response = client.
|
|
295
|
-
|
|
311
|
+
response = client.memories.with_raw_response.add(
|
|
312
|
+
content="This is a detailed article about machine learning concepts...",
|
|
296
313
|
)
|
|
297
314
|
print(response.headers.get('X-My-Header'))
|
|
298
315
|
|
|
299
|
-
|
|
300
|
-
print(
|
|
316
|
+
memory = response.parse() # get the object that `memories.add()` would have returned
|
|
317
|
+
print(memory.id)
|
|
301
318
|
```
|
|
302
319
|
|
|
303
320
|
These methods return an [`APIResponse`](https://github.com/supermemoryai/python-sdk/tree/main/src/supermemory/_response.py) object.
|
|
@@ -311,8 +328,8 @@ The above interface eagerly reads the full response body when you make the reque
|
|
|
311
328
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
|
312
329
|
|
|
313
330
|
```python
|
|
314
|
-
with client.
|
|
315
|
-
|
|
331
|
+
with client.memories.with_streaming_response.add(
|
|
332
|
+
content="This is a detailed article about machine learning concepts...",
|
|
316
333
|
) as response:
|
|
317
334
|
print(response.headers.get("X-My-Header"))
|
|
318
335
|
|