Skip to content

Commit c2623b2

Browse files
feat(api): manual updates
1 parent 9e373ef commit c2623b2

File tree

7 files changed

+512
-3
lines changed

7 files changed

+512
-3
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 18
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-d52acd1a525b4bfe9f4befcc3a645f5d1289d75e7bad999cf1330e539b2ed84e.yml
33
openapi_spec_hash: c34df5406cfa4d245812d30f99d28116
4-
config_hash: f305e457fd9ddd1dec2614b14d7936a5
4+
config_hash: 9b9291a6c872b063900a46386729ba3c

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ Methods:
2626
Types:
2727

2828
```python
29-
from supermemory.types import SearchDocumentsResponse, SearchMemoriesResponse
29+
from supermemory.types import SearchDocumentsResponse, SearchExecuteResponse, SearchMemoriesResponse
3030
```
3131

3232
Methods:
3333

3434
- <code title="post /v3/search">client.search.<a href="./src/supermemory/resources/search.py">documents</a>(\*\*<a href="src/supermemory/types/search_documents_params.py">params</a>) -> <a href="./src/supermemory/types/search_documents_response.py">SearchDocumentsResponse</a></code>
35+
- <code title="post /v3/search">client.search.<a href="./src/supermemory/resources/search.py">execute</a>(\*\*<a href="src/supermemory/types/search_execute_params.py">params</a>) -> <a href="./src/supermemory/types/search_execute_response.py">SearchExecuteResponse</a></code>
3536
- <code title="post /v4/search">client.search.<a href="./src/supermemory/resources/search.py">memories</a>(\*\*<a href="src/supermemory/types/search_memories_params.py">params</a>) -> <a href="./src/supermemory/types/search_memories_response.py">SearchMemoriesResponse</a></code>
3637

3738
# Settings

src/supermemory/resources/search.py

Lines changed: 212 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import search_memories_params, search_documents_params
10+
from ..types import search_execute_params, search_memories_params, search_documents_params
1111
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1212
from .._utils import maybe_transform, async_maybe_transform
1313
from .._compat import cached_property
@@ -19,6 +19,7 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from .._base_client import make_request_options
22+
from ..types.search_execute_response import SearchExecuteResponse
2223
from ..types.search_memories_response import SearchMemoriesResponse
2324
from ..types.search_documents_response import SearchDocumentsResponse
2425

@@ -144,6 +145,105 @@ def documents(
144145
cast_to=SearchDocumentsResponse,
145146
)
146147

