supermemory 0.1.0a1__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 (47) hide show
  1. supermemory/__init__.py +94 -0
  2. supermemory/_base_client.py +1943 -0
  3. supermemory/_client.py +427 -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 +803 -0
  9. supermemory/_qs.py +150 -0
  10. supermemory/_resource.py +43 -0
  11. supermemory/_response.py +832 -0
  12. supermemory/_streaming.py +333 -0
  13. supermemory/_types.py +217 -0
  14. supermemory/_utils/__init__.py +57 -0
  15. supermemory/_utils/_logs.py +25 -0
  16. supermemory/_utils/_proxy.py +62 -0
  17. supermemory/_utils/_reflection.py +42 -0
  18. supermemory/_utils/_streams.py +12 -0
  19. supermemory/_utils/_sync.py +86 -0
  20. supermemory/_utils/_transform.py +447 -0
  21. supermemory/_utils/_typing.py +151 -0
  22. supermemory/_utils/_utils.py +422 -0
  23. supermemory/_version.py +4 -0
  24. supermemory/lib/.keep +4 -0
  25. supermemory/py.typed +0 -0
  26. supermemory/resources/__init__.py +61 -0
  27. supermemory/resources/connection.py +267 -0
  28. supermemory/resources/memory.py +487 -0
  29. supermemory/resources/search.py +254 -0
  30. supermemory/resources/settings.py +195 -0
  31. supermemory/types/__init__.py +16 -0
  32. supermemory/types/connection_create_params.py +15 -0
  33. supermemory/types/connection_create_response.py +13 -0
  34. supermemory/types/memory_create_params.py +23 -0
  35. supermemory/types/memory_create_response.py +11 -0
  36. supermemory/types/memory_delete_response.py +9 -0
  37. supermemory/types/memory_get_response.py +27 -0
  38. supermemory/types/memory_list_params.py +24 -0
  39. supermemory/types/memory_list_response.py +59 -0
  40. supermemory/types/search_execute_params.py +56 -0
  41. supermemory/types/search_execute_response.py +52 -0
  42. supermemory/types/setting_update_params.py +30 -0
  43. supermemory/types/setting_update_response.py +35 -0
  44. supermemory-0.1.0a1.dist-info/METADATA +376 -0
  45. supermemory-0.1.0a1.dist-info/RECORD +47 -0
  46. supermemory-0.1.0a1.dist-info/WHEEL +4 -0
  47. supermemory-0.1.0a1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,487 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict, Union
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import memory_list_params, memory_create_params
11
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
12
+ from .._utils import maybe_transform, 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_get_response import MemoryGetResponse
23
+ from ..types.memory_list_response import MemoryListResponse
24
+ from ..types.memory_create_response import MemoryCreateResponse
25
+ from ..types.memory_delete_response import MemoryDeleteResponse
26
+
27
+ __all__ = ["MemoryResource", "AsyncMemoryResource"]
28
+
29
+
30
+ class MemoryResource(SyncAPIResource):
31
+ @cached_property
32
+ def with_raw_response(self) -> MemoryResourceWithRawResponse:
33
+ """
34
+ This property can be used as a prefix for any HTTP method call to return
35
+ the raw response object instead of the parsed content.
36
+
37
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
38
+ """
39
+ return MemoryResourceWithRawResponse(self)
40
+
41
+ @cached_property
42
+ def with_streaming_response(self) -> MemoryResourceWithStreamingResponse:
43
+ """
44
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
45
+
46
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
47
+ """
48
+ return MemoryResourceWithStreamingResponse(self)
49
+
50
+ def create(
51
+ self,
52
+ *,
53
+ content: str,
54
+ id: str | NotGiven = NOT_GIVEN,
55
+ metadata: Dict[str, Union[str, float, bool]] | NotGiven = NOT_GIVEN,
56
+ user_id: str | NotGiven = NOT_GIVEN,
57
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
58
+ # The extra values given here take precedence over values defined on the client or passed to this method.
59
+ extra_headers: Headers | None = None,
60
+ extra_query: Query | None = None,
61
+ extra_body: Body | None = None,
62
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
63
+ ) -> MemoryCreateResponse:
64
+ """
65
+ Add a new memory with content and metadata
66
+
67
+ Args:
68
+ content: Content of the memory
69
+
70
+ metadata: Optional metadata for the memory
71
+
72
+ user_id: Optional end user ID this memory belongs to
73
+
74
+ extra_headers: Send extra headers
75
+
76
+ extra_query: Add additional query parameters to the request
77
+
78
+ extra_body: Add additional JSON properties to the request
79
+
80
+ timeout: Override the client-level default timeout for this request, in seconds
81
+ """
82
+ return self._post(
83
+ "/add",
84
+ body=maybe_transform(
85
+ {
86
+ "content": content,
87
+ "id": id,
88
+ "metadata": metadata,
89
+ "user_id": user_id,
90
+ },
91
+ memory_create_params.MemoryCreateParams,
92
+ ),
93
+ options=make_request_options(
94
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
95
+ ),
96
+ cast_to=MemoryCreateResponse,
97
+ )
98
+
99
+ def list(
100
+ self,
101
+ *,
102
+ filters: str | NotGiven = NOT_GIVEN,
103
+ limit: str | NotGiven = NOT_GIVEN,
104
+ order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
105
+ page: str | NotGiven = NOT_GIVEN,
106
+ sort: Literal["createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
107
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
108
+ # The extra values given here take precedence over values defined on the client or passed to this method.
109
+ extra_headers: Headers | None = None,
110
+ extra_query: Query | None = None,
111
+ extra_body: Body | None = None,
112
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
113
+ ) -> MemoryListResponse:
114
+ """
115
+ Retrieves a paginated list of memories with their metadata and workflow status
116
+
117
+ Args:
118
+ filters: Optional filters to apply to the search
119
+
120
+ limit: Number of items per page
121
+
122
+ order: Sort order
123
+
124
+ page: Page number to fetch
125
+
126
+ sort: Field to sort by
127
+
128
+ extra_headers: Send extra headers
129
+
130
+ extra_query: Add additional query parameters to the request
131
+
132
+ extra_body: Add additional JSON properties to the request
133
+
134
+ timeout: Override the client-level default timeout for this request, in seconds
135
+ """
136
+ return self._get(
137
+ "/memories",
138
+ options=make_request_options(
139
+ extra_headers=extra_headers,
140
+ extra_query=extra_query,
141
+ extra_body=extra_body,
142
+ timeout=timeout,
143
+ query=maybe_transform(
144
+ {
145
+ "filters": filters,
146
+ "limit": limit,
147
+ "order": order,
148
+ "page": page,
149
+ "sort": sort,
150
+ },
151
+ memory_list_params.MemoryListParams,
152
+ ),
153
+ ),
154
+ cast_to=MemoryListResponse,
155
+ )
156
+
157
+ def delete(
158
+ self,
159
+ id: str,
160
+ *,
161
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
162
+ # The extra values given here take precedence over values defined on the client or passed to this method.
163
+ extra_headers: Headers | None = None,
164
+ extra_query: Query | None = None,
165
+ extra_body: Body | None = None,
166
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
167
+ ) -> MemoryDeleteResponse:
168
+ """
169
+ Delete a memory
170
+
171
+ Args:
172
+ extra_headers: Send extra headers
173
+
174
+ extra_query: Add additional query parameters to the request
175
+
176
+ extra_body: Add additional JSON properties to the request
177
+
178
+ timeout: Override the client-level default timeout for this request, in seconds
179
+ """
180
+ if not id:
181
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
182
+ return self._delete(
183
+ f"/delete/{id}",
184
+ options=make_request_options(
185
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
186
+ ),
187
+ cast_to=MemoryDeleteResponse,
188
+ )
189
+
190
+ def get(
191
+ self,
192
+ id: str,
193
+ *,
194
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
195
+ # The extra values given here take precedence over values defined on the client or passed to this method.
196
+ extra_headers: Headers | None = None,
197
+ extra_query: Query | None = None,
198
+ extra_body: Body | None = None,
199
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
200
+ ) -> MemoryGetResponse:
201
+ """
202
+ Get a memory by ID
203
+
204
+ Args:
205
+ extra_headers: Send extra headers
206
+
207
+ extra_query: Add additional query parameters to the request
208
+
209
+ extra_body: Add additional JSON properties to the request
210
+
211
+ timeout: Override the client-level default timeout for this request, in seconds
212
+ """
213
+ if not id:
214
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
215
+ return self._get(
216
+ f"/memory/{id}",
217
+ options=make_request_options(
218
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
219
+ ),
220
+ cast_to=MemoryGetResponse,
221
+ )
222
+
223
+
224
+ class AsyncMemoryResource(AsyncAPIResource):
225
+ @cached_property
226
+ def with_raw_response(self) -> AsyncMemoryResourceWithRawResponse:
227
+ """
228
+ This property can be used as a prefix for any HTTP method call to return
229
+ the raw response object instead of the parsed content.
230
+
231
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
232
+ """
233
+ return AsyncMemoryResourceWithRawResponse(self)
234
+
235
+ @cached_property
236
+ def with_streaming_response(self) -> AsyncMemoryResourceWithStreamingResponse:
237
+ """
238
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
239
+
240
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
241
+ """
242
+ return AsyncMemoryResourceWithStreamingResponse(self)
243
+
244
+ async def create(
245
+ self,
246
+ *,
247
+ content: str,
248
+ id: str | NotGiven = NOT_GIVEN,
249
+ metadata: Dict[str, Union[str, float, bool]] | NotGiven = NOT_GIVEN,
250
+ user_id: str | NotGiven = NOT_GIVEN,
251
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
252
+ # The extra values given here take precedence over values defined on the client or passed to this method.
253
+ extra_headers: Headers | None = None,
254
+ extra_query: Query | None = None,
255
+ extra_body: Body | None = None,
256
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
257
+ ) -> MemoryCreateResponse:
258
+ """
259
+ Add a new memory with content and metadata
260
+
261
+ Args:
262
+ content: Content of the memory
263
+
264
+ metadata: Optional metadata for the memory
265
+
266
+ user_id: Optional end user ID this memory belongs to
267
+
268
+ extra_headers: Send extra headers
269
+
270
+ extra_query: Add additional query parameters to the request
271
+
272
+ extra_body: Add additional JSON properties to the request
273
+
274
+ timeout: Override the client-level default timeout for this request, in seconds
275
+ """
276
+ return await self._post(
277
+ "/add",
278
+ body=await async_maybe_transform(
279
+ {
280
+ "content": content,
281
+ "id": id,
282
+ "metadata": metadata,
283
+ "user_id": user_id,
284
+ },
285
+ memory_create_params.MemoryCreateParams,
286
+ ),
287
+ options=make_request_options(
288
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
289
+ ),
290
+ cast_to=MemoryCreateResponse,
291
+ )
292
+
293
+ async def list(
294
+ self,
295
+ *,
296
+ filters: str | NotGiven = NOT_GIVEN,
297
+ limit: str | NotGiven = NOT_GIVEN,
298
+ order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
299
+ page: str | NotGiven = NOT_GIVEN,
300
+ sort: Literal["createdAt", "updatedAt"] | NotGiven = NOT_GIVEN,
301
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
302
+ # The extra values given here take precedence over values defined on the client or passed to this method.
303
+ extra_headers: Headers | None = None,
304
+ extra_query: Query | None = None,
305
+ extra_body: Body | None = None,
306
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
307
+ ) -> MemoryListResponse:
308
+ """
309
+ Retrieves a paginated list of memories with their metadata and workflow status
310
+
311
+ Args:
312
+ filters: Optional filters to apply to the search
313
+
314
+ limit: Number of items per page
315
+
316
+ order: Sort order
317
+
318
+ page: Page number to fetch
319
+
320
+ sort: Field to sort by
321
+
322
+ extra_headers: Send extra headers
323
+
324
+ extra_query: Add additional query parameters to the request
325
+
326
+ extra_body: Add additional JSON properties to the request
327
+
328
+ timeout: Override the client-level default timeout for this request, in seconds
329
+ """
330
+ return await self._get(
331
+ "/memories",
332
+ options=make_request_options(
333
+ extra_headers=extra_headers,
334
+ extra_query=extra_query,
335
+ extra_body=extra_body,
336
+ timeout=timeout,
337
+ query=await async_maybe_transform(
338
+ {
339
+ "filters": filters,
340
+ "limit": limit,
341
+ "order": order,
342
+ "page": page,
343
+ "sort": sort,
344
+ },
345
+ memory_list_params.MemoryListParams,
346
+ ),
347
+ ),
348
+ cast_to=MemoryListResponse,
349
+ )
350
+
351
+ async def delete(
352
+ self,
353
+ id: str,
354
+ *,
355
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
356
+ # The extra values given here take precedence over values defined on the client or passed to this method.
357
+ extra_headers: Headers | None = None,
358
+ extra_query: Query | None = None,
359
+ extra_body: Body | None = None,
360
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
361
+ ) -> MemoryDeleteResponse:
362
+ """
363
+ Delete a memory
364
+
365
+ Args:
366
+ extra_headers: Send extra headers
367
+
368
+ extra_query: Add additional query parameters to the request
369
+
370
+ extra_body: Add additional JSON properties to the request
371
+
372
+ timeout: Override the client-level default timeout for this request, in seconds
373
+ """
374
+ if not id:
375
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
376
+ return await self._delete(
377
+ f"/delete/{id}",
378
+ options=make_request_options(
379
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
380
+ ),
381
+ cast_to=MemoryDeleteResponse,
382
+ )
383
+
384
+ async def get(
385
+ self,
386
+ id: str,
387
+ *,
388
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
389
+ # The extra values given here take precedence over values defined on the client or passed to this method.
390
+ extra_headers: Headers | None = None,
391
+ extra_query: Query | None = None,
392
+ extra_body: Body | None = None,
393
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
394
+ ) -> MemoryGetResponse:
395
+ """
396
+ Get a memory by ID
397
+
398
+ Args:
399
+ extra_headers: Send extra headers
400
+
401
+ extra_query: Add additional query parameters to the request
402
+
403
+ extra_body: Add additional JSON properties to the request
404
+
405
+ timeout: Override the client-level default timeout for this request, in seconds
406
+ """
407
+ if not id:
408
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
409
+ return await self._get(
410
+ f"/memory/{id}",
411
+ options=make_request_options(
412
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
413
+ ),
414
+ cast_to=MemoryGetResponse,
415
+ )
416
+
417
+
418
+ class MemoryResourceWithRawResponse:
419
+ def __init__(self, memory: MemoryResource) -> None:
420
+ self._memory = memory
421
+
422
+ self.create = to_raw_response_wrapper(
423
+ memory.create,
424
+ )
425
+ self.list = to_raw_response_wrapper(
426
+ memory.list,
427
+ )
428
+ self.delete = to_raw_response_wrapper(
429
+ memory.delete,
430
+ )
431
+ self.get = to_raw_response_wrapper(
432
+ memory.get,
433
+ )
434
+
435
+
436
+ class AsyncMemoryResourceWithRawResponse:
437
+ def __init__(self, memory: AsyncMemoryResource) -> None:
438
+ self._memory = memory
439
+
440
+ self.create = async_to_raw_response_wrapper(
441
+ memory.create,
442
+ )
443
+ self.list = async_to_raw_response_wrapper(
444
+ memory.list,
445
+ )
446
+ self.delete = async_to_raw_response_wrapper(
447
+ memory.delete,
448
+ )
449
+ self.get = async_to_raw_response_wrapper(
450
+ memory.get,
451
+ )
452
+
453
+
454
+ class MemoryResourceWithStreamingResponse:
455
+ def __init__(self, memory: MemoryResource) -> None:
456
+ self._memory = memory
457
+
458
+ self.create = to_streamed_response_wrapper(
459
+ memory.create,
460
+ )
461
+ self.list = to_streamed_response_wrapper(
462
+ memory.list,
463
+ )
464
+ self.delete = to_streamed_response_wrapper(
465
+ memory.delete,
466
+ )
467
+ self.get = to_streamed_response_wrapper(
468
+ memory.get,
469
+ )
470
+
471
+
472
+ class AsyncMemoryResourceWithStreamingResponse:
473
+ def __init__(self, memory: AsyncMemoryResource) -> None:
474
+ self._memory = memory
475
+
476
+ self.create = async_to_streamed_response_wrapper(
477
+ memory.create,
478
+ )
479
+ self.list = async_to_streamed_response_wrapper(
480
+ memory.list,
481
+ )
482
+ self.delete = async_to_streamed_response_wrapper(
483
+ memory.delete,
484
+ )
485
+ self.get = async_to_streamed_response_wrapper(
486
+ memory.get,
487
+ )