supermemory 3.0.0a28__py3-none-any.whl → 3.0.0a30__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.

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