148+
def execute(
149+
self,
150+
*,
151+
q: str,
152+
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
153+
chunk_threshold: float | NotGiven = NOT_GIVEN,
154+
container_tags: List[str] | NotGiven = NOT_GIVEN,
155+
doc_id: str | NotGiven = NOT_GIVEN,
156+
document_threshold: float | NotGiven = NOT_GIVEN,
157+
filters: search_execute_params.Filters | NotGiven = NOT_GIVEN,
158+
include_full_docs: bool | NotGiven = NOT_GIVEN,
159+
include_summary: bool | NotGiven = NOT_GIVEN,
160+
limit: int | NotGiven = NOT_GIVEN,
161+
only_matching_chunks: bool | NotGiven = NOT_GIVEN,
162+
rerank: bool | NotGiven = NOT_GIVEN,
163+
rewrite_query: bool | NotGiven = NOT_GIVEN,
164+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
165+
# The extra values given here take precedence over values defined on the client or passed to this method.
166+
extra_headers: Headers | None = None,
167+
extra_query: Query | None = None,
168+
extra_body: Body | None = None,
169+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
170+
) -> SearchExecuteResponse:
171+
"""
172+
Search memories with advanced filtering
173+
174+
Args:
175+
q: Search query string
176+
177+
categories_filter: Optional category filters
178+
179+
chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
180+
chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
181+
results)
182+
183+
container_tags: Optional tags this search should be containerized by. This can be an ID for your
184+
user, a project ID, or any other identifier you wish to use to filter memories.
185+
186+
doc_id: Optional document ID to search within. You can use this to find chunks in a very
187+
large document.
188+
189+
document_threshold: Threshold / sensitivity for document selection. 0 is least sensitive (returns
190+
most documents, more results), 1 is most sensitive (returns lesser documents,
191+
accurate results)
192+
193+
filters: Optional filters to apply to the search
194+
195+
include_full_docs: If true, include full document in the response. This is helpful if you want a
196+
chatbot to know the full context of the document.
197+
198+
include_summary: If true, include document summary in the response. This is helpful if you want a
199+
chatbot to know the full context of the document.
200+
201+
limit: Maximum number of results to return
202+
203+
only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
204+
previous and next chunk to provide more context for LLMs. If you only want the
205+
matching chunk, set this to true.
206+
207+
rerank: If true, rerank the results based on the query. This is helpful if you want to
208+
ensure the most relevant results are returned.
209+
210+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
211+
the latency by about 400ms
212+
213+
extra_headers: Send extra headers
214+
215+
extra_query: Add additional query parameters to the request
216+
217+
extra_body: Add additional JSON properties to the request
218+
219+
timeout: Override the client-level default timeout for this request, in seconds
220+
"""
221+
return self._post(
222+
"/v3/search",
223+
body=maybe_transform(
224+
{
225+
"q": q,
226+
"categories_filter": categories_filter,
227+
"chunk_threshold": chunk_threshold,
228+
"container_tags": container_tags,
229+
"doc_id": doc_id,
230+
"document_threshold": document_threshold,
231+
"filters": filters,
232+
"include_full_docs": include_full_docs,
233+
"include_summary": include_summary,
234+
"limit": limit,
235+
"only_matching_chunks": only_matching_chunks,
236+
"rerank": rerank,
237+
"rewrite_query": rewrite_query,
238+
},
239+
search_execute_params.SearchExecuteParams,
240+
),
241+
options=make_request_options(
242+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
243+
),
244+
cast_to=SearchExecuteResponse,
245+
)
246+
147247
def memories(
148248
self,
149249
*,
@@ -334,6 +434,105 @@ async def documents(
334434
cast_to=SearchDocumentsResponse,
335435
)
336436

437+
async def execute(
438+
self,
439+
*,
440+
q: str,
441+
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
442+
chunk_threshold: float | NotGiven = NOT_GIVEN,
443+
container_tags: List[str] | NotGiven = NOT_GIVEN,
444+
doc_id: str | NotGiven = NOT_GIVEN,
445+
document_threshold: float | NotGiven = NOT_GIVEN,
446+
filters: search_execute_params.Filters | NotGiven = NOT_GIVEN,
447+
include_full_docs: bool | NotGiven = NOT_GIVEN,
448+
include_summary: bool | NotGiven = NOT_GIVEN,
449+
limit: int | NotGiven = NOT_GIVEN,
450+
only_matching_chunks: bool | NotGiven = NOT_GIVEN,
451+
rerank: bool | NotGiven = NOT_GIVEN,
452+
rewrite_query: bool | NotGiven = NOT_GIVEN,
453+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
454+
# The extra values given here take precedence over values defined on the client or passed to this method.
455+
extra_headers: Headers | None = None,
456+
extra_query: Query | None = None,
457+
extra_body: Body | None = None,
458+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
459+
) -> SearchExecuteResponse:
460+
"""
461+
Search memories with advanced filtering
462+
463+
Args:
464+
q: Search query string
465+
466+
categories_filter: Optional category filters
467+
468+
chunk_threshold: Threshold / sensitivity for chunk selection. 0 is least sensitive (returns most
469+
chunks, more results), 1 is most sensitive (returns lesser chunks, accurate
470+
results)
471+
472+
container_tags: Optional tags this search should be containerized by. This can be an ID for your
473+
user, a project ID, or any other identifier you wish to use to filter memories.
474+
475+
doc_id: Optional document ID to search within. You can use this to find chunks in a very
476+
large document.
477+
478+
document_threshold: Threshold / sensitivity for document selection. 0 is least sensitive (returns
479+
most documents, more results), 1 is most sensitive (returns lesser documents,
480+
accurate results)
481+
482+
filters: Optional filters to apply to the search
483+
484+
include_full_docs: If true, include full document in the response. This is helpful if you want a
485+
chatbot to know the full context of the document.
486+
487+
include_summary: If true, include document summary in the response. This is helpful if you want a
488+
chatbot to know the full context of the document.
489+
490+
limit: Maximum number of results to return
491+
492+
only_matching_chunks: If true, only return matching chunks without context. Normally, we send the
493+
previous and next chunk to provide more context for LLMs. If you only want the
494+
matching chunk, set this to true.
495+
496+
rerank: If true, rerank the results based on the query. This is helpful if you want to
497+
ensure the most relevant results are returned.
498+
499+
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
500+
the latency by about 400ms
501+
502+
extra_headers: Send extra headers
503+
504+
extra_query: Add additional query parameters to the request
505+
506+
extra_body: Add additional JSON properties to the request
507+
508+
timeout: Override the client-level default timeout for this request, in seconds
509+
"""
510+
return await self._post(
511+
"/v3/search",
512+
body=await async_maybe_transform(
513+
{
514+
"q": q,
515+
"categories_filter": categories_filter,
516+
"chunk_threshold": chunk_threshold,
517+
"container_tags": container_tags,
518+
"doc_id": doc_id,
519+
"document_threshold": document_threshold,
520+
"filters": filters,
521+
"include_full_docs": include_full_docs,
522+
"include_summary": include_summary,
523+
"limit": limit,
524+
"only_matching_chunks": only_matching_chunks,
525+
"rerank": rerank,
526+
"rewrite_query": rewrite_query,
527+
},
528+
search_execute_params.SearchExecuteParams,
529+
),
530+
options=make_request_options(
531+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
532+
),
533+
cast_to=SearchExecuteResponse,
534+
)
535+
337536
async def memories(
338537
self,
339538
*,
@@ -412,6 +611,9 @@ def __init__(self, search: SearchResource) -> None:
412611
self.documents = to_raw_response_wrapper(
413612
search.documents,
414613
)
614+
self.execute = to_raw_response_wrapper(
615+
search.execute,
616+
)
415617
self.memories = to_raw_response_wrapper(
416618
search.memories,
417619
)
@@ -424,6 +626,9 @@ def __init__(self, search: AsyncSearchResource) -> None:
424626
self.documents = async_to_raw_response_wrapper(
425627
search.documents,
426628
)
629+
self.execute = async_to_raw_response_wrapper(
630+
search.execute,
631+
)
427632
self.memories = async_to_raw_response_wrapper(
428633
search.memories,
429634
)
@@ -436,6 +641,9 @@ def __init__(self, search: SearchResource) -> None:
436641
self.documents = to_streamed_response_wrapper(
437642
search.documents,
438643
)
644+
self.execute = to_streamed_response_wrapper(
645+
search.execute,
646+
)
439647
self.memories = to_streamed_response_wrapper(
440648
search.memories,
441649
)
@@ -448,6 +656,9 @@ def __init__(self, search: AsyncSearchResource) -> None:
448656
self.documents = async_to_streamed_response_wrapper(
449657
search.documents,
450658
)
659+
self.execute = async_to_streamed_response_wrapper(
660+
search.execute,
661+
)
451662
self.memories = async_to_streamed_response_wrapper(
452663
search.memories,
453664
)

src/supermemory/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
from .memory_list_response import MemoryListResponse as MemoryListResponse
1010
from .memory_update_params import MemoryUpdateParams as MemoryUpdateParams
1111
from .setting_get_response import SettingGetResponse as SettingGetResponse
12+
from .search_execute_params import SearchExecuteParams as SearchExecuteParams
1213
from .setting_update_params import SettingUpdateParams as SettingUpdateParams
1314
from .connection_list_params import ConnectionListParams as ConnectionListParams
1415
from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
1516
from .search_memories_params import SearchMemoriesParams as SearchMemoriesParams
1617
from .search_documents_params import SearchDocumentsParams as SearchDocumentsParams
18+
from .search_execute_response import SearchExecuteResponse as SearchExecuteResponse
1719
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
1820
from .connection_create_params import ConnectionCreateParams as ConnectionCreateParams
1921
from .connection_import_params import ConnectionImportParams as ConnectionImportParams
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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, Iterable
6+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
7+
8+
from .._utils import PropertyInfo
9+
10+
__all__ = ["SearchExecuteParams", "Filters", "FiltersUnionMember0"]
11+
12+
13+
class SearchExecuteParams(TypedDict, total=False):
14+
q: Required[str]
15+
"""Search query string"""
16+
17+
categories_filter: Annotated[
18+
List[Literal["technology", "science", "business", "health"]], PropertyInfo(alias="categoriesFilter")
19+
]
20+
"""Optional category filters"""
21+
22+
chunk_threshold: Annotated[float, PropertyInfo(alias="chunkThreshold")]
23+
"""Threshold / sensitivity for chunk selection.
24+
25+
0 is least sensitive (returns most chunks, more results), 1 is most sensitive
26+
(returns lesser chunks, accurate results)
27+
"""
28+
29+
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
30+
"""Optional tags this search should be containerized by.
31+
32+
This can be an ID for your user, a project ID, or any other identifier you wish
33+
to use to filter memories.
34+
"""
35+
36+
doc_id: Annotated[str, PropertyInfo(alias="docId")]
37+
"""Optional document ID to search within.
38+
39+
You can use this to find chunks in a very large document.
40+
"""
41+
42+
document_threshold: Annotated[float, PropertyInfo(alias="documentThreshold")]
43+
"""Threshold / sensitivity for document selection.
44+
45+
0 is least sensitive (returns most documents, more results), 1 is most sensitive
46+
(returns lesser documents, accurate results)
47+
"""
48+
49+
filters: Filters
50+
"""Optional filters to apply to the search"""
51+
52+
include_full_docs: Annotated[bool, PropertyInfo(alias="includeFullDocs")]
53+
"""If true, include full document in the response.
54+
55+
This is helpful if you want a chatbot to know the full context of the document.
56+
"""
57+
58+
include_summary: Annotated[bool, PropertyInfo(alias="includeSummary")]
59+
"""If true, include document summary in the response.
60+
61+
This is helpful if you want a chatbot to know the full context of the document.
62+
"""
63+
64+
limit: int
65+
"""Maximum number of results to return"""
66+
67+
only_matching_chunks: Annotated[bool, PropertyInfo(alias="onlyMatchingChunks")]
68+
"""If true, only return matching chunks without context.
69+
70+
Normally, we send the previous and next chunk to provide more context for LLMs.
71+
If you only want the matching chunk, set this to true.
72+
"""
73+
74+
rerank: bool
75+
"""If true, rerank the results based on the query.
76+
77+
This is helpful if you want to ensure the most relevant results are returned.
78+
"""
79+
80+
rewrite_query: Annotated[bool, PropertyInfo(alias="rewriteQuery")]
81+
"""If true, rewrites the query to make it easier to find documents.
82+
83+
This increases the latency by about 400ms
84+
"""
85+
86+
87+
class FiltersUnionMember0(TypedDict, total=False):
88+
and_: Annotated[Iterable[object], PropertyInfo(alias="AND")]
89+
90+
or_: Annotated[Iterable[object], PropertyInfo(alias="OR")]
91+
92+
93+
Filters: TypeAlias = Union[FiltersUnionMember0, Dict[str, object]]

0 commit comments

Comments
 (0)