supermemory 3.7.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.
Files changed (84) hide show
  1. supermemory/__init__.py +102 -0
  2. supermemory/_base_client.py +1995 -0
  3. supermemory/_client.py +683 -0
  4. supermemory/_compat.py +219 -0
  5. supermemory/_constants.py +14 -0
  6. supermemory/_exceptions.py +108 -0
  7. supermemory/_files.py +123 -0
  8. supermemory/_models.py +857 -0
  9. supermemory/_qs.py +150 -0
  10. supermemory/_resource.py +43 -0
  11. supermemory/_response.py +832 -0
  12. supermemory/_streaming.py +331 -0
  13. supermemory/_types.py +260 -0
  14. supermemory/_utils/__init__.py +64 -0
  15. supermemory/_utils/_compat.py +45 -0
  16. supermemory/_utils/_datetime_parse.py +136 -0
  17. supermemory/_utils/_logs.py +25 -0
  18. supermemory/_utils/_proxy.py +65 -0
  19. supermemory/_utils/_reflection.py +42 -0
  20. supermemory/_utils/_resources_proxy.py +24 -0
  21. supermemory/_utils/_streams.py +12 -0
  22. supermemory/_utils/_sync.py +58 -0
  23. supermemory/_utils/_transform.py +457 -0
  24. supermemory/_utils/_typing.py +156 -0
  25. supermemory/_utils/_utils.py +421 -0
  26. supermemory/_version.py +4 -0
  27. supermemory/lib/.keep +4 -0
  28. supermemory/py.typed +0 -0
  29. supermemory/resources/__init__.py +75 -0
  30. supermemory/resources/connections.py +807 -0
  31. supermemory/resources/documents.py +830 -0
  32. supermemory/resources/memories.py +830 -0
  33. supermemory/resources/search.py +657 -0
  34. supermemory/resources/settings.py +278 -0
  35. supermemory/types/__init__.py +51 -0
  36. supermemory/types/add_response.py +13 -0
  37. supermemory/types/client_add_params.py +36 -0
  38. supermemory/types/client_profile_params.py +21 -0
  39. supermemory/types/connection_create_params.py +21 -0
  40. supermemory/types/connection_create_response.py +19 -0
  41. supermemory/types/connection_delete_by_id_response.py +11 -0
  42. supermemory/types/connection_delete_by_provider_params.py +15 -0
  43. supermemory/types/connection_delete_by_provider_response.py +11 -0
  44. supermemory/types/connection_get_by_id_response.py +25 -0
  45. supermemory/types/connection_get_by_tags_params.py +15 -0
  46. supermemory/types/connection_get_by_tags_response.py +25 -0
  47. supermemory/types/connection_import_params.py +15 -0
  48. supermemory/types/connection_import_response.py +7 -0
  49. supermemory/types/connection_list_documents_params.py +15 -0
  50. supermemory/types/connection_list_documents_response.py +29 -0
  51. supermemory/types/connection_list_params.py +15 -0
  52. supermemory/types/connection_list_response.py +29 -0
  53. supermemory/types/document_add_params.py +36 -0
  54. supermemory/types/document_add_response.py +13 -0
  55. supermemory/types/document_get_response.py +103 -0
  56. supermemory/types/document_list_params.py +52 -0
  57. supermemory/types/document_list_response.py +94 -0
  58. supermemory/types/document_update_params.py +55 -0
  59. supermemory/types/document_update_response.py +13 -0
  60. supermemory/types/document_upload_file_params.py +44 -0
  61. supermemory/types/document_upload_file_response.py +13 -0
  62. supermemory/types/memory_add_params.py +36 -0
  63. supermemory/types/memory_add_response.py +13 -0
  64. supermemory/types/memory_get_response.py +103 -0
  65. supermemory/types/memory_list_params.py +52 -0
  66. supermemory/types/memory_list_response.py +94 -0
  67. supermemory/types/memory_update_params.py +55 -0
  68. supermemory/types/memory_update_response.py +13 -0
  69. supermemory/types/memory_upload_file_params.py +44 -0
  70. supermemory/types/memory_upload_file_response.py +13 -0
  71. supermemory/types/profile_response.py +35 -0
  72. supermemory/types/search_documents_params.py +93 -0
  73. supermemory/types/search_documents_response.py +60 -0
  74. supermemory/types/search_execute_params.py +93 -0
  75. supermemory/types/search_execute_response.py +60 -0
  76. supermemory/types/search_memories_params.py +75 -0
  77. supermemory/types/search_memories_response.py +123 -0
  78. supermemory/types/setting_get_response.py +43 -0
  79. supermemory/types/setting_update_params.py +44 -0
  80. supermemory/types/setting_update_response.py +51 -0
  81. supermemory-3.7.0.dist-info/METADATA +447 -0
  82. supermemory-3.7.0.dist-info/RECORD +84 -0
  83. supermemory-3.7.0.dist-info/WHEEL +4 -0
  84. supermemory-3.7.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,830 @@
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, Mapping, cast
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import memory_add_params, memory_list_params, memory_update_params, memory_upload_file_params
11
+ from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, FileTypes, SequenceNotStr, omit, not_given
12
+ from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+ from ..types.memory_add_response import MemoryAddResponse
23
+ from ..types.memory_get_response import MemoryGetResponse
24
+ from ..types.memory_list_response import MemoryListResponse
25
+ from ..types.memory_update_response import MemoryUpdateResponse
26
+ from ..types.memory_upload_file_response import MemoryUploadFileResponse
27
+
28
+ __all__ = ["MemoriesResource", "AsyncMemoriesResource"]
29
+
30
+
31
+ class MemoriesResource(SyncAPIResource):
32
+ @cached_property
33
+ def with_raw_response(self) -> MemoriesResourceWithRawResponse:
34
+ """
35
+ This property can be used as a prefix for any HTTP method call to return
36
+ the raw response object instead of the parsed content.
37
+
38
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
39
+ """
40
+ return MemoriesResourceWithRawResponse(self)
41
+
42
+ @cached_property
43
+ def with_streaming_response(self) -> MemoriesResourceWithStreamingResponse:
44
+ """
45
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
46
+
47
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
48
+ """
49
+ return MemoriesResourceWithStreamingResponse(self)
50
+
51
+ def update(
52
+ self,
53
+ id: str,
54
+ *,
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
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
60
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
61
+ # The extra values given here take precedence over values defined on the client or passed to this method.
62
+ extra_headers: Headers | None = None,
63
+ extra_query: Query | None = None,
64
+ extra_body: Body | None = None,
65
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
66
+ ) -> MemoryUpdateResponse:
67
+ """
68
+ Update a document with any content type (text, url, file, etc.) and metadata
69
+
70
+ Args:
71
+ container_tag: Optional tag this document should be containerized by. This can be an ID for
72
+ your user, a project ID, or any other identifier you wish to use to group
73
+ documents.
74
+
75
+ container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
76
+ containerized by. This can be an ID for your user, a project ID, or any other
77
+ identifier you wish to use to group documents.
78
+
79
+ content: The content to extract and process into a document. This can be a URL to a
80
+ website, a PDF, an image, or a video.
81
+
82
+ Plaintext: Any plaintext format
83
+
84
+ URL: A URL to a website, PDF, image, or video
85
+
86
+ We automatically detect the content type from the url's response format.
87
+
88
+ custom_id: Optional custom ID of the document. This could be an ID from your database that
89
+ will uniquely identify this document.
90
+
91
+ metadata: Optional metadata for the document. This is used to store additional information
92
+ about the document. You can use this to store any additional information you
93
+ need about the document. Metadata can be filtered through. Keys must be strings
94
+ and are case sensitive. Values can be strings, numbers, or booleans. You cannot
95
+ nest objects.
96
+
97
+ extra_headers: Send extra headers
98
+
99
+ extra_query: Add additional query parameters to the request
100
+
101
+ extra_body: Add additional JSON properties to the request
102
+
103
+ timeout: Override the client-level default timeout for this request, in seconds
104
+ """
105
+ if not id:
106
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
107
+ return self._patch(
108
+ f"/v3/documents/{id}",
109
+ body=maybe_transform(
110
+ {
111
+ "container_tag": container_tag,
112
+ "container_tags": container_tags,
113
+ "content": content,
114
+ "custom_id": custom_id,
115
+ "metadata": metadata,
116
+ },
117
+ memory_update_params.MemoryUpdateParams,
118
+ ),
119
+ options=make_request_options(
120
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
121
+ ),
122
+ cast_to=MemoryUpdateResponse,
123
+ )
124
+
125
+ def list(
126
+ self,
127
+ *,
128
+ container_tags: SequenceNotStr[str] | Omit = omit,
129
+ filters: memory_list_params.Filters | Omit = omit,
130
+ include_content: bool | Omit = omit,
131
+ limit: Union[str, float] | Omit = omit,
132
+ order: Literal["asc", "desc"] | Omit = omit,
133
+ page: Union[str, float] | Omit = omit,
134
+ sort: Literal["createdAt", "updatedAt"] | Omit = omit,
135
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
136
+ # The extra values given here take precedence over values defined on the client or passed to this method.
137
+ extra_headers: Headers | None = None,
138
+ extra_query: Query | None = None,
139
+ extra_body: Body | None = None,
140
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
141
+ ) -> MemoryListResponse:
142
+ """
143
+ Retrieves a paginated list of documents with their metadata and workflow status
144
+
145
+ Args:
146
+ container_tags: Optional tags this document should be containerized by. This can be an ID for
147
+ your user, a project ID, or any other identifier you wish to use to group
148
+ documents.
149
+
150
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
151
+
152
+ include_content: Whether to include the content field in the response. Warning: This can make
153
+ responses significantly larger.
154
+
155
+ limit: Number of items per page
156
+
157
+ order: Sort order
158
+
159
+ page: Page number to fetch
160
+
161
+ sort: Field to sort by
162
+
163
+ extra_headers: Send extra headers
164
+
165
+ extra_query: Add additional query parameters to the request
166
+
167
+ extra_body: Add additional JSON properties to the request
168
+
169
+ timeout: Override the client-level default timeout for this request, in seconds
170
+ """
171
+ return self._post(
172
+ "/v3/documents/list",
173
+ body=maybe_transform(
174
+ {
175
+ "container_tags": container_tags,
176
+ "filters": filters,
177
+ "include_content": include_content,
178
+ "limit": limit,
179
+ "order": order,
180
+ "page": page,
181
+ "sort": sort,
182
+ },
183
+ memory_list_params.MemoryListParams,
184
+ ),
185
+ options=make_request_options(
186
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
187
+ ),
188
+ cast_to=MemoryListResponse,
189
+ )
190
+
191
+ def delete(
192
+ self,
193
+ id: str,
194
+ *,
195
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
196
+ # The extra values given here take precedence over values defined on the client or passed to this method.
197
+ extra_headers: Headers | None = None,
198
+ extra_query: Query | None = None,
199
+ extra_body: Body | None = None,
200
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
201
+ ) -> None:
202
+ """
203
+ Delete a document by ID or customId
204
+
205
+ Args:
206
+ extra_headers: Send extra headers
207
+
208
+ extra_query: Add additional query parameters to the request
209
+
210
+ extra_body: Add additional JSON properties to the request
211
+
212
+ timeout: Override the client-level default timeout for this request, in seconds
213
+ """
214
+ if not id:
215
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
216
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
217
+ return self._delete(
218
+ f"/v3/documents/{id}",
219
+ options=make_request_options(
220
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
221
+ ),
222
+ cast_to=NoneType,
223
+ )
224
+
225
+ def add(
226
+ self,
227
+ *,
228
+ content: str,
229
+ container_tag: str | Omit = omit,
230
+ container_tags: SequenceNotStr[str] | Omit = omit,
231
+ custom_id: str | Omit = omit,
232
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
233
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
234
+ # The extra values given here take precedence over values defined on the client or passed to this method.
235
+ extra_headers: Headers | None = None,
236
+ extra_query: Query | None = None,
237
+ extra_body: Body | None = None,
238
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
239
+ ) -> MemoryAddResponse:
240
+ """
241
+ Add a document with any content type (text, url, file, etc.) and metadata
242
+
243
+ Args:
244
+ content: The content to extract and process into a document. This can be a URL to a
245
+ website, a PDF, an image, or a video.
246
+
247
+ container_tag: Optional tag this document should be containerized by. Max 100 characters,
248
+ alphanumeric with hyphens and underscores only.
249
+
250
+ custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
251
+ hyphens and underscores only.
252
+
253
+ metadata: Optional metadata for the document.
254
+
255
+ extra_headers: Send extra headers
256
+
257
+ extra_query: Add additional query parameters to the request
258
+
259
+ extra_body: Add additional JSON properties to the request
260
+
261
+ timeout: Override the client-level default timeout for this request, in seconds
262
+ """
263
+ return self._post(
264
+ "/v3/documents",
265
+ body=maybe_transform(
266
+ {
267
+ "content": content,
268
+ "container_tag": container_tag,
269
+ "container_tags": container_tags,
270
+ "custom_id": custom_id,
271
+ "metadata": metadata,
272
+ },
273
+ memory_add_params.MemoryAddParams,
274
+ ),
275
+ options=make_request_options(
276
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
277
+ ),
278
+ cast_to=MemoryAddResponse,
279
+ )
280
+
281
+ def get(
282
+ self,
283
+ id: str,
284
+ *,
285
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
286
+ # The extra values given here take precedence over values defined on the client or passed to this method.
287
+ extra_headers: Headers | None = None,
288
+ extra_query: Query | None = None,
289
+ extra_body: Body | None = None,
290
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
291
+ ) -> MemoryGetResponse:
292
+ """
293
+ Get a document by ID
294
+
295
+ Args:
296
+ extra_headers: Send extra headers
297
+
298
+ extra_query: Add additional query parameters to the request
299
+
300
+ extra_body: Add additional JSON properties to the request
301
+
302
+ timeout: Override the client-level default timeout for this request, in seconds
303
+ """
304
+ if not id:
305
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
306
+ return self._get(
307
+ f"/v3/documents/{id}",
308
+ options=make_request_options(
309
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
310
+ ),
311
+ cast_to=MemoryGetResponse,
312
+ )
313
+
314
+ def upload_file(
315
+ self,
316
+ *,
317
+ file: FileTypes,
318
+ container_tags: str | Omit = omit,
319
+ file_type: str | Omit = omit,
320
+ metadata: str | Omit = omit,
321
+ mime_type: str | Omit = omit,
322
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
323
+ # The extra values given here take precedence over values defined on the client or passed to this method.
324
+ extra_headers: Headers | None = None,
325
+ extra_query: Query | None = None,
326
+ extra_body: Body | None = None,
327
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
328
+ ) -> MemoryUploadFileResponse:
329
+ """
330
+ Upload a file to be processed
331
+
332
+ Args:
333
+ file: File to upload and process
334
+
335
+ container_tags: Optional container tags. Can be either a JSON string of an array (e.g.,
336
+ '["user_123", "project_123"]') or a single string (e.g., 'user_123'). Single
337
+ strings will be automatically converted to an array.
338
+
339
+ file_type:
340
+ Optional file type override to force specific processing behavior. Valid values:
341
+ text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
342
+ notion_doc, webpage, onedrive
343
+
344
+ metadata: Optional metadata for the document as a JSON string. This is used to store
345
+ additional information about the document. Keys must be strings and values can
346
+ be strings, numbers, or booleans.
347
+
348
+ mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
349
+ use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
350
+
351
+ extra_headers: Send extra headers
352
+
353
+ extra_query: Add additional query parameters to the request
354
+
355
+ extra_body: Add additional JSON properties to the request
356
+
357
+ timeout: Override the client-level default timeout for this request, in seconds
358
+ """
359
+ body = deepcopy_minimal(
360
+ {
361
+ "file": file,
362
+ "container_tags": container_tags,
363
+ "file_type": file_type,
364
+ "metadata": metadata,
365
+ "mime_type": mime_type,
366
+ }
367
+ )
368
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
369
+ # It should be noted that the actual Content-Type header that will be
370
+ # sent to the server will contain a `boundary` parameter, e.g.
371
+ # multipart/form-data; boundary=---abc--
372
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
373
+ return self._post(
374
+ "/v3/documents/file",
375
+ body=maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
376
+ files=files,
377
+ options=make_request_options(
378
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
379
+ ),
380
+ cast_to=MemoryUploadFileResponse,
381
+ )
382
+
383
+
384
+ class AsyncMemoriesResource(AsyncAPIResource):
385
+ @cached_property
386
+ def with_raw_response(self) -> AsyncMemoriesResourceWithRawResponse:
387
+ """
388
+ This property can be used as a prefix for any HTTP method call to return
389
+ the raw response object instead of the parsed content.
390
+
391
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
392
+ """
393
+ return AsyncMemoriesResourceWithRawResponse(self)
394
+
395
+ @cached_property
396
+ def with_streaming_response(self) -> AsyncMemoriesResourceWithStreamingResponse:
397
+ """
398
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
399
+
400
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
401
+ """
402
+ return AsyncMemoriesResourceWithStreamingResponse(self)
403
+
404
+ async def update(
405
+ self,
406
+ id: str,
407
+ *,
408
+ container_tag: str | Omit = omit,
409
+ container_tags: SequenceNotStr[str] | Omit = omit,
410
+ content: str | Omit = omit,
411
+ custom_id: str | Omit = omit,
412
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
413
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
414
+ # The extra values given here take precedence over values defined on the client or passed to this method.
415
+ extra_headers: Headers | None = None,
416
+ extra_query: Query | None = None,
417
+ extra_body: Body | None = None,
418
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
419
+ ) -> MemoryUpdateResponse:
420
+ """
421
+ Update a document with any content type (text, url, file, etc.) and metadata
422
+
423
+ Args:
424
+ container_tag: Optional tag this document should be containerized by. This can be an ID for
425
+ your user, a project ID, or any other identifier you wish to use to group
426
+ documents.
427
+
428
+ container_tags: (DEPRECATED: Use containerTag instead) Optional tags this document should be
429
+ containerized by. This can be an ID for your user, a project ID, or any other
430
+ identifier you wish to use to group documents.
431
+
432
+ content: The content to extract and process into a document. This can be a URL to a
433
+ website, a PDF, an image, or a video.
434
+
435
+ Plaintext: Any plaintext format
436
+
437
+ URL: A URL to a website, PDF, image, or video
438
+
439
+ We automatically detect the content type from the url's response format.
440
+
441
+ custom_id: Optional custom ID of the document. This could be an ID from your database that
442
+ will uniquely identify this document.
443
+
444
+ metadata: Optional metadata for the document. This is used to store additional information
445
+ about the document. You can use this to store any additional information you
446
+ need about the document. Metadata can be filtered through. Keys must be strings
447
+ and are case sensitive. Values can be strings, numbers, or booleans. You cannot
448
+ nest objects.
449
+
450
+ extra_headers: Send extra headers
451
+
452
+ extra_query: Add additional query parameters to the request
453
+
454
+ extra_body: Add additional JSON properties to the request
455
+
456
+ timeout: Override the client-level default timeout for this request, in seconds
457
+ """
458
+ if not id:
459
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
460
+ return await self._patch(
461
+ f"/v3/documents/{id}",
462
+ body=await async_maybe_transform(
463
+ {
464
+ "container_tag": container_tag,
465
+ "container_tags": container_tags,
466
+ "content": content,
467
+ "custom_id": custom_id,
468
+ "metadata": metadata,
469
+ },
470
+ memory_update_params.MemoryUpdateParams,
471
+ ),
472
+ options=make_request_options(
473
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
474
+ ),
475
+ cast_to=MemoryUpdateResponse,
476
+ )
477
+
478
+ async def list(
479
+ self,
480
+ *,
481
+ container_tags: SequenceNotStr[str] | Omit = omit,
482
+ filters: memory_list_params.Filters | Omit = omit,
483
+ include_content: bool | Omit = omit,
484
+ limit: Union[str, float] | Omit = omit,
485
+ order: Literal["asc", "desc"] | Omit = omit,
486
+ page: Union[str, float] | Omit = omit,
487
+ sort: Literal["createdAt", "updatedAt"] | Omit = omit,
488
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
489
+ # The extra values given here take precedence over values defined on the client or passed to this method.
490
+ extra_headers: Headers | None = None,
491
+ extra_query: Query | None = None,
492
+ extra_body: Body | None = None,
493
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
494
+ ) -> MemoryListResponse:
495
+ """
496
+ Retrieves a paginated list of documents with their metadata and workflow status
497
+
498
+ Args:
499
+ container_tags: Optional tags this document should be containerized by. This can be an ID for
500
+ your user, a project ID, or any other identifier you wish to use to group
501
+ documents.
502
+
503
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
504
+
505
+ include_content: Whether to include the content field in the response. Warning: This can make
506
+ responses significantly larger.
507
+
508
+ limit: Number of items per page
509
+
510
+ order: Sort order
511
+
512
+ page: Page number to fetch
513
+
514
+ sort: Field to sort by
515
+
516
+ extra_headers: Send extra headers
517
+
518
+ extra_query: Add additional query parameters to the request
519
+
520
+ extra_body: Add additional JSON properties to the request
521
+
522
+ timeout: Override the client-level default timeout for this request, in seconds
523
+ """
524
+ return await self._post(
525
+ "/v3/documents/list",
526
+ body=await async_maybe_transform(
527
+ {
528
+ "container_tags": container_tags,
529
+ "filters": filters,
530
+ "include_content": include_content,
531
+ "limit": limit,
532
+ "order": order,
533
+ "page": page,
534
+ "sort": sort,
535
+ },
536
+ memory_list_params.MemoryListParams,
537
+ ),
538
+ options=make_request_options(
539
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
540
+ ),
541
+ cast_to=MemoryListResponse,
542
+ )
543
+
544
+ async def delete(
545
+ self,
546
+ id: str,
547
+ *,
548
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
549
+ # The extra values given here take precedence over values defined on the client or passed to this method.
550
+ extra_headers: Headers | None = None,
551
+ extra_query: Query | None = None,
552
+ extra_body: Body | None = None,
553
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
554
+ ) -> None:
555
+ """
556
+ Delete a document by ID or customId
557
+
558
+ Args:
559
+ extra_headers: Send extra headers
560
+
561
+ extra_query: Add additional query parameters to the request
562
+
563
+ extra_body: Add additional JSON properties to the request
564
+
565
+ timeout: Override the client-level default timeout for this request, in seconds
566
+ """
567
+ if not id:
568
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
569
+ extra_headers = {"Accept": "*/*", **(extra_headers or {})}
570
+ return await self._delete(
571
+ f"/v3/documents/{id}",
572
+ options=make_request_options(
573
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
574
+ ),
575
+ cast_to=NoneType,
576
+ )
577
+
578
+ async def add(
579
+ self,
580
+ *,
581
+ content: str,
582
+ container_tag: str | Omit = omit,
583
+ container_tags: SequenceNotStr[str] | Omit = omit,
584
+ custom_id: str | Omit = omit,
585
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
586
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
587
+ # The extra values given here take precedence over values defined on the client or passed to this method.
588
+ extra_headers: Headers | None = None,
589
+ extra_query: Query | None = None,
590
+ extra_body: Body | None = None,
591
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
592
+ ) -> MemoryAddResponse:
593
+ """
594
+ Add a document with any content type (text, url, file, etc.) and metadata
595
+
596
+ Args:
597
+ content: The content to extract and process into a document. This can be a URL to a
598
+ website, a PDF, an image, or a video.
599
+
600
+ container_tag: Optional tag this document should be containerized by. Max 100 characters,
601
+ alphanumeric with hyphens and underscores only.
602
+
603
+ custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
604
+ hyphens and underscores only.
605
+
606
+ metadata: Optional metadata for the document.
607
+
608
+ extra_headers: Send extra headers
609
+
610
+ extra_query: Add additional query parameters to the request
611
+
612
+ extra_body: Add additional JSON properties to the request
613
+
614
+ timeout: Override the client-level default timeout for this request, in seconds
615
+ """
616
+ return await self._post(
617
+ "/v3/documents",
618
+ body=await async_maybe_transform(
619
+ {
620
+ "content": content,
621
+ "container_tag": container_tag,
622
+ "container_tags": container_tags,
623
+ "custom_id": custom_id,
624
+ "metadata": metadata,
625
+ },
626
+ memory_add_params.MemoryAddParams,
627
+ ),
628
+ options=make_request_options(
629
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
630
+ ),
631
+ cast_to=MemoryAddResponse,
632
+ )
633
+
634
+ async def get(
635
+ self,
636
+ id: str,
637
+ *,
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
+ ) -> MemoryGetResponse:
645
+ """
646
+ Get a document by ID
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
+ if not id:
658
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
659
+ return await self._get(
660
+ f"/v3/documents/{id}",
661
+ options=make_request_options(
662
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
663
+ ),
664
+ cast_to=MemoryGetResponse,
665
+ )
666
+
667
+ async def upload_file(
668
+ self,
669
+ *,
670
+ file: FileTypes,
671
+ container_tags: str | Omit = omit,
672
+ file_type: str | Omit = omit,
673
+ metadata: str | Omit = omit,
674
+ mime_type: str | Omit = omit,
675
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
676
+ # The extra values given here take precedence over values defined on the client or passed to this method.
677
+ extra_headers: Headers | None = None,
678
+ extra_query: Query | None = None,
679
+ extra_body: Body | None = None,
680
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
681
+ ) -> MemoryUploadFileResponse:
682
+ """
683
+ Upload a file to be processed
684
+
685
+ Args:
686
+ file: File to upload and process
687
+
688
+ container_tags: Optional container tags. Can be either a JSON string of an array (e.g.,
689
+ '["user_123", "project_123"]') or a single string (e.g., 'user_123'). Single
690
+ strings will be automatically converted to an array.
691
+
692
+ file_type:
693
+ Optional file type override to force specific processing behavior. Valid values:
694
+ text, pdf, tweet, google_doc, google_slide, google_sheet, image, video,
695
+ notion_doc, webpage, onedrive
696
+
697
+ metadata: Optional metadata for the document as a JSON string. This is used to store
698
+ additional information about the document. Keys must be strings and values can
699
+ be strings, numbers, or booleans.
700
+
701
+ mime_type: Required when fileType is 'image' or 'video'. Specifies the exact MIME type to
702
+ use (e.g., 'image/png', 'image/jpeg', 'video/mp4', 'video/webm')
703
+
704
+ extra_headers: Send extra headers
705
+
706
+ extra_query: Add additional query parameters to the request
707
+
708
+ extra_body: Add additional JSON properties to the request
709
+
710
+ timeout: Override the client-level default timeout for this request, in seconds
711
+ """
712
+ body = deepcopy_minimal(
713
+ {
714
+ "file": file,
715
+ "container_tags": container_tags,
716
+ "file_type": file_type,
717
+ "metadata": metadata,
718
+ "mime_type": mime_type,
719
+ }
720
+ )
721
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
722
+ # It should be noted that the actual Content-Type header that will be
723
+ # sent to the server will contain a `boundary` parameter, e.g.
724
+ # multipart/form-data; boundary=---abc--
725
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
726
+ return await self._post(
727
+ "/v3/documents/file",
728
+ body=await async_maybe_transform(body, memory_upload_file_params.MemoryUploadFileParams),
729
+ files=files,
730
+ options=make_request_options(
731
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
732
+ ),
733
+ cast_to=MemoryUploadFileResponse,
734
+ )
735
+
736
+
737
+ class MemoriesResourceWithRawResponse:
738
+ def __init__(self, memories: MemoriesResource) -> None:
739
+ self._memories = memories
740
+
741
+ self.update = to_raw_response_wrapper(
742
+ memories.update,
743
+ )
744
+ self.list = to_raw_response_wrapper(
745
+ memories.list,
746
+ )
747
+ self.delete = to_raw_response_wrapper(
748
+ memories.delete,
749
+ )
750
+ self.add = to_raw_response_wrapper(
751
+ memories.add,
752
+ )
753
+ self.get = to_raw_response_wrapper(
754
+ memories.get,
755
+ )
756
+ self.upload_file = to_raw_response_wrapper(
757
+ memories.upload_file,
758
+ )
759
+
760
+
761
+ class AsyncMemoriesResourceWithRawResponse:
762
+ def __init__(self, memories: AsyncMemoriesResource) -> None:
763
+ self._memories = memories
764
+
765
+ self.update = async_to_raw_response_wrapper(
766
+ memories.update,
767
+ )
768
+ self.list = async_to_raw_response_wrapper(
769
+ memories.list,
770
+ )
771
+ self.delete = async_to_raw_response_wrapper(
772
+ memories.delete,
773
+ )
774
+ self.add = async_to_raw_response_wrapper(
775
+ memories.add,
776
+ )
777
+ self.get = async_to_raw_response_wrapper(
778
+ memories.get,
779
+ )
780
+ self.upload_file = async_to_raw_response_wrapper(
781
+ memories.upload_file,
782
+ )
783
+
784
+
785
+ class MemoriesResourceWithStreamingResponse:
786
+ def __init__(self, memories: MemoriesResource) -> None:
787
+ self._memories = memories
788
+
789
+ self.update = to_streamed_response_wrapper(
790
+ memories.update,
791
+ )
792
+ self.list = to_streamed_response_wrapper(
793
+ memories.list,
794
+ )
795
+ self.delete = to_streamed_response_wrapper(
796
+ memories.delete,
797
+ )
798
+ self.add = to_streamed_response_wrapper(
799
+ memories.add,
800
+ )
801
+ self.get = to_streamed_response_wrapper(
802
+ memories.get,
803
+ )
804
+ self.upload_file = to_streamed_response_wrapper(
805
+ memories.upload_file,
806
+ )
807
+
808
+
809
+ class AsyncMemoriesResourceWithStreamingResponse:
810
+ def __init__(self, memories: AsyncMemoriesResource) -> None:
811
+ self._memories = memories
812
+
813
+ self.update = async_to_streamed_response_wrapper(
814
+ memories.update,
815
+ )
816
+ self.list = async_to_streamed_response_wrapper(
817
+ memories.list,
818
+ )
819
+ self.delete = async_to_streamed_response_wrapper(
820
+ memories.delete,
821
+ )
822
+ self.add = async_to_streamed_response_wrapper(
823
+ memories.add,
824
+ )
825
+ self.get = async_to_streamed_response_wrapper(
826
+ memories.get,
827
+ )
828
+ self.upload_file = async_to_streamed_response_wrapper(
829
+ memories.upload_file,
830
+ )