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,657 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from ..types import search_execute_params, search_memories_params, search_documents_params
8
+ from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
9
+ from .._utils import maybe_transform, async_maybe_transform
10
+ from .._compat import cached_property
11
+ from .._resource import SyncAPIResource, AsyncAPIResource
12
+ from .._response import (
13
+ to_raw_response_wrapper,
14
+ to_streamed_response_wrapper,
15
+ async_to_raw_response_wrapper,
16
+ async_to_streamed_response_wrapper,
17
+ )
18
+ from .._base_client import make_request_options
19
+ from ..types.search_execute_response import SearchExecuteResponse
20
+ from ..types.search_memories_response import SearchMemoriesResponse
21
+ from ..types.search_documents_response import SearchDocumentsResponse
22
+
23
+ __all__ = ["SearchResource", "AsyncSearchResource"]
24
+
25
+
26
+ class SearchResource(SyncAPIResource):
27
+ @cached_property
28
+ def with_raw_response(self) -> SearchResourceWithRawResponse:
29
+ """
30
+ This property can be used as a prefix for any HTTP method call to return
31
+ the raw response object instead of the parsed content.
32
+
33
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
34
+ """
35
+ return SearchResourceWithRawResponse(self)
36
+
37
+ @cached_property
38
+ def with_streaming_response(self) -> SearchResourceWithStreamingResponse:
39
+ """
40
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
41
+
42
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
43
+ """
44
+ return SearchResourceWithStreamingResponse(self)
45
+
46
+ def documents(
47
+ self,
48
+ *,
49
+ q: str,
50
+ categories_filter: SequenceNotStr[str] | Omit = omit,
51
+ chunk_threshold: float | Omit = omit,
52
+ container_tags: SequenceNotStr[str] | Omit = omit,
53
+ doc_id: str | Omit = omit,
54
+ document_threshold: float | Omit = omit,
55
+ filters: search_documents_params.Filters | Omit = omit,
56
+ include_full_docs: bool | Omit = omit,
57
+ include_summary: bool | Omit = omit,
58
+ limit: int | Omit = omit,
59
+ only_matching_chunks: bool | Omit = omit,
60
+ rerank: bool | Omit = omit,
61
+ rewrite_query: bool | Omit = omit,
62
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
63
+ # The extra values given here take precedence over values defined on the client or passed to this method.
64
+ extra_headers: Headers | None = None,
65
+ extra_query: Query | None = None,
66
+ extra_body: Body | None = None,
67
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
68
+ ) -> SearchDocumentsResponse:
69
+ """
70
+ Search memories with advanced filtering
71
+
72
+ Args:
73
+ q: Search query string
74
+
75
+ categories_filter: DEPRECATED: Optional category filters
76
+
77
+ chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
78
+ chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
79
+ results)
80
+
81
+ container_tags: Optional tags this search should be containerized by. This can be an ID for your
82
+ user, a project ID, or any other identifier you wish to use to filter documents.
83
+
84
+ doc_id: Optional document ID to search within. You can use this to find chunks in a very
85
+ large document.
86
+
87
+ document_threshold: DEPRECATED: This field is no longer used in v3 search. The search now uses
88
+ chunkThreshold only. This parameter will be ignored.
89
+
90
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
91
+
92
+ include_full_docs: If true, include full document in the response. This is helpful if you want a
93
+ chatbot to know the full context of the document.
94
+
95
+ include_summary: If true, include document summary in the response. This is helpful if you want a
96
+ chatbot to know the full context of the document.
97
+
98
+ limit: Maximum number of results to return
99
+
100
+ only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
101
+ previous and next chunk to provide more context for LLMs. If you only want the
102
+ matching chunk, set this to true.
103
+
104
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
105
+ ensure the most relevant results are returned.
106
+
107
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
108
+ the latency by about 400ms
109
+
110
+ extra_headers: Send extra headers
111
+
112
+ extra_query: Add additional query parameters to the request
113
+
114
+ extra_body: Add additional JSON properties to the request
115
+
116
+ timeout: Override the client-level default timeout for this request, in seconds
117
+ """
118
+ return self._post(
119
+ "/v3/search",
120
+ body=maybe_transform(
121
+ {
122
+ "q": q,
123
+ "categories_filter": categories_filter,
124
+ "chunk_threshold": chunk_threshold,
125
+ "container_tags": container_tags,
126
+ "doc_id": doc_id,
127
+ "document_threshold": document_threshold,
128
+ "filters": filters,
129
+ "include_full_docs": include_full_docs,
130
+ "include_summary": include_summary,
131
+ "limit": limit,
132
+ "only_matching_chunks": only_matching_chunks,
133
+ "rerank": rerank,
134
+ "rewrite_query": rewrite_query,
135
+ },
136
+ search_documents_params.SearchDocumentsParams,
137
+ ),
138
+ options=make_request_options(
139
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
140
+ ),
141
+ cast_to=SearchDocumentsResponse,
142
+ )
143
+
144
+ def execute(
145
+ self,
146
+ *,
147
+ q: str,
148
+ categories_filter: SequenceNotStr[str] | Omit = omit,
149
+ chunk_threshold: float | Omit = omit,
150
+ container_tags: SequenceNotStr[str] | Omit = omit,
151
+ doc_id: str | Omit = omit,
152
+ document_threshold: float | Omit = omit,
153
+ filters: search_execute_params.Filters | Omit = omit,
154
+ include_full_docs: bool | Omit = omit,
155
+ include_summary: bool | Omit = omit,
156
+ limit: int | Omit = omit,
157
+ only_matching_chunks: bool | Omit = omit,
158
+ rerank: bool | Omit = omit,
159
+ rewrite_query: bool | Omit = omit,
160
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
161
+ # The extra values given here take precedence over values defined on the client or passed to this method.
162
+ extra_headers: Headers | None = None,
163
+ extra_query: Query | None = None,
164
+ extra_body: Body | None = None,
165
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
166
+ ) -> SearchExecuteResponse:
167
+ """
168
+ Search memories with advanced filtering
169
+
170
+ Args:
171
+ q: Search query string
172
+
173
+ categories_filter: DEPRECATED: Optional category filters
174
+
175
+ chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
176
+ chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
177
+ results)
178
+
179
+ container_tags: Optional tags this search should be containerized by. This can be an ID for your
180
+ user, a project ID, or any other identifier you wish to use to filter documents.
181
+
182
+ doc_id: Optional document ID to search within. You can use this to find chunks in a very
183
+ large document.
184
+
185
+ document_threshold: DEPRECATED: This field is no longer used in v3 search. The search now uses
186
+ chunkThreshold only. This parameter will be ignored.
187
+
188
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
189
+
190
+ include_full_docs: If true, include full document in the response. This is helpful if you want a
191
+ chatbot to know the full context of the document.
192
+
193
+ include_summary: If true, include document summary in the response. This is helpful if you want a
194
+ chatbot to know the full context of the document.
195
+
196
+ limit: Maximum number of results to return
197
+
198
+ only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
199
+ previous and next chunk to provide more context for LLMs. If you only want the
200
+ matching chunk, set this to true.
201
+
202
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
203
+ ensure the most relevant results are returned.
204
+
205
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
206
+ the latency by about 400ms
207
+
208
+ extra_headers: Send extra headers
209
+
210
+ extra_query: Add additional query parameters to the request
211
+
212
+ extra_body: Add additional JSON properties to the request
213
+
214
+ timeout: Override the client-level default timeout for this request, in seconds
215
+ """
216
+ return self._post(
217
+ "/v3/search",
218
+ body=maybe_transform(
219
+ {
220
+ "q": q,
221
+ "categories_filter": categories_filter,
222
+ "chunk_threshold": chunk_threshold,
223
+ "container_tags": container_tags,
224
+ "doc_id": doc_id,
225
+ "document_threshold": document_threshold,
226
+ "filters": filters,
227
+ "include_full_docs": include_full_docs,
228
+ "include_summary": include_summary,
229
+ "limit": limit,
230
+ "only_matching_chunks": only_matching_chunks,
231
+ "rerank": rerank,
232
+ "rewrite_query": rewrite_query,
233
+ },
234
+ search_execute_params.SearchExecuteParams,
235
+ ),
236
+ options=make_request_options(
237
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
238
+ ),
239
+ cast_to=SearchExecuteResponse,
240
+ )
241
+
242
+ def memories(
243
+ self,
244
+ *,
245
+ q: str,
246
+ container_tag: str | Omit = omit,
247
+ filters: search_memories_params.Filters | Omit = omit,
248
+ include: search_memories_params.Include | Omit = omit,
249
+ limit: int | Omit = omit,
250
+ rerank: bool | Omit = omit,
251
+ rewrite_query: bool | Omit = omit,
252
+ threshold: float | Omit = omit,
253
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
254
+ # The extra values given here take precedence over values defined on the client or passed to this method.
255
+ extra_headers: Headers | None = None,
256
+ extra_query: Query | None = None,
257
+ extra_body: Body | None = None,
258
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
259
+ ) -> SearchMemoriesResponse:
260
+ """
261
+ Search memory entries - Low latency for conversational
262
+
263
+ Args:
264
+ q: Search query string
265
+
266
+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
267
+ user, a project ID, or any other identifier you wish to use to filter memories.
268
+
269
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
270
+
271
+ limit: Maximum number of results to return
272
+
273
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
274
+ ensure the most relevant results are returned.
275
+
276
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
277
+ the latency by about 400ms
278
+
279
+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
280
+ most memories, more results), 1 is most sensitive (returns lesser memories,
281
+ accurate results)
282
+
283
+ extra_headers: Send extra headers
284
+
285
+ extra_query: Add additional query parameters to the request
286
+
287
+ extra_body: Add additional JSON properties to the request
288
+
289
+ timeout: Override the client-level default timeout for this request, in seconds
290
+ """
291
+ return self._post(
292
+ "/v4/search",
293
+ body=maybe_transform(
294
+ {
295
+ "q": q,
296
+ "container_tag": container_tag,
297
+ "filters": filters,
298
+ "include": include,
299
+ "limit": limit,
300
+ "rerank": rerank,
301
+ "rewrite_query": rewrite_query,
302
+ "threshold": threshold,
303
+ },
304
+ search_memories_params.SearchMemoriesParams,
305
+ ),
306
+ options=make_request_options(
307
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
308
+ ),
309
+ cast_to=SearchMemoriesResponse,
310
+ )
311
+
312
+
313
+ class AsyncSearchResource(AsyncAPIResource):
314
+ @cached_property
315
+ def with_raw_response(self) -> AsyncSearchResourceWithRawResponse:
316
+ """
317
+ This property can be used as a prefix for any HTTP method call to return
318
+ the raw response object instead of the parsed content.
319
+
320
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
321
+ """
322
+ return AsyncSearchResourceWithRawResponse(self)
323
+
324
+ @cached_property
325
+ def with_streaming_response(self) -> AsyncSearchResourceWithStreamingResponse:
326
+ """
327
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
328
+
329
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
330
+ """
331
+ return AsyncSearchResourceWithStreamingResponse(self)
332
+
333
+ async def documents(
334
+ self,
335
+ *,
336
+ q: str,
337
+ categories_filter: SequenceNotStr[str] | Omit = omit,
338
+ chunk_threshold: float | Omit = omit,
339
+ container_tags: SequenceNotStr[str] | Omit = omit,
340
+ doc_id: str | Omit = omit,
341
+ document_threshold: float | Omit = omit,
342
+ filters: search_documents_params.Filters | Omit = omit,
343
+ include_full_docs: bool | Omit = omit,
344
+ include_summary: bool | Omit = omit,
345
+ limit: int | Omit = omit,
346
+ only_matching_chunks: bool | Omit = omit,
347
+ rerank: bool | Omit = omit,
348
+ rewrite_query: bool | Omit = omit,
349
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
350
+ # The extra values given here take precedence over values defined on the client or passed to this method.
351
+ extra_headers: Headers | None = None,
352
+ extra_query: Query | None = None,
353
+ extra_body: Body | None = None,
354
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
355
+ ) -> SearchDocumentsResponse:
356
+ """
357
+ Search memories with advanced filtering
358
+
359
+ Args:
360
+ q: Search query string
361
+
362
+ categories_filter: DEPRECATED: Optional category filters
363
+
364
+ chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
365
+ chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
366
+ results)
367
+
368
+ container_tags: Optional tags this search should be containerized by. This can be an ID for your
369
+ user, a project ID, or any other identifier you wish to use to filter documents.
370
+
371
+ doc_id: Optional document ID to search within. You can use this to find chunks in a very
372
+ large document.
373
+
374
+ document_threshold: DEPRECATED: This field is no longer used in v3 search. The search now uses
375
+ chunkThreshold only. This parameter will be ignored.
376
+
377
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
378
+
379
+ include_full_docs: If true, include full document in the response. This is helpful if you want a
380
+ chatbot to know the full context of the document.
381
+
382
+ include_summary: If true, include document summary in the response. This is helpful if you want a
383
+ chatbot to know the full context of the document.
384
+
385
+ limit: Maximum number of results to return
386
+
387
+ only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
388
+ previous and next chunk to provide more context for LLMs. If you only want the
389
+ matching chunk, set this to true.
390
+
391
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
392
+ ensure the most relevant results are returned.
393
+
394
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
395
+ the latency by about 400ms
396
+
397
+ extra_headers: Send extra headers
398
+
399
+ extra_query: Add additional query parameters to the request
400
+
401
+ extra_body: Add additional JSON properties to the request
402
+
403
+ timeout: Override the client-level default timeout for this request, in seconds
404
+ """
405
+ return await self._post(
406
+ "/v3/search",
407
+ body=await async_maybe_transform(
408
+ {
409
+ "q": q,
410
+ "categories_filter": categories_filter,
411
+ "chunk_threshold": chunk_threshold,
412
+ "container_tags": container_tags,
413
+ "doc_id": doc_id,
414
+ "document_threshold": document_threshold,
415
+ "filters": filters,
416
+ "include_full_docs": include_full_docs,
417
+ "include_summary": include_summary,
418
+ "limit": limit,
419
+ "only_matching_chunks": only_matching_chunks,
420
+ "rerank": rerank,
421
+ "rewrite_query": rewrite_query,
422
+ },
423
+ search_documents_params.SearchDocumentsParams,
424
+ ),
425
+ options=make_request_options(
426
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
427
+ ),
428
+ cast_to=SearchDocumentsResponse,
429
+ )
430
+
431
+ async def execute(
432
+ self,
433
+ *,
434
+ q: str,
435
+ categories_filter: SequenceNotStr[str] | Omit = omit,
436
+ chunk_threshold: float | Omit = omit,
437
+ container_tags: SequenceNotStr[str] | Omit = omit,
438
+ doc_id: str | Omit = omit,
439
+ document_threshold: float | Omit = omit,
440
+ filters: search_execute_params.Filters | Omit = omit,
441
+ include_full_docs: bool | Omit = omit,
442
+ include_summary: bool | Omit = omit,
443
+ limit: int | Omit = omit,
444
+ only_matching_chunks: bool | Omit = omit,
445
+ rerank: bool | Omit = omit,
446
+ rewrite_query: bool | Omit = omit,
447
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
448
+ # The extra values given here take precedence over values defined on the client or passed to this method.
449
+ extra_headers: Headers | None = None,
450
+ extra_query: Query | None = None,
451
+ extra_body: Body | None = None,
452
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
453
+ ) -> SearchExecuteResponse:
454
+ """
455
+ Search memories with advanced filtering
456
+
457
+ Args:
458
+ q: Search query string
459
+
460
+ categories_filter: DEPRECATED: Optional category filters
461
+
462
+ chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
463
+ chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
464
+ results)
465
+
466
+ container_tags: Optional tags this search should be containerized by. This can be an ID for your
467
+ user, a project ID, or any other identifier you wish to use to filter documents.
468
+
469
+ doc_id: Optional document ID to search within. You can use this to find chunks in a very
470
+ large document.
471
+
472
+ document_threshold: DEPRECATED: This field is no longer used in v3 search. The search now uses
473
+ chunkThreshold only. This parameter will be ignored.
474
+
475
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
476
+
477
+ include_full_docs: If true, include full document in the response. This is helpful if you want a
478
+ chatbot to know the full context of the document.
479
+
480
+ include_summary: If true, include document summary in the response. This is helpful if you want a
481
+ chatbot to know the full context of the document.
482
+
483
+ limit: Maximum number of results to return
484
+
485
+ only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
486
+ previous and next chunk to provide more context for LLMs. If you only want the
487
+ matching chunk, set this to true.
488
+
489
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
490
+ ensure the most relevant results are returned.
491
+
492
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
493
+ the latency by about 400ms
494
+
495
+ extra_headers: Send extra headers
496
+
497
+ extra_query: Add additional query parameters to the request
498
+
499
+ extra_body: Add additional JSON properties to the request
500
+
501
+ timeout: Override the client-level default timeout for this request, in seconds
502
+ """
503
+ return await self._post(
504
+ "/v3/search",
505
+ body=await async_maybe_transform(
506
+ {
507
+ "q": q,
508
+ "categories_filter": categories_filter,
509
+ "chunk_threshold": chunk_threshold,
510
+ "container_tags": container_tags,
511
+ "doc_id": doc_id,
512
+ "document_threshold": document_threshold,
513
+ "filters": filters,
514
+ "include_full_docs": include_full_docs,
515
+ "include_summary": include_summary,
516
+ "limit": limit,
517
+ "only_matching_chunks": only_matching_chunks,
518
+ "rerank": rerank,
519
+ "rewrite_query": rewrite_query,
520
+ },
521
+ search_execute_params.SearchExecuteParams,
522
+ ),
523
+ options=make_request_options(
524
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
525
+ ),
526
+ cast_to=SearchExecuteResponse,
527
+ )
528
+
529
+ async def memories(
530
+ self,
531
+ *,
532
+ q: str,
533
+ container_tag: str | Omit = omit,
534
+ filters: search_memories_params.Filters | Omit = omit,
535
+ include: search_memories_params.Include | Omit = omit,
536
+ limit: int | Omit = omit,
537
+ rerank: bool | Omit = omit,
538
+ rewrite_query: bool | Omit = omit,
539
+ threshold: float | Omit = omit,
540
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
541
+ # The extra values given here take precedence over values defined on the client or passed to this method.
542
+ extra_headers: Headers | None = None,
543
+ extra_query: Query | None = None,
544
+ extra_body: Body | None = None,
545
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
546
+ ) -> SearchMemoriesResponse:
547
+ """
548
+ Search memory entries - Low latency for conversational
549
+
550
+ Args:
551
+ q: Search query string
552
+
553
+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
554
+ user, a project ID, or any other identifier you wish to use to filter memories.
555
+
556
+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
557
+
558
+ limit: Maximum number of results to return
559
+
560
+ rerank: If true, rerank the results based on the query. This is helpful if you want to
561
+ ensure the most relevant results are returned.
562
+
563
+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
564
+ the latency by about 400ms
565
+
566
+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
567
+ most memories, more results), 1 is most sensitive (returns lesser memories,
568
+ accurate results)
569
+
570
+ extra_headers: Send extra headers
571
+
572
+ extra_query: Add additional query parameters to the request
573
+
574
+ extra_body: Add additional JSON properties to the request
575
+
576
+ timeout: Override the client-level default timeout for this request, in seconds
577
+ """
578
+ return await self._post(
579
+ "/v4/search",
580
+ body=await async_maybe_transform(
581
+ {
582
+ "q": q,
583
+ "container_tag": container_tag,
584
+ "filters": filters,
585
+ "include": include,
586
+ "limit": limit,
587
+ "rerank": rerank,
588
+ "rewrite_query": rewrite_query,
589
+ "threshold": threshold,
590
+ },
591
+ search_memories_params.SearchMemoriesParams,
592
+ ),
593
+ options=make_request_options(
594
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
595
+ ),
596
+ cast_to=SearchMemoriesResponse,
597
+ )
598
+
599
+
600
+ class SearchResourceWithRawResponse:
601
+ def __init__(self, search: SearchResource) -> None:
602
+ self._search = search
603
+
604
+ self.documents = to_raw_response_wrapper(
605
+ search.documents,
606
+ )
607
+ self.execute = to_raw_response_wrapper(
608
+ search.execute,
609
+ )
610
+ self.memories = to_raw_response_wrapper(
611
+ search.memories,
612
+ )
613
+
614
+
615
+ class AsyncSearchResourceWithRawResponse:
616
+ def __init__(self, search: AsyncSearchResource) -> None:
617
+ self._search = search
618
+
619
+ self.documents = async_to_raw_response_wrapper(
620
+ search.documents,
621
+ )
622
+ self.execute = async_to_raw_response_wrapper(
623
+ search.execute,
624
+ )
625
+ self.memories = async_to_raw_response_wrapper(
626
+ search.memories,
627
+ )
628
+
629
+
630
+ class SearchResourceWithStreamingResponse:
631
+ def __init__(self, search: SearchResource) -> None:
632
+ self._search = search
633
+
634
+ self.documents = to_streamed_response_wrapper(
635
+ search.documents,
636
+ )
637
+ self.execute = to_streamed_response_wrapper(
638
+ search.execute,
639
+ )
640
+ self.memories = to_streamed_response_wrapper(
641
+ search.memories,
642
+ )
643
+
644
+
645
+ class AsyncSearchResourceWithStreamingResponse:
646
+ def __init__(self, search: AsyncSearchResource) -> None:
647
+ self._search = search
648
+
649
+ self.documents = async_to_streamed_response_wrapper(
650
+ search.documents,
651
+ )
652
+ self.execute = async_to_streamed_response_wrapper(
653
+ search.execute,
654
+ )
655
+ self.memories = async_to_streamed_response_wrapper(
656
+ search.memories,
657
+ )