supermemory 3.0.0a29__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 +12 -12
- supermemory/_client.py +17 -9
- supermemory/_compat.py +48 -48
- supermemory/_models.py +50 -44
- supermemory/_qs.py +7 -7
- supermemory/_types.py +53 -12
- supermemory/_utils/__init__.py +9 -2
- supermemory/_utils/_compat.py +45 -0
- supermemory/_utils/_datetime_parse.py +136 -0
- supermemory/_utils/_transform.py +13 -3
- supermemory/_utils/_typing.py +6 -1
- supermemory/_utils/_utils.py +4 -5
- supermemory/_version.py +1 -1
- supermemory/resources/__init__.py +14 -0
- supermemory/resources/connections.py +36 -36
- supermemory/resources/documents.py +894 -0
- supermemory/resources/memories.py +222 -134
- supermemory/resources/search.py +79 -79
- supermemory/resources/settings.py +31 -31
- supermemory/types/__init__.py +9 -0
- supermemory/types/connection_create_params.py +3 -2
- supermemory/types/connection_delete_by_provider_params.py +2 -2
- supermemory/types/connection_get_by_tags_params.py +2 -2
- supermemory/types/connection_import_params.py +2 -2
- supermemory/types/connection_list_documents_params.py +2 -2
- supermemory/types/connection_list_params.py +2 -2
- 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 +39 -23
- supermemory/types/memory_get_response.py +21 -20
- supermemory/types/memory_list_params.py +79 -8
- supermemory/types/memory_list_response.py +18 -17
- supermemory/types/memory_update_params.py +31 -15
- supermemory/types/memory_upload_file_params.py +20 -0
- supermemory/types/search_documents_params.py +71 -9
- supermemory/types/search_execute_params.py +71 -9
- supermemory/types/search_memories_params.py +77 -8
- supermemory/types/search_memories_response.py +10 -7
- {supermemory-3.0.0a29.dist-info → supermemory-3.1.0.dist-info}/METADATA +18 -8
- supermemory-3.1.0.dist-info/RECORD +80 -0
- supermemory-3.0.0a29.dist-info/RECORD +0 -68
- {supermemory-3.0.0a29.dist-info → supermemory-3.1.0.dist-info}/WHEEL +0 -0
- {supermemory-3.0.0a29.dist-info → supermemory-3.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Dict,
|
|
5
|
+
from typing import Dict, Union, Mapping, cast
|
|
6
6
|
from typing_extensions import Literal
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
10
|
from ..types import memory_add_params, memory_list_params, memory_update_params, memory_upload_file_params
|
|
11
|
-
from .._types import
|
|
11
|
+
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, SequenceNotStr, omit, not_given
|
|
12
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
|
|
@@ -52,30 +52,33 @@ class MemoriesResource(SyncAPIResource):
|
|
|
52
52
|
self,
|
|
53
53
|
id: str,
|
|
54
54
|
*,
|
|
55
|
-
container_tag: str |
|
|
56
|
-
container_tags:
|
|
57
|
-
content: str |
|
|
58
|
-
custom_id: str |
|
|
59
|
-
|
|
55
|
+
container_tag: str | Omit = omit,
|
|
56
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
57
|
+
content: str | Omit = omit,
|
|
58
|
+
custom_id: str | Omit = omit,
|
|
59
|
+
file_type: str | Omit = omit,
|
|
60
|
+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
|
|
61
|
+
mime_type: str | Omit = omit,
|
|
60
62
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
61
63
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
62
64
|
extra_headers: Headers | None = None,
|
|
63
65
|
extra_query: Query | None = None,
|
|
64
66
|
extra_body: Body | None = None,
|
|
65
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
67
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
66
68
|
) -> MemoryUpdateResponse:
|
|
67
69
|
"""
|
|
68
|
-
Update a
|
|
70
|
+
Update a document with any content type (text, url, file, etc.) and metadata
|
|
69
71
|
|
|
70
72
|
Args:
|
|
71
|
-
container_tag: Optional tag this
|
|
72
|
-
user, a project ID, or any other identifier you wish to use to group
|
|
73
|
+
container_tag: Optional tag this document should be containerized by. This can be an ID for
|
|
74
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
75
|
+
documents.
|
|
73
76
|
|
|
74
|
-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this
|
|
77
|
+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
|
|
75
78
|
containerized by. This can be an ID for your user, a project ID, or any other
|
|
76
|
-
identifier you wish to use to group
|
|
79
|
+
identifier you wish to use to group documents.
|
|
77
80
|
|
|
78
|
-
content: The content to extract and process into a
|
|
81
|
+
content: The content to extract and process into a document. This can be a URL to a
|
|
79
82
|
website, a PDF, an image, or a video.
|
|
80
83
|
|
|
81
84
|
Plaintext: Any plaintext format
|
|
@@ -84,14 +87,22 @@ class MemoriesResource(SyncAPIResource):
|
|
|
84
87
|
|
|
85
88
|
We automatically detect the content type from the url's response format.
|
|
86
89
|
|
|
87
|
-
custom_id: Optional custom ID of the
|
|
88
|
-
will uniquely identify this
|
|
90
|
+
custom_id: Optional custom ID of the document. This could be an ID from your database that
|
|
91
|
+
will uniquely identify this document.
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
file_type:
|
|
94
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
95
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
96
|
+
notion_doc, webpage, onedrive
|
|
97
|
+
|
|
98
|
+
metadata: Optional metadata for the document. This is used to store additional information
|
|
99
|
+
about the document. You can use this to store any additional information you
|
|
100
|
+
need about the document. Metadata can be filtered through. Keys must be strings
|
|
101
|
+
and are case sensitive. Values can be strings, numbers, or booleans. You cannot
|
|
102
|
+
nest objects.
|
|
103
|
+
|
|
104
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
105
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
95
106
|
|
|
96
107
|
extra_headers: Send extra headers
|
|
97
108
|
|
|
@@ -104,14 +115,16 @@ class MemoriesResource(SyncAPIResource):
|
|
|
104
115
|
if not id:
|
|
105
116
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
106
117
|
return self._patch(
|
|
107
|
-
f"/v3/
|
|
118
|
+
f"/v3/documents/{id}",
|
|
108
119
|
body=maybe_transform(
|
|
109
120
|
{
|
|
110
121
|
"container_tag": container_tag,
|
|
111
122
|
"container_tags": container_tags,
|
|
112
123
|
"content": content,
|
|
113
124
|
"custom_id": custom_id,
|
|
125
|
+
"file_type": file_type,
|
|
114
126
|
"metadata": metadata,
|
|
127
|
+
"mime_type": mime_type,
|
|
115
128
|
},
|
|
116
129
|
memory_update_params.MemoryUpdateParams,
|
|
117
130
|
),
|
|
@@ -124,28 +137,29 @@ class MemoriesResource(SyncAPIResource):
|
|
|
124
137
|
def list(
|
|
125
138
|
self,
|
|
126
139
|
*,
|
|
127
|
-
container_tags:
|
|
128
|
-
filters:
|
|
129
|
-
include_content: bool |
|
|
130
|
-
limit: Union[str, float] |
|
|
131
|
-
order: Literal["asc", "desc"] |
|
|
132
|
-
page: Union[str, float] |
|
|
133
|
-
sort: Literal["createdAt", "updatedAt"] |
|
|
140
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
141
|
+
filters: memory_list_params.Filters | Omit = omit,
|
|
142
|
+
include_content: bool | Omit = omit,
|
|
143
|
+
limit: Union[str, float] | Omit = omit,
|
|
144
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
145
|
+
page: Union[str, float] | Omit = omit,
|
|
146
|
+
sort: Literal["createdAt", "updatedAt"] | Omit = omit,
|
|
134
147
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
135
148
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
136
149
|
extra_headers: Headers | None = None,
|
|
137
150
|
extra_query: Query | None = None,
|
|
138
151
|
extra_body: Body | None = None,
|
|
139
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
152
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
140
153
|
) -> MemoryListResponse:
|
|
141
154
|
"""
|
|
142
|
-
Retrieves a paginated list of
|
|
155
|
+
Retrieves a paginated list of documents with their metadata and workflow status
|
|
143
156
|
|
|
144
157
|
Args:
|
|
145
|
-
container_tags: Optional tags this
|
|
146
|
-
user, a project ID, or any other identifier you wish to use to group
|
|
158
|
+
container_tags: Optional tags this document should be containerized by. This can be an ID for
|
|
159
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
160
|
+
documents.
|
|
147
161
|
|
|
148
|
-
filters: Optional filters to apply to the search
|
|
162
|
+
filters: Optional filters to apply to the search. Can be a JSON string or Query object.
|
|
149
163
|
|
|
150
164
|
include_content: Whether to include the content field in the response. Warning: This can make
|
|
151
165
|
responses significantly larger.
|
|
@@ -167,7 +181,7 @@ class MemoriesResource(SyncAPIResource):
|
|
|
167
181
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
168
182
|
"""
|
|
169
183
|
return self._post(
|
|
170
|
-
"/v3/
|
|
184
|
+
"/v3/documents/list",
|
|
171
185
|
body=maybe_transform(
|
|
172
186
|
{
|
|
173
187
|
"container_tags": container_tags,
|
|
@@ -195,10 +209,10 @@ class MemoriesResource(SyncAPIResource):
|
|
|
195
209
|
extra_headers: Headers | None = None,
|
|
196
210
|
extra_query: Query | None = None,
|
|
197
211
|
extra_body: Body | None = None,
|
|
198
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
212
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
199
213
|
) -> None:
|
|
200
214
|
"""
|
|
201
|
-
Delete a
|
|
215
|
+
Delete a document by ID or customId
|
|
202
216
|
|
|
203
217
|
Args:
|
|
204
218
|
extra_headers: Send extra headers
|
|
@@ -213,7 +227,7 @@ class MemoriesResource(SyncAPIResource):
|
|
|
213
227
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
214
228
|
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
215
229
|
return self._delete(
|
|
216
|
-
f"/v3/
|
|
230
|
+
f"/v3/documents/{id}",
|
|
217
231
|
options=make_request_options(
|
|
218
232
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
219
233
|
),
|
|
@@ -223,30 +237,25 @@ class MemoriesResource(SyncAPIResource):
|
|
|
223
237
|
def add(
|
|
224
238
|
self,
|
|
225
239
|
*,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
custom_id: str |
|
|
230
|
-
|
|
240
|
+
content: str,
|
|
241
|
+
container_tag: str | Omit = omit,
|
|
242
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
243
|
+
custom_id: str | Omit = omit,
|
|
244
|
+
file_type: str | Omit = omit,
|
|
245
|
+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
|
|
246
|
+
mime_type: str | Omit = omit,
|
|
231
247
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
232
248
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
233
249
|
extra_headers: Headers | None = None,
|
|
234
250
|
extra_query: Query | None = None,
|
|
235
251
|
extra_body: Body | None = None,
|
|
236
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
252
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
237
253
|
) -> MemoryAddResponse:
|
|
238
254
|
"""
|
|
239
|
-
Add a
|
|
255
|
+
Add a document with any content type (text, url, file, etc.) and metadata
|
|
240
256
|
|
|
241
257
|
Args:
|
|
242
|
-
|
|
243
|
-
user, a project ID, or any other identifier you wish to use to group memories.
|
|
244
|
-
|
|
245
|
-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
|
|
246
|
-
containerized by. This can be an ID for your user, a project ID, or any other
|
|
247
|
-
identifier you wish to use to group memories.
|
|
248
|
-
|
|
249
|
-
content: The content to extract and process into a memory. This can be a URL to a
|
|
258
|
+
content: The content to extract and process into a document. This can be a URL to a
|
|
250
259
|
website, a PDF, an image, or a video.
|
|
251
260
|
|
|
252
261
|
Plaintext: Any plaintext format
|
|
@@ -255,14 +264,30 @@ class MemoriesResource(SyncAPIResource):
|
|
|
255
264
|
|
|
256
265
|
We automatically detect the content type from the url's response format.
|
|
257
266
|
|
|
258
|
-
|
|
259
|
-
|
|
267
|
+
container_tag: Optional tag this document should be containerized by. This can be an ID for
|
|
268
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
269
|
+
documents.
|
|
270
|
+
|
|
271
|
+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
|
|
272
|
+
containerized by. This can be an ID for your user, a project ID, or any other
|
|
273
|
+
identifier you wish to use to group documents.
|
|
274
|
+
|
|
275
|
+
custom_id: Optional custom ID of the document. This could be an ID from your database that
|
|
276
|
+
will uniquely identify this document.
|
|
260
277
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
file_type:
|
|
279
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
280
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
281
|
+
notion_doc, webpage, onedrive
|
|
282
|
+
|
|
283
|
+
metadata: Optional metadata for the document. This is used to store additional information
|
|
284
|
+
about the document. You can use this to store any additional information you
|
|
285
|
+
need about the document. Metadata can be filtered through. Keys must be strings
|
|
286
|
+
and are case sensitive. Values can be strings, numbers, or booleans. You cannot
|
|
287
|
+
nest objects.
|
|
288
|
+
|
|
289
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
290
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
266
291
|
|
|
267
292
|
extra_headers: Send extra headers
|
|
268
293
|
|
|
@@ -273,14 +298,16 @@ class MemoriesResource(SyncAPIResource):
|
|
|
273
298
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
274
299
|
"""
|
|
275
300
|
return self._post(
|
|
276
|
-
"/v3/
|
|
301
|
+
"/v3/documents",
|
|
277
302
|
body=maybe_transform(
|
|
278
303
|
{
|
|
304
|
+
"content": content,
|
|
279
305
|
"container_tag": container_tag,
|
|
280
306
|
"container_tags": container_tags,
|
|
281
|
-
"content": content,
|
|
282
307
|
"custom_id": custom_id,
|
|
308
|
+
"file_type": file_type,
|
|
283
309
|
"metadata": metadata,
|
|
310
|
+
"mime_type": mime_type,
|
|
284
311
|
},
|
|
285
312
|
memory_add_params.MemoryAddParams,
|
|
286
313
|
),
|
|
@@ -299,10 +326,10 @@ class MemoriesResource(SyncAPIResource):
|
|
|
299
326
|
extra_headers: Headers | None = None,
|
|
300
327
|
extra_query: Query | None = None,
|
|
301
328
|
extra_body: Body | None = None,
|
|
302
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
329
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
303
330
|
) -> MemoryGetResponse:
|
|
304
331
|
"""
|
|
305
|
-
Get a
|
|
332
|
+
Get a document by ID
|
|
306
333
|
|
|
307
334
|
Args:
|
|
308
335
|
extra_headers: Send extra headers
|
|
@@ -316,7 +343,7 @@ class MemoriesResource(SyncAPIResource):
|
|
|
316
343
|
if not id:
|
|
317
344
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
318
345
|
return self._get(
|
|
319
|
-
f"/v3/
|
|
346
|
+
f"/v3/documents/{id}",
|
|
320
347
|
options=make_request_options(
|
|
321
348
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
322
349
|
),
|
|
@@ -327,18 +354,33 @@ class MemoriesResource(SyncAPIResource):
|
|
|
327
354
|
self,
|
|
328
355
|
*,
|
|
329
356
|
file: FileTypes,
|
|
330
|
-
container_tags: str |
|
|
357
|
+
container_tags: str | Omit = omit,
|
|
358
|
+
file_type: str | Omit = omit,
|
|
359
|
+
mime_type: str | Omit = omit,
|
|
331
360
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
332
361
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
333
362
|
extra_headers: Headers | None = None,
|
|
334
363
|
extra_query: Query | None = None,
|
|
335
364
|
extra_body: Body | None = None,
|
|
336
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
365
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
337
366
|
) -> MemoryUploadFileResponse:
|
|
338
367
|
"""
|
|
339
368
|
Upload a file to be processed
|
|
340
369
|
|
|
341
370
|
Args:
|
|
371
|
+
file: File to upload and process
|
|
372
|
+
|
|
373
|
+
container_tags: Optional JSON string of container tags array. This can be an ID for your user, a
|
|
374
|
+
project ID, or any other identifier you wish to use to group documents.
|
|
375
|
+
|
|
376
|
+
file_type:
|
|
377
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
378
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
379
|
+
notion_doc, webpage, onedrive
|
|
380
|
+
|
|
381
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
382
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
383
|
+
|
|
342
384
|
extra_headers: Send extra headers
|
|
343
385
|
|
|
344
386
|
extra_query: Add additional query parameters to the request
|
|
@@ -351,6 +393,8 @@ class MemoriesResource(SyncAPIResource):
|
|
|
351
393
|
{
|
|
352
394
|
"file": file,
|
|
353
395
|
"container_tags": container_tags,
|
|
396
|
+
"file_type": file_type,
|
|
397
|
+
"mime_type": mime_type,
|
|
354
398
|
}
|
|
355
399
|
)
|
|
356
400
|
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
@@ -359,7 +403,7 @@ class MemoriesResource(SyncAPIResource):
|
|
|
359
403
|
# multipart/form-data; boundary=---abc--
|
|
360
404
|
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
361
405
|
return self._post(
|
|
362
|
-
"/v3/
|
|
406
|
+
"/v3/documents/file",
|
|
363
407
|
body=maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
|
364
408
|
files=files,
|
|
365
409
|
options=make_request_options(
|
|
@@ -393,30 +437,33 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
393
437
|
self,
|
|
394
438
|
id: str,
|
|
395
439
|
*,
|
|
396
|
-
container_tag: str |
|
|
397
|
-
container_tags:
|
|
398
|
-
content: str |
|
|
399
|
-
custom_id: str |
|
|
400
|
-
|
|
440
|
+
container_tag: str | Omit = omit,
|
|
441
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
442
|
+
content: str | Omit = omit,
|
|
443
|
+
custom_id: str | Omit = omit,
|
|
444
|
+
file_type: str | Omit = omit,
|
|
445
|
+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
|
|
446
|
+
mime_type: str | Omit = omit,
|
|
401
447
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
402
448
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
403
449
|
extra_headers: Headers | None = None,
|
|
404
450
|
extra_query: Query | None = None,
|
|
405
451
|
extra_body: Body | None = None,
|
|
406
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
452
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
407
453
|
) -> MemoryUpdateResponse:
|
|
408
454
|
"""
|
|
409
|
-
Update a
|
|
455
|
+
Update a document with any content type (text, url, file, etc.) and metadata
|
|
410
456
|
|
|
411
457
|
Args:
|
|
412
|
-
container_tag: Optional tag this
|
|
413
|
-
user, a project ID, or any other identifier you wish to use to group
|
|
458
|
+
container_tag: Optional tag this document should be containerized by. This can be an ID for
|
|
459
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
460
|
+
documents.
|
|
414
461
|
|
|
415
|
-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this
|
|
462
|
+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
|
|
416
463
|
containerized by. This can be an ID for your user, a project ID, or any other
|
|
417
|
-
identifier you wish to use to group
|
|
464
|
+
identifier you wish to use to group documents.
|
|
418
465
|
|
|
419
|
-
content: The content to extract and process into a
|
|
466
|
+
content: The content to extract and process into a document. This can be a URL to a
|
|
420
467
|
website, a PDF, an image, or a video.
|
|
421
468
|
|
|
422
469
|
Plaintext: Any plaintext format
|
|
@@ -425,14 +472,22 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
425
472
|
|
|
426
473
|
We automatically detect the content type from the url's response format.
|
|
427
474
|
|
|
428
|
-
custom_id: Optional custom ID of the
|
|
429
|
-
will uniquely identify this
|
|
475
|
+
custom_id: Optional custom ID of the document. This could be an ID from your database that
|
|
476
|
+
will uniquely identify this document.
|
|
430
477
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
478
|
+
file_type:
|
|
479
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
480
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
481
|
+
notion_doc, webpage, onedrive
|
|
482
|
+
|
|
483
|
+
metadata: Optional metadata for the document. This is used to store additional information
|
|
484
|
+
about the document. You can use this to store any additional information you
|
|
485
|
+
need about the document. Metadata can be filtered through. Keys must be strings
|
|
486
|
+
and are case sensitive. Values can be strings, numbers, or booleans. You cannot
|
|
487
|
+
nest objects.
|
|
488
|
+
|
|
489
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
490
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
436
491
|
|
|
437
492
|
extra_headers: Send extra headers
|
|
438
493
|
|
|
@@ -445,14 +500,16 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
445
500
|
if not id:
|
|
446
501
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
447
502
|
return await self._patch(
|
|
448
|
-
f"/v3/
|
|
503
|
+
f"/v3/documents/{id}",
|
|
449
504
|
body=await async_maybe_transform(
|
|
450
505
|
{
|
|
451
506
|
"container_tag": container_tag,
|
|
452
507
|
"container_tags": container_tags,
|
|
453
508
|
"content": content,
|
|
454
509
|
"custom_id": custom_id,
|
|
510
|
+
"file_type": file_type,
|
|
455
511
|
"metadata": metadata,
|
|
512
|
+
"mime_type": mime_type,
|
|
456
513
|
},
|
|
457
514
|
memory_update_params.MemoryUpdateParams,
|
|
458
515
|
),
|
|
@@ -465,28 +522,29 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
465
522
|
async def list(
|
|
466
523
|
self,
|
|
467
524
|
*,
|
|
468
|
-
container_tags:
|
|
469
|
-
filters:
|
|
470
|
-
include_content: bool |
|
|
471
|
-
limit: Union[str, float] |
|
|
472
|
-
order: Literal["asc", "desc"] |
|
|
473
|
-
page: Union[str, float] |
|
|
474
|
-
sort: Literal["createdAt", "updatedAt"] |
|
|
525
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
526
|
+
filters: memory_list_params.Filters | Omit = omit,
|
|
527
|
+
include_content: bool | Omit = omit,
|
|
528
|
+
limit: Union[str, float] | Omit = omit,
|
|
529
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
530
|
+
page: Union[str, float] | Omit = omit,
|
|
531
|
+
sort: Literal["createdAt", "updatedAt"] | Omit = omit,
|
|
475
532
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
476
533
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
477
534
|
extra_headers: Headers | None = None,
|
|
478
535
|
extra_query: Query | None = None,
|
|
479
536
|
extra_body: Body | None = None,
|
|
480
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
537
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
481
538
|
) -> MemoryListResponse:
|
|
482
539
|
"""
|
|
483
|
-
Retrieves a paginated list of
|
|
540
|
+
Retrieves a paginated list of documents with their metadata and workflow status
|
|
484
541
|
|
|
485
542
|
Args:
|
|
486
|
-
container_tags: Optional tags this
|
|
487
|
-
user, a project ID, or any other identifier you wish to use to group
|
|
543
|
+
container_tags: Optional tags this document should be containerized by. This can be an ID for
|
|
544
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
545
|
+
documents.
|
|
488
546
|
|
|
489
|
-
filters: Optional filters to apply to the search
|
|
547
|
+
filters: Optional filters to apply to the search. Can be a JSON string or Query object.
|
|
490
548
|
|
|
491
549
|
include_content: Whether to include the content field in the response. Warning: This can make
|
|
492
550
|
responses significantly larger.
|
|
@@ -508,7 +566,7 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
508
566
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
509
567
|
"""
|
|
510
568
|
return await self._post(
|
|
511
|
-
"/v3/
|
|
569
|
+
"/v3/documents/list",
|
|
512
570
|
body=await async_maybe_transform(
|
|
513
571
|
{
|
|
514
572
|
"container_tags": container_tags,
|
|
@@ -536,10 +594,10 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
536
594
|
extra_headers: Headers | None = None,
|
|
537
595
|
extra_query: Query | None = None,
|
|
538
596
|
extra_body: Body | None = None,
|
|
539
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
597
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
540
598
|
) -> None:
|
|
541
599
|
"""
|
|
542
|
-
Delete a
|
|
600
|
+
Delete a document by ID or customId
|
|
543
601
|
|
|
544
602
|
Args:
|
|
545
603
|
extra_headers: Send extra headers
|
|
@@ -554,7 +612,7 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
554
612
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
555
613
|
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
556
614
|
return await self._delete(
|
|
557
|
-
f"/v3/
|
|
615
|
+
f"/v3/documents/{id}",
|
|
558
616
|
options=make_request_options(
|
|
559
617
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
560
618
|
),
|
|
@@ -564,30 +622,25 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
564
622
|
async def add(
|
|
565
623
|
self,
|
|
566
624
|
*,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
custom_id: str |
|
|
571
|
-
|
|
625
|
+
content: str,
|
|
626
|
+
container_tag: str | Omit = omit,
|
|
627
|
+
container_tags: SequenceNotStr[str] | Omit = omit,
|
|
628
|
+
custom_id: str | Omit = omit,
|
|
629
|
+
file_type: str | Omit = omit,
|
|
630
|
+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
|
|
631
|
+
mime_type: str | Omit = omit,
|
|
572
632
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
573
633
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
574
634
|
extra_headers: Headers | None = None,
|
|
575
635
|
extra_query: Query | None = None,
|
|
576
636
|
extra_body: Body | None = None,
|
|
577
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
637
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
578
638
|
) -> MemoryAddResponse:
|
|
579
639
|
"""
|
|
580
|
-
Add a
|
|
640
|
+
Add a document with any content type (text, url, file, etc.) and metadata
|
|
581
641
|
|
|
582
642
|
Args:
|
|
583
|
-
|
|
584
|
-
user, a project ID, or any other identifier you wish to use to group memories.
|
|
585
|
-
|
|
586
|
-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
|
|
587
|
-
containerized by. This can be an ID for your user, a project ID, or any other
|
|
588
|
-
identifier you wish to use to group memories.
|
|
589
|
-
|
|
590
|
-
content: The content to extract and process into a memory. This can be a URL to a
|
|
643
|
+
content: The content to extract and process into a document. This can be a URL to a
|
|
591
644
|
website, a PDF, an image, or a video.
|
|
592
645
|
|
|
593
646
|
Plaintext: Any plaintext format
|
|
@@ -596,14 +649,30 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
596
649
|
|
|
597
650
|
We automatically detect the content type from the url's response format.
|
|
598
651
|
|
|
599
|
-
|
|
600
|
-
|
|
652
|
+
container_tag: Optional tag this document should be containerized by. This can be an ID for
|
|
653
|
+
your user, a project ID, or any other identifier you wish to use to group
|
|
654
|
+
documents.
|
|
655
|
+
|
|
656
|
+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
|
|
657
|
+
containerized by. This can be an ID for your user, a project ID, or any other
|
|
658
|
+
identifier you wish to use to group documents.
|
|
659
|
+
|
|
660
|
+
custom_id: Optional custom ID of the document. This could be an ID from your database that
|
|
661
|
+
will uniquely identify this document.
|
|
601
662
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
663
|
+
file_type:
|
|
664
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
665
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
666
|
+
notion_doc, webpage, onedrive
|
|
667
|
+
|
|
668
|
+
metadata: Optional metadata for the document. This is used to store additional information
|
|
669
|
+
about the document. You can use this to store any additional information you
|
|
670
|
+
need about the document. Metadata can be filtered through. Keys must be strings
|
|
671
|
+
and are case sensitive. Values can be strings, numbers, or booleans. You cannot
|
|
672
|
+
nest objects.
|
|
673
|
+
|
|
674
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
675
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
607
676
|
|
|
608
677
|
extra_headers: Send extra headers
|
|
609
678
|
|
|
@@ -614,14 +683,16 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
614
683
|
timeout: Override the client-level default timeout for this request, in seconds
|
|
615
684
|
"""
|
|
616
685
|
return await self._post(
|
|
617
|
-
"/v3/
|
|
686
|
+
"/v3/documents",
|
|
618
687
|
body=await async_maybe_transform(
|
|
619
688
|
{
|
|
689
|
+
"content": content,
|
|
620
690
|
"container_tag": container_tag,
|
|
621
691
|
"container_tags": container_tags,
|
|
622
|
-
"content": content,
|
|
623
692
|
"custom_id": custom_id,
|
|
693
|
+
"file_type": file_type,
|
|
624
694
|
"metadata": metadata,
|
|
695
|
+
"mime_type": mime_type,
|
|
625
696
|
},
|
|
626
697
|
memory_add_params.MemoryAddParams,
|
|
627
698
|
),
|
|
@@ -640,10 +711,10 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
640
711
|
extra_headers: Headers | None = None,
|
|
641
712
|
extra_query: Query | None = None,
|
|
642
713
|
extra_body: Body | None = None,
|
|
643
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
714
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
644
715
|
) -> MemoryGetResponse:
|
|
645
716
|
"""
|
|
646
|
-
Get a
|
|
717
|
+
Get a document by ID
|
|
647
718
|
|
|
648
719
|
Args:
|
|
649
720
|
extra_headers: Send extra headers
|
|
@@ -657,7 +728,7 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
657
728
|
if not id:
|
|
658
729
|
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
659
730
|
return await self._get(
|
|
660
|
-
f"/v3/
|
|
731
|
+
f"/v3/documents/{id}",
|
|
661
732
|
options=make_request_options(
|
|
662
733
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
663
734
|
),
|
|
@@ -668,18 +739,33 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
668
739
|
self,
|
|
669
740
|
*,
|
|
670
741
|
file: FileTypes,
|
|
671
|
-
container_tags: str |
|
|
742
|
+
container_tags: str | Omit = omit,
|
|
743
|
+
file_type: str | Omit = omit,
|
|
744
|
+
mime_type: str | Omit = omit,
|
|
672
745
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
673
746
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
674
747
|
extra_headers: Headers | None = None,
|
|
675
748
|
extra_query: Query | None = None,
|
|
676
749
|
extra_body: Body | None = None,
|
|
677
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
750
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
678
751
|
) -> MemoryUploadFileResponse:
|
|
679
752
|
"""
|
|
680
753
|
Upload a file to be processed
|
|
681
754
|
|
|
682
755
|
Args:
|
|
756
|
+
file: File to upload and process
|
|
757
|
+
|
|
758
|
+
container_tags: Optional JSON string of container tags array. This can be an ID for your user, a
|
|
759
|
+
project ID, or any other identifier you wish to use to group documents.
|
|
760
|
+
|
|
761
|
+
file_type:
|
|
762
|
+
Optional file type override to force specific processing behavior. Valid values:
|
|
763
|
+
text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
|
|
764
|
+
notion_doc, webpage, onedrive
|
|
765
|
+
|
|
766
|
+
mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
|
|
767
|
+
use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
|
|
768
|
+
|
|
683
769
|
extra_headers: Send extra headers
|
|
684
770
|
|
|
685
771
|
extra_query: Add additional query parameters to the request
|
|
@@ -692,6 +778,8 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
692
778
|
{
|
|
693
779
|
"file": file,
|
|
694
780
|
"container_tags": container_tags,
|
|
781
|
+
"file_type": file_type,
|
|
782
|
+
"mime_type": mime_type,
|
|
695
783
|
}
|
|
696
784
|
)
|
|
697
785
|
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
|
|
@@ -700,7 +788,7 @@ class AsyncMemoriesResource(AsyncAPIResource):
|
|
|
700
788
|
# multipart/form-data; boundary=---abc--
|
|
701
789
|
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
|
|
702
790
|
return await self._post(
|
|
703
|
-
"/v3/
|
|
791
|
+
"/v3/documents/file",
|
|
704
792
|
body=await async_maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
|
|
705
793
|
files=files,
|
|
706
794
|
options=make_request_options(
|