Skip to content

Commit 9e373ef

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

File tree

10 files changed

+558
-58
lines changed

10 files changed

+558
-58
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 17
1+
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: 38ef57207cda6bd69b47a02098e2fdb0
4+
config_hash: f305e457fd9ddd1dec2614b14d7936a5

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ client = Supermemory(
3232
api_key=os.environ.get("SUPERMEMORY_API_KEY"), # This is the default and can be omitted
3333
)
3434

35-
response = client.search.execute(
35+
response = client.search.documents(
3636
q="documents related to python",
3737
)
3838
print(response.results)
@@ -58,7 +58,7 @@ client = AsyncSupermemory(
5858

5959

6060
async def main() -> None:
61-
response = await client.search.execute(
61+
response = await client.search.documents(
6262
q="documents related to python",
6363
)
6464
print(response.results)
@@ -93,7 +93,7 @@ async def main() -> None:
9393
api_key="My API Key",
9494
http_client=DefaultAioHttpClient(),
9595
) as client:
96-
response = await client.search.execute(
96+
response = await client.search.documents(
9797
q="documents related to python",
9898
)
9999
print(response.results)
@@ -111,6 +111,22 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
111111

112112
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
113113

114+
## Nested params
115+
116+
Nested parameters are dictionaries, typed using `TypedDict`, for example:
117+
118+
```python
119+
from supermemory import Supermemory
120+
121+
client = Supermemory()
122+
123+
response = client.search.memories(
124+
q="machine learning concepts",
125+
include={},
126+
)
127+
print(response.include)
128+
```
129+
114130
## File uploads
115131

116132
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.

api.md

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

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

3232
Methods:
3333

34-
- <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>
34+
- <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 /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>
3536

3637
# Settings
3738

src/supermemory/resources/search.py

Lines changed: 173 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import search_execute_params
10+
from ..types import 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,7 +19,8 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from .._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

267408
class 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

276420
class 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

285432
class 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

294444
class 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
)

src/supermemory/types/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
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
1312
from .setting_update_params import SettingUpdateParams as SettingUpdateParams
1413
from .connection_list_params import ConnectionListParams as ConnectionListParams
1514
from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
16-
from .search_execute_response import SearchExecuteResponse as SearchExecuteResponse
15+
from .search_memories_params import SearchMemoriesParams as SearchMemoriesParams
16+
from .search_documents_params import SearchDocumentsParams as SearchDocumentsParams
1717
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
1818
from .connection_create_params import ConnectionCreateParams as ConnectionCreateParams
1919
from .connection_import_params import ConnectionImportParams as ConnectionImportParams
2020
from .connection_list_response import ConnectionListResponse as ConnectionListResponse
21+
from .search_memories_response import SearchMemoriesResponse as SearchMemoriesResponse
2122
from .memory_upload_file_params import MemoryUploadFileParams as MemoryUploadFileParams
23+
from .search_documents_response import SearchDocumentsResponse as SearchDocumentsResponse
2224
from .connection_create_response import ConnectionCreateResponse as ConnectionCreateResponse
2325
from .memory_upload_file_response import MemoryUploadFileResponse as MemoryUploadFileResponse
2426
from .connection_get_by_id_response import ConnectionGetByIDResponse as ConnectionGetByIDResponse

0 commit comments

Comments
 (0)