1010
1111from . import _exceptions
1212from ._qs import Querystring
13- from .types import client_add_params , client_profile_params
13+ from .types import client_add_params , client_search_params , client_profile_params
1414from ._types import (
1515 Body ,
1616 Omit ,
4848 make_request_options ,
4949)
5050from .types .add_response import AddResponse
51+ from .types .search_response import SearchResponse
5152from .types .profile_response import ProfileResponse
5253
5354__all__ = [
@@ -304,6 +305,76 @@ def profile(
304305 cast_to = ProfileResponse ,
305306 )
306307
308+ def search (
309+ self ,
310+ * ,
311+ q : str ,
312+ container_tag : str | Omit = omit ,
313+ filters : client_search_params .Filters | Omit = omit ,
314+ include : client_search_params .Include | Omit = omit ,
315+ limit : int | Omit = omit ,
316+ rerank : bool | Omit = omit ,
317+ rewrite_query : bool | Omit = omit ,
318+ threshold : float | Omit = omit ,
319+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
320+ # The extra values given here take precedence over values defined on the client or passed to this method.
321+ extra_headers : Headers | None = None ,
322+ extra_query : Query | None = None ,
323+ extra_body : Body | None = None ,
324+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
325+ ) -> SearchResponse :
326+ """
327+ Search memory entries - Low latency for conversational
328+
329+ Args:
330+ q: Search query string
331+
332+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
333+ user, a project ID, or any other identifier you wish to use to filter memories.
334+
335+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
336+
337+ limit: Maximum number of results to return
338+
339+ rerank: If true, rerank the results based on the query. This is helpful if you want to
340+ ensure the most relevant results are returned.
341+
342+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
343+ the latency by about 400ms
344+
345+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
346+ most memories, more results), 1 is most sensitive (returns lesser memories,
347+ accurate results)
348+
349+ extra_headers: Send extra headers
350+
351+ extra_query: Add additional query parameters to the request
352+
353+ extra_body: Add additional JSON properties to the request
354+
355+ timeout: Override the client-level default timeout for this request, in seconds
356+ """
357+ return self .post (
358+ "/v4/search" ,
359+ body = maybe_transform (
360+ {
361+ "q" : q ,
362+ "container_tag" : container_tag ,
363+ "filters" : filters ,
364+ "include" : include ,
365+ "limit" : limit ,
366+ "rerank" : rerank ,
367+ "rewrite_query" : rewrite_query ,
368+ "threshold" : threshold ,
369+ },
370+ client_search_params .ClientSearchParams ,
371+ ),
372+ options = make_request_options (
373+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
374+ ),
375+ cast_to = SearchResponse ,
376+ )
377+
307378 @override
308379 def _make_status_error (
309380 self ,
@@ -580,6 +651,76 @@ async def profile(
580651 cast_to = ProfileResponse ,
581652 )
582653
654+ async def search (
655+ self ,
656+ * ,
657+ q : str ,
658+ container_tag : str | Omit = omit ,
659+ filters : client_search_params .Filters | Omit = omit ,
660+ include : client_search_params .Include | Omit = omit ,
661+ limit : int | Omit = omit ,
662+ rerank : bool | Omit = omit ,
663+ rewrite_query : bool | Omit = omit ,
664+ threshold : float | Omit = omit ,
665+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
666+ # The extra values given here take precedence over values defined on the client or passed to this method.
667+ extra_headers : Headers | None = None ,
668+ extra_query : Query | None = None ,
669+ extra_body : Body | None = None ,
670+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
671+ ) -> SearchResponse :
672+ """
673+ Search memory entries - Low latency for conversational
674+
675+ Args:
676+ q: Search query string
677+
678+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
679+ user, a project ID, or any other identifier you wish to use to filter memories.
680+
681+ filters: Optional filters to apply to the search. Can be a JSON string or Query object.
682+
683+ limit: Maximum number of results to return
684+
685+ rerank: If true, rerank the results based on the query. This is helpful if you want to
686+ ensure the most relevant results are returned.
687+
688+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
689+ the latency by about 400ms
690+
691+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
692+ most memories, more results), 1 is most sensitive (returns lesser memories,
693+ accurate results)
694+
695+ extra_headers: Send extra headers
696+
697+ extra_query: Add additional query parameters to the request
698+
699+ extra_body: Add additional JSON properties to the request
700+
701+ timeout: Override the client-level default timeout for this request, in seconds
702+ """
703+ return await self .post (
704+ "/v4/search" ,
705+ body = await async_maybe_transform (
706+ {
707+ "q" : q ,
708+ "container_tag" : container_tag ,
709+ "filters" : filters ,
710+ "include" : include ,
711+ "limit" : limit ,
712+ "rerank" : rerank ,
713+ "rewrite_query" : rewrite_query ,
714+ "threshold" : threshold ,
715+ },
716+ client_search_params .ClientSearchParams ,
717+ ),
718+ options = make_request_options (
719+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
720+ ),
721+ cast_to = SearchResponse ,
722+ )
723+
583724 @override
584725 def _make_status_error (
585726 self ,
@@ -628,6 +769,9 @@ def __init__(self, client: Supermemory) -> None:
628769 self .profile = to_raw_response_wrapper (
629770 client .profile ,
630771 )
772+ self .search = to_raw_response_wrapper (
773+ client .search ,
774+ )
631775
632776
633777class AsyncSupermemoryWithRawResponse :
@@ -644,6 +788,9 @@ def __init__(self, client: AsyncSupermemory) -> None:
644788 self .profile = async_to_raw_response_wrapper (
645789 client .profile ,
646790 )
791+ self .search = async_to_raw_response_wrapper (
792+ client .search ,
793+ )
647794
648795
649796class SupermemoryWithStreamedResponse :
@@ -660,6 +807,9 @@ def __init__(self, client: Supermemory) -> None:
660807 self .profile = to_streamed_response_wrapper (
661808 client .profile ,
662809 )
810+ self .search = to_streamed_response_wrapper (
811+ client .search ,
812+ )
663813
664814
665815class AsyncSupermemoryWithStreamedResponse :
@@ -676,6 +826,9 @@ def __init__(self, client: AsyncSupermemory) -> None:
676826 self .profile = async_to_streamed_response_wrapper (
677827 client .profile ,
678828 )
829+ self .search = async_to_streamed_response_wrapper (
830+ client .search ,
831+ )
679832
680833
681834Client = Supermemory
0 commit comments