77
88import httpx
99
10- from ..types import search_execute_params
10+ from ..types import search_memories_params , search_documents_params
1111from .._types import NOT_GIVEN , Body , Query , Headers , NotGiven
1212from .._utils import maybe_transform , async_maybe_transform
1313from .._compat import cached_property
1919 async_to_streamed_response_wrapper ,
2020)
2121from .._base_client import make_request_options
22- from ..types .search_execute_response import SearchExecuteResponse
22+ from ..types .search_memories_response import SearchMemoriesResponse
23+ from ..types .search_documents_response import SearchDocumentsResponse
2324
2425__all__ = ["SearchResource" , "AsyncSearchResource" ]
2526
@@ -44,7 +45,7 @@ def with_streaming_response(self) -> SearchResourceWithStreamingResponse:
4445 """
4546 return SearchResourceWithStreamingResponse (self )
4647
47- def execute (
48+ def documents (
4849 self ,
4950 * ,
5051 q : str ,
@@ -53,7 +54,7 @@ def execute(
5354 container_tags : List [str ] | NotGiven = NOT_GIVEN ,
5455 doc_id : str | NotGiven = NOT_GIVEN ,
5556 document_threshold : float | NotGiven = NOT_GIVEN ,
56- filters : search_execute_params .Filters | NotGiven = NOT_GIVEN ,
57+ filters : search_documents_params .Filters | NotGiven = NOT_GIVEN ,
5758 include_full_docs : bool | NotGiven = NOT_GIVEN ,
5859 include_summary : bool | NotGiven = NOT_GIVEN ,
5960 limit : int | NotGiven = NOT_GIVEN ,
@@ -66,7 +67,7 @@ def execute(
6667 extra_query : Query | None = None ,
6768 extra_body : Body | None = None ,
6869 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
69- ) -> SearchExecuteResponse :
70+ ) -> SearchDocumentsResponse :
7071 """
7172 Search memories with advanced filtering
7273
@@ -135,12 +136,82 @@ def execute(
135136 "rerank" : rerank ,
136137 "rewrite_query" : rewrite_query ,
137138 },
138- search_execute_params . SearchExecuteParams ,
139+ search_documents_params . SearchDocumentsParams ,
139140 ),
140141 options = make_request_options (
141142 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
142143 ),
143- cast_to = SearchExecuteResponse ,
144+ cast_to = SearchDocumentsResponse ,
145+ )
146+
147+ def memories (
148+ self ,
149+ * ,
150+ q : str ,
151+ container_tag : str | NotGiven = NOT_GIVEN ,
152+ filters : search_memories_params .Filters | NotGiven = NOT_GIVEN ,
153+ include : search_memories_params .Include | NotGiven = NOT_GIVEN ,
154+ limit : int | NotGiven = NOT_GIVEN ,
155+ rerank : bool | NotGiven = NOT_GIVEN ,
156+ rewrite_query : bool | NotGiven = NOT_GIVEN ,
157+ threshold : float | NotGiven = NOT_GIVEN ,
158+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
159+ # The extra values given here take precedence over values defined on the client or passed to this method.
160+ extra_headers : Headers | None = None ,
161+ extra_query : Query | None = None ,
162+ extra_body : Body | None = None ,
163+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
164+ ) -> SearchMemoriesResponse :
165+ """
166+ Search memory entries - Low latency for conversational
167+
168+ Args:
169+ q: Search query string
170+
171+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
172+ user, a project ID, or any other identifier you wish to use to filter memories.
173+
174+ filters: Optional filters to apply to the search
175+
176+ limit: Maximum number of results to return
177+
178+ rerank: If true, rerank the results based on the query. This is helpful if you want to
179+ ensure the most relevant results are returned.
180+
181+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
182+ the latency by about 400ms
183+
184+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
185+ most memories, more results), 1 is most sensitive (returns lesser memories,
186+ accurate results)
187+
188+ extra_headers: Send extra headers
189+
190+ extra_query: Add additional query parameters to the request
191+
192+ extra_body: Add additional JSON properties to the request
193+
194+ timeout: Override the client-level default timeout for this request, in seconds
195+ """
196+ return self ._post (
197+ "/v4/search" ,
198+ body = maybe_transform (
199+ {
200+ "q" : q ,
201+ "container_tag" : container_tag ,
202+ "filters" : filters ,
203+ "include" : include ,
204+ "limit" : limit ,
205+ "rerank" : rerank ,
206+ "rewrite_query" : rewrite_query ,
207+ "threshold" : threshold ,
208+ },
209+ search_memories_params .SearchMemoriesParams ,
210+ ),
211+ options = make_request_options (
212+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
213+ ),
214+ cast_to = SearchMemoriesResponse ,
144215 )
145216
146217
@@ -164,7 +235,7 @@ def with_streaming_response(self) -> AsyncSearchResourceWithStreamingResponse:
164235 """
165236 return AsyncSearchResourceWithStreamingResponse (self )
166237
167- async def execute (
238+ async def documents (
168239 self ,
169240 * ,
170241 q : str ,
@@ -173,7 +244,7 @@ async def execute(
173244 container_tags : List [str ] | NotGiven = NOT_GIVEN ,
174245 doc_id : str | NotGiven = NOT_GIVEN ,
175246 document_threshold : float | NotGiven = NOT_GIVEN ,
176- filters : search_execute_params .Filters | NotGiven = NOT_GIVEN ,
247+ filters : search_documents_params .Filters | NotGiven = NOT_GIVEN ,
177248 include_full_docs : bool | NotGiven = NOT_GIVEN ,
178249 include_summary : bool | NotGiven = NOT_GIVEN ,
179250 limit : int | NotGiven = NOT_GIVEN ,
@@ -186,7 +257,7 @@ async def execute(
186257 extra_query : Query | None = None ,
187258 extra_body : Body | None = None ,
188259 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
189- ) -> SearchExecuteResponse :
260+ ) -> SearchDocumentsResponse :
190261 """
191262 Search memories with advanced filtering
192263
@@ -255,46 +326,128 @@ async def execute(
255326 "rerank" : rerank ,
256327 "rewrite_query" : rewrite_query ,
257328 },
258- search_execute_params .SearchExecuteParams ,
329+ search_documents_params .SearchDocumentsParams ,
330+ ),
331+ options = make_request_options (
332+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
333+ ),
334+ cast_to = SearchDocumentsResponse ,
335+ )
336+
337+ async def memories (
338+ self ,
339+ * ,
340+ q : str ,
341+ container_tag : str | NotGiven = NOT_GIVEN ,
342+ filters : search_memories_params .Filters | NotGiven = NOT_GIVEN ,
343+ include : search_memories_params .Include | NotGiven = NOT_GIVEN ,
344+ limit : int | NotGiven = NOT_GIVEN ,
345+ rerank : bool | NotGiven = NOT_GIVEN ,
346+ rewrite_query : bool | NotGiven = NOT_GIVEN ,
347+ threshold : float | NotGiven = NOT_GIVEN ,
348+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
349+ # The extra values given here take precedence over values defined on the client or passed to this method.
350+ extra_headers : Headers | None = None ,
351+ extra_query : Query | None = None ,
352+ extra_body : Body | None = None ,
353+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
354+ ) -> SearchMemoriesResponse :
355+ """
356+ Search memory entries - Low latency for conversational
357+
358+ Args:
359+ q: Search query string
360+
361+ container_tag: Optional tag this search should be containerized by. This can be an ID for your
362+ user, a project ID, or any other identifier you wish to use to filter memories.
363+
364+ filters: Optional filters to apply to the search
365+
366+ limit: Maximum number of results to return
367+
368+ rerank: If true, rerank the results based on the query. This is helpful if you want to
369+ ensure the most relevant results are returned.
370+
371+ rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
372+ the latency by about 400ms
373+
374+ threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
375+ most memories, more results), 1 is most sensitive (returns lesser memories,
376+ accurate results)
377+
378+ extra_headers: Send extra headers
379+
380+ extra_query: Add additional query parameters to the request
381+
382+ extra_body: Add additional JSON properties to the request
383+
384+ timeout: Override the client-level default timeout for this request, in seconds
385+ """
386+ return await self ._post (
387+ "/v4/search" ,
388+ body = await async_maybe_transform (
389+ {
390+ "q" : q ,
391+ "container_tag" : container_tag ,
392+ "filters" : filters ,
393+ "include" : include ,
394+ "limit" : limit ,
395+ "rerank" : rerank ,
396+ "rewrite_query" : rewrite_query ,
397+ "threshold" : threshold ,
398+ },
399+ search_memories_params .SearchMemoriesParams ,
259400 ),
260401 options = make_request_options (
261402 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
262403 ),
263- cast_to = SearchExecuteResponse ,
404+ cast_to = SearchMemoriesResponse ,
264405 )
265406
266407
267408class SearchResourceWithRawResponse :
268409 def __init__ (self , search : SearchResource ) -> None :
269410 self ._search = search
270411
271- self .execute = to_raw_response_wrapper (
272- search .execute ,
412+ self .documents = to_raw_response_wrapper (
413+ search .documents ,
414+ )
415+ self .memories = to_raw_response_wrapper (
416+ search .memories ,
273417 )
274418
275419
276420class AsyncSearchResourceWithRawResponse :
277421 def __init__ (self , search : AsyncSearchResource ) -> None :
278422 self ._search = search
279423
280- self .execute = async_to_raw_response_wrapper (
281- search .execute ,
424+ self .documents = async_to_raw_response_wrapper (
425+ search .documents ,
426+ )
427+ self .memories = async_to_raw_response_wrapper (
428+ search .memories ,
282429 )
283430
284431
285432class SearchResourceWithStreamingResponse :
286433 def __init__ (self , search : SearchResource ) -> None :
287434 self ._search = search
288435
289- self .execute = to_streamed_response_wrapper (
290- search .execute ,
436+ self .documents = to_streamed_response_wrapper (
437+ search .documents ,
438+ )
439+ self .memories = to_streamed_response_wrapper (
440+ search .memories ,
291441 )
292442
293443
294444class AsyncSearchResourceWithStreamingResponse :
295445 def __init__ (self , search : AsyncSearchResource ) -> None :
296446 self ._search = search
297447
298- self .execute = async_to_streamed_response_wrapper (
299- search .execute ,
448+ self .documents = async_to_streamed_response_wrapper (
449+ search .documents ,
450+ )
451+ self .memories = async_to_streamed_response_wrapper (
452+ search .memories ,
300453 )
0 commit comments