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
supermemory/_client.py ADDED
@@ -0,0 +1,683 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Any, Dict, Union, Mapping
7
+ from typing_extensions import Self, override
8
+
9
+ import httpx
10
+
11
+ from . import _exceptions
12
+ from ._qs import Querystring
13
+ from .types import client_add_params, client_profile_params
14
+ from ._types import (
15
+ Body,
16
+ Omit,
17
+ Query,
18
+ Headers,
19
+ Timeout,
20
+ NotGiven,
21
+ Transport,
22
+ ProxiesTypes,
23
+ RequestOptions,
24
+ SequenceNotStr,
25
+ omit,
26
+ not_given,
27
+ )
28
+ from ._utils import (
29
+ is_given,
30
+ maybe_transform,
31
+ get_async_library,
32
+ async_maybe_transform,
33
+ )
34
+ from ._version import __version__
35
+ from ._response import (
36
+ to_raw_response_wrapper,
37
+ to_streamed_response_wrapper,
38
+ async_to_raw_response_wrapper,
39
+ async_to_streamed_response_wrapper,
40
+ )
41
+ from .resources import search, memories, settings, documents, connections
42
+ from ._streaming import Stream as Stream, AsyncStream as AsyncStream
43
+ from ._exceptions import APIStatusError, SupermemoryError
44
+ from ._base_client import (
45
+ DEFAULT_MAX_RETRIES,
46
+ SyncAPIClient,
47
+ AsyncAPIClient,
48
+ make_request_options,
49
+ )
50
+ from .types.add_response import AddResponse
51
+ from .types.profile_response import ProfileResponse
52
+
53
+ __all__ = [
54
+ "Timeout",
55
+ "Transport",
56
+ "ProxiesTypes",
57
+ "RequestOptions",
58
+ "Supermemory",
59
+ "AsyncSupermemory",
60
+ "Client",
61
+ "AsyncClient",
62
+ ]
63
+
64
+
65
+ class Supermemory(SyncAPIClient):
66
+ memories: memories.MemoriesResource
67
+ documents: documents.DocumentsResource
68
+ search: search.SearchResource
69
+ settings: settings.SettingsResource
70
+ connections: connections.ConnectionsResource
71
+ with_raw_response: SupermemoryWithRawResponse
72
+ with_streaming_response: SupermemoryWithStreamedResponse
73
+
74
+ # client options
75
+ api_key: str
76
+
77
+ def __init__(
78
+ self,
79
+ *,
80
+ api_key: str | None = None,
81
+ base_url: str | httpx.URL | None = None,
82
+ timeout: float | Timeout | None | NotGiven = not_given,
83
+ max_retries: int = DEFAULT_MAX_RETRIES,
84
+ default_headers: Mapping[str, str] | None = None,
85
+ default_query: Mapping[str, object] | None = None,
86
+ # Configure a custom httpx client.
87
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
88
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
89
+ http_client: httpx.Client | None = None,
90
+ # Enable or disable schema validation for data returned by the API.
91
+ # When enabled an error APIResponseValidationError is raised
92
+ # if the API responds with invalid data for the expected schema.
93
+ #
94
+ # This parameter may be removed or changed in the future.
95
+ # If you rely on this feature, please open a GitHub issue
96
+ # outlining your use-case to help us decide if it should be
97
+ # part of our public interface in the future.
98
+ _strict_response_validation: bool = False,
99
+ ) -> None:
100
+ """Construct a new synchronous Supermemory client instance.
101
+
102
+ This automatically infers the `api_key` argument from the `SUPERMEMORY_API_KEY` environment variable if it is not provided.
103
+ """
104
+ if api_key is None:
105
+ api_key = os.environ.get("SUPERMEMORY_API_KEY")
106
+ if api_key is None:
107
+ raise SupermemoryError(
108
+ "The api_key client option must be set either by passing api_key to the client or by setting the SUPERMEMORY_API_KEY environment variable"
109
+ )
110
+ self.api_key = api_key
111
+
112
+ if base_url is None:
113
+ base_url = os.environ.get("SUPERMEMORY_BASE_URL")
114
+ if base_url is None:
115
+ base_url = f"https://api.supermemory.ai"
116
+
117
+ super().__init__(
118
+ version=__version__,
119
+ base_url=base_url,
120
+ max_retries=max_retries,
121
+ timeout=timeout,
122
+ http_client=http_client,
123
+ custom_headers=default_headers,
124
+ custom_query=default_query,
125
+ _strict_response_validation=_strict_response_validation,
126
+ )
127
+
128
+ self.memories = memories.MemoriesResource(self)
129
+ self.documents = documents.DocumentsResource(self)
130
+ self.search = search.SearchResource(self)
131
+ self.settings = settings.SettingsResource(self)
132
+ self.connections = connections.ConnectionsResource(self)
133
+ self.with_raw_response = SupermemoryWithRawResponse(self)
134
+ self.with_streaming_response = SupermemoryWithStreamedResponse(self)
135
+
136
+ @property
137
+ @override
138
+ def qs(self) -> Querystring:
139
+ return Querystring(array_format="comma")
140
+
141
+ @property
142
+ @override
143
+ def auth_headers(self) -> dict[str, str]:
144
+ api_key = self.api_key
145
+ return {"Authorization": f"Bearer {api_key}"}
146
+
147
+ @property
148
+ @override
149
+ def default_headers(self) -> dict[str, str | Omit]:
150
+ return {
151
+ **super().default_headers,
152
+ "X-Stainless-Async": "false",
153
+ **self._custom_headers,
154
+ }
155
+
156
+ def copy(
157
+ self,
158
+ *,
159
+ api_key: str | None = None,
160
+ base_url: str | httpx.URL | None = None,
161
+ timeout: float | Timeout | None | NotGiven = not_given,
162
+ http_client: httpx.Client | None = None,
163
+ max_retries: int | NotGiven = not_given,
164
+ default_headers: Mapping[str, str] | None = None,
165
+ set_default_headers: Mapping[str, str] | None = None,
166
+ default_query: Mapping[str, object] | None = None,
167
+ set_default_query: Mapping[str, object] | None = None,
168
+ _extra_kwargs: Mapping[str, Any] = {},
169
+ ) -> Self:
170
+ """
171
+ Create a new client instance re-using the same options given to the current client with optional overriding.
172
+ """
173
+ if default_headers is not None and set_default_headers is not None:
174
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
175
+
176
+ if default_query is not None and set_default_query is not None:
177
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
178
+
179
+ headers = self._custom_headers
180
+ if default_headers is not None:
181
+ headers = {**headers, **default_headers}
182
+ elif set_default_headers is not None:
183
+ headers = set_default_headers
184
+
185
+ params = self._custom_query
186
+ if default_query is not None:
187
+ params = {**params, **default_query}
188
+ elif set_default_query is not None:
189
+ params = set_default_query
190
+
191
+ http_client = http_client or self._client
192
+ return self.__class__(
193
+ api_key=api_key or self.api_key,
194
+ base_url=base_url or self.base_url,
195
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
196
+ http_client=http_client,
197
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
198
+ default_headers=headers,
199
+ default_query=params,
200
+ **_extra_kwargs,
201
+ )
202
+
203
+ # Alias for `copy` for nicer inline usage, e.g.
204
+ # client.with_options(timeout=10).foo.create(...)
205
+ with_options = copy
206
+
207
+ def add(
208
+ self,
209
+ *,
210
+ content: str,
211
+ container_tag: str | Omit = omit,
212
+ container_tags: SequenceNotStr[str] | Omit = omit,
213
+ custom_id: str | Omit = omit,
214
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
215
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
216
+ # The extra values given here take precedence over values defined on the client or passed to this method.
217
+ extra_headers: Headers | None = None,
218
+ extra_query: Query | None = None,
219
+ extra_body: Body | None = None,
220
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
221
+ ) -> AddResponse:
222
+ """
223
+ Add a document with any content type (text, url, file, etc.) and metadata
224
+
225
+ Args:
226
+ content: The content to extract and process into a document. This can be a URL to a
227
+ website, a PDF, an image, or a video.
228
+
229
+ container_tag: Optional tag this document should be containerized by. Max 100 characters,
230
+ alphanumeric with hyphens and underscores only.
231
+
232
+ custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
233
+ hyphens and underscores only.
234
+
235
+ metadata: Optional metadata for the document.
236
+
237
+ extra_headers: Send extra headers
238
+
239
+ extra_query: Add additional query parameters to the request
240
+
241
+ extra_body: Add additional JSON properties to the request
242
+
243
+ timeout: Override the client-level default timeout for this request, in seconds
244
+ """
245
+ return self.post(
246
+ "/v3/documents",
247
+ body=maybe_transform(
248
+ {
249
+ "content": content,
250
+ "container_tag": container_tag,
251
+ "container_tags": container_tags,
252
+ "custom_id": custom_id,
253
+ "metadata": metadata,
254
+ },
255
+ client_add_params.ClientAddParams,
256
+ ),
257
+ options=make_request_options(
258
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
259
+ ),
260
+ cast_to=AddResponse,
261
+ )
262
+
263
+ def profile(
264
+ self,
265
+ *,
266
+ container_tag: str,
267
+ q: str | Omit = omit,
268
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
269
+ # The extra values given here take precedence over values defined on the client or passed to this method.
270
+ extra_headers: Headers | None = None,
271
+ extra_query: Query | None = None,
272
+ extra_body: Body | None = None,
273
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
274
+ ) -> ProfileResponse:
275
+ """
276
+ Get user profile with optional search results
277
+
278
+ Args:
279
+ container_tag: Tag to filter the profile by. This can be an ID for your user, a project ID, or
280
+ any other identifier you wish to use to filter memories.
281
+
282
+ q: Optional search query to include search results in the response
283
+
284
+ extra_headers: Send extra headers
285
+
286
+ extra_query: Add additional query parameters to the request
287
+
288
+ extra_body: Add additional JSON properties to the request
289
+
290
+ timeout: Override the client-level default timeout for this request, in seconds
291
+ """
292
+ return self.post(
293
+ "/v4/profile",
294
+ body=maybe_transform(
295
+ {
296
+ "container_tag": container_tag,
297
+ "q": q,
298
+ },
299
+ client_profile_params.ClientProfileParams,
300
+ ),
301
+ options=make_request_options(
302
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
303
+ ),
304
+ cast_to=ProfileResponse,
305
+ )
306
+
307
+ @override
308
+ def _make_status_error(
309
+ self,
310
+ err_msg: str,
311
+ *,
312
+ body: object,
313
+ response: httpx.Response,
314
+ ) -> APIStatusError:
315
+ if response.status_code == 400:
316
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
317
+
318
+ if response.status_code == 401:
319
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
320
+
321
+ if response.status_code == 403:
322
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
323
+
324
+ if response.status_code == 404:
325
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
326
+
327
+ if response.status_code == 409:
328
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
329
+
330
+ if response.status_code == 422:
331
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
332
+
333
+ if response.status_code == 429:
334
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
335
+
336
+ if response.status_code >= 500:
337
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
338
+ return APIStatusError(err_msg, response=response, body=body)
339
+
340
+
341
+ class AsyncSupermemory(AsyncAPIClient):
342
+ memories: memories.AsyncMemoriesResource
343
+ documents: documents.AsyncDocumentsResource
344
+ search: search.AsyncSearchResource
345
+ settings: settings.AsyncSettingsResource
346
+ connections: connections.AsyncConnectionsResource
347
+ with_raw_response: AsyncSupermemoryWithRawResponse
348
+ with_streaming_response: AsyncSupermemoryWithStreamedResponse
349
+
350
+ # client options
351
+ api_key: str
352
+
353
+ def __init__(
354
+ self,
355
+ *,
356
+ api_key: str | None = None,
357
+ base_url: str | httpx.URL | None = None,
358
+ timeout: float | Timeout | None | NotGiven = not_given,
359
+ max_retries: int = DEFAULT_MAX_RETRIES,
360
+ default_headers: Mapping[str, str] | None = None,
361
+ default_query: Mapping[str, object] | None = None,
362
+ # Configure a custom httpx client.
363
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
364
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
365
+ http_client: httpx.AsyncClient | None = None,
366
+ # Enable or disable schema validation for data returned by the API.
367
+ # When enabled an error APIResponseValidationError is raised
368
+ # if the API responds with invalid data for the expected schema.
369
+ #
370
+ # This parameter may be removed or changed in the future.
371
+ # If you rely on this feature, please open a GitHub issue
372
+ # outlining your use-case to help us decide if it should be
373
+ # part of our public interface in the future.
374
+ _strict_response_validation: bool = False,
375
+ ) -> None:
376
+ """Construct a new async AsyncSupermemory client instance.
377
+
378
+ This automatically infers the `api_key` argument from the `SUPERMEMORY_API_KEY` environment variable if it is not provided.
379
+ """
380
+ if api_key is None:
381
+ api_key = os.environ.get("SUPERMEMORY_API_KEY")
382
+ if api_key is None:
383
+ raise SupermemoryError(
384
+ "The api_key client option must be set either by passing api_key to the client or by setting the SUPERMEMORY_API_KEY environment variable"
385
+ )
386
+ self.api_key = api_key
387
+
388
+ if base_url is None:
389
+ base_url = os.environ.get("SUPERMEMORY_BASE_URL")
390
+ if base_url is None:
391
+ base_url = f"https://api.supermemory.ai"
392
+
393
+ super().__init__(
394
+ version=__version__,
395
+ base_url=base_url,
396
+ max_retries=max_retries,
397
+ timeout=timeout,
398
+ http_client=http_client,
399
+ custom_headers=default_headers,
400
+ custom_query=default_query,
401
+ _strict_response_validation=_strict_response_validation,
402
+ )
403
+
404
+ self.memories = memories.AsyncMemoriesResource(self)
405
+ self.documents = documents.AsyncDocumentsResource(self)
406
+ self.search = search.AsyncSearchResource(self)
407
+ self.settings = settings.AsyncSettingsResource(self)
408
+ self.connections = connections.AsyncConnectionsResource(self)
409
+ self.with_raw_response = AsyncSupermemoryWithRawResponse(self)
410
+ self.with_streaming_response = AsyncSupermemoryWithStreamedResponse(self)
411
+
412
+ @property
413
+ @override
414
+ def qs(self) -> Querystring:
415
+ return Querystring(array_format="comma")
416
+
417
+ @property
418
+ @override
419
+ def auth_headers(self) -> dict[str, str]:
420
+ api_key = self.api_key
421
+ return {"Authorization": f"Bearer {api_key}"}
422
+
423
+ @property
424
+ @override
425
+ def default_headers(self) -> dict[str, str | Omit]:
426
+ return {
427
+ **super().default_headers,
428
+ "X-Stainless-Async": f"async:{get_async_library()}",
429
+ **self._custom_headers,
430
+ }
431
+
432
+ def copy(
433
+ self,
434
+ *,
435
+ api_key: str | None = None,
436
+ base_url: str | httpx.URL | None = None,
437
+ timeout: float | Timeout | None | NotGiven = not_given,
438
+ http_client: httpx.AsyncClient | None = None,
439
+ max_retries: int | NotGiven = not_given,
440
+ default_headers: Mapping[str, str] | None = None,
441
+ set_default_headers: Mapping[str, str] | None = None,
442
+ default_query: Mapping[str, object] | None = None,
443
+ set_default_query: Mapping[str, object] | None = None,
444
+ _extra_kwargs: Mapping[str, Any] = {},
445
+ ) -> Self:
446
+ """
447
+ Create a new client instance re-using the same options given to the current client with optional overriding.
448
+ """
449
+ if default_headers is not None and set_default_headers is not None:
450
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
451
+
452
+ if default_query is not None and set_default_query is not None:
453
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
454
+
455
+ headers = self._custom_headers
456
+ if default_headers is not None:
457
+ headers = {**headers, **default_headers}
458
+ elif set_default_headers is not None:
459
+ headers = set_default_headers
460
+
461
+ params = self._custom_query
462
+ if default_query is not None:
463
+ params = {**params, **default_query}
464
+ elif set_default_query is not None:
465
+ params = set_default_query
466
+
467
+ http_client = http_client or self._client
468
+ return self.__class__(
469
+ api_key=api_key or self.api_key,
470
+ base_url=base_url or self.base_url,
471
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
472
+ http_client=http_client,
473
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
474
+ default_headers=headers,
475
+ default_query=params,
476
+ **_extra_kwargs,
477
+ )
478
+
479
+ # Alias for `copy` for nicer inline usage, e.g.
480
+ # client.with_options(timeout=10).foo.create(...)
481
+ with_options = copy
482
+
483
+ async def add(
484
+ self,
485
+ *,
486
+ content: str,
487
+ container_tag: str | Omit = omit,
488
+ container_tags: SequenceNotStr[str] | Omit = omit,
489
+ custom_id: str | Omit = omit,
490
+ metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
491
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
492
+ # The extra values given here take precedence over values defined on the client or passed to this method.
493
+ extra_headers: Headers | None = None,
494
+ extra_query: Query | None = None,
495
+ extra_body: Body | None = None,
496
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
497
+ ) -> AddResponse:
498
+ """
499
+ Add a document with any content type (text, url, file, etc.) and metadata
500
+
501
+ Args:
502
+ content: The content to extract and process into a document. This can be a URL to a
503
+ website, a PDF, an image, or a video.
504
+
505
+ container_tag: Optional tag this document should be containerized by. Max 100 characters,
506
+ alphanumeric with hyphens and underscores only.
507
+
508
+ custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
509
+ hyphens and underscores only.
510
+
511
+ metadata: Optional metadata for the document.
512
+
513
+ extra_headers: Send extra headers
514
+
515
+ extra_query: Add additional query parameters to the request
516
+
517
+ extra_body: Add additional JSON properties to the request
518
+
519
+ timeout: Override the client-level default timeout for this request, in seconds
520
+ """
521
+ return await self.post(
522
+ "/v3/documents",
523
+ body=await async_maybe_transform(
524
+ {
525
+ "content": content,
526
+ "container_tag": container_tag,
527
+ "container_tags": container_tags,
528
+ "custom_id": custom_id,
529
+ "metadata": metadata,
530
+ },
531
+ client_add_params.ClientAddParams,
532
+ ),
533
+ options=make_request_options(
534
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
535
+ ),
536
+ cast_to=AddResponse,
537
+ )
538
+
539
+ async def profile(
540
+ self,
541
+ *,
542
+ container_tag: str,
543
+ q: str | Omit = omit,
544
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
545
+ # The extra values given here take precedence over values defined on the client or passed to this method.
546
+ extra_headers: Headers | None = None,
547
+ extra_query: Query | None = None,
548
+ extra_body: Body | None = None,
549
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
550
+ ) -> ProfileResponse:
551
+ """
552
+ Get user profile with optional search results
553
+
554
+ Args:
555
+ container_tag: Tag to filter the profile by. This can be an ID for your user, a project ID, or
556
+ any other identifier you wish to use to filter memories.
557
+
558
+ q: Optional search query to include search results in the response
559
+
560
+ extra_headers: Send extra headers
561
+
562
+ extra_query: Add additional query parameters to the request
563
+
564
+ extra_body: Add additional JSON properties to the request
565
+
566
+ timeout: Override the client-level default timeout for this request, in seconds
567
+ """
568
+ return await self.post(
569
+ "/v4/profile",
570
+ body=await async_maybe_transform(
571
+ {
572
+ "container_tag": container_tag,
573
+ "q": q,
574
+ },
575
+ client_profile_params.ClientProfileParams,
576
+ ),
577
+ options=make_request_options(
578
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
579
+ ),
580
+ cast_to=ProfileResponse,
581
+ )
582
+
583
+ @override
584
+ def _make_status_error(
585
+ self,
586
+ err_msg: str,
587
+ *,
588
+ body: object,
589
+ response: httpx.Response,
590
+ ) -> APIStatusError:
591
+ if response.status_code == 400:
592
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
593
+
594
+ if response.status_code == 401:
595
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
596
+
597
+ if response.status_code == 403:
598
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
599
+
600
+ if response.status_code == 404:
601
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
602
+
603
+ if response.status_code == 409:
604
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
605
+
606
+ if response.status_code == 422:
607
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
608
+
609
+ if response.status_code == 429:
610
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
611
+
612
+ if response.status_code >= 500:
613
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
614
+ return APIStatusError(err_msg, response=response, body=body)
615
+
616
+
617
+ class SupermemoryWithRawResponse:
618
+ def __init__(self, client: Supermemory) -> None:
619
+ self.memories = memories.MemoriesResourceWithRawResponse(client.memories)
620
+ self.documents = documents.DocumentsResourceWithRawResponse(client.documents)
621
+ self.search = search.SearchResourceWithRawResponse(client.search)
622
+ self.settings = settings.SettingsResourceWithRawResponse(client.settings)
623
+ self.connections = connections.ConnectionsResourceWithRawResponse(client.connections)
624
+
625
+ self.add = to_raw_response_wrapper(
626
+ client.add,
627
+ )
628
+ self.profile = to_raw_response_wrapper(
629
+ client.profile,
630
+ )
631
+
632
+
633
+ class AsyncSupermemoryWithRawResponse:
634
+ def __init__(self, client: AsyncSupermemory) -> None:
635
+ self.memories = memories.AsyncMemoriesResourceWithRawResponse(client.memories)
636
+ self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents)
637
+ self.search = search.AsyncSearchResourceWithRawResponse(client.search)
638
+ self.settings = settings.AsyncSettingsResourceWithRawResponse(client.settings)
639
+ self.connections = connections.AsyncConnectionsResourceWithRawResponse(client.connections)
640
+
641
+ self.add = async_to_raw_response_wrapper(
642
+ client.add,
643
+ )
644
+ self.profile = async_to_raw_response_wrapper(
645
+ client.profile,
646
+ )
647
+
648
+
649
+ class SupermemoryWithStreamedResponse:
650
+ def __init__(self, client: Supermemory) -> None:
651
+ self.memories = memories.MemoriesResourceWithStreamingResponse(client.memories)
652
+ self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents)
653
+ self.search = search.SearchResourceWithStreamingResponse(client.search)
654
+ self.settings = settings.SettingsResourceWithStreamingResponse(client.settings)
655
+ self.connections = connections.ConnectionsResourceWithStreamingResponse(client.connections)
656
+
657
+ self.add = to_streamed_response_wrapper(
658
+ client.add,
659
+ )
660
+ self.profile = to_streamed_response_wrapper(
661
+ client.profile,
662
+ )
663
+
664
+
665
+ class AsyncSupermemoryWithStreamedResponse:
666
+ def __init__(self, client: AsyncSupermemory) -> None:
667
+ self.memories = memories.AsyncMemoriesResourceWithStreamingResponse(client.memories)
668
+ self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents)
669
+ self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
670
+ self.settings = settings.AsyncSettingsResourceWithStreamingResponse(client.settings)
671
+ self.connections = connections.AsyncConnectionsResourceWithStreamingResponse(client.connections)
672
+
673
+ self.add = async_to_streamed_response_wrapper(
674
+ client.add,
675
+ )
676
+ self.profile = async_to_streamed_response_wrapper(
677
+ client.profile,
678
+ )
679
+
680
+
681
+ Client = Supermemory
682
+
683
+ AsyncClient = AsyncSupermemory