Skip to content

Commit a1c62df

Browse files
feat(api): api update
1 parent de31fa6 commit a1c62df

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-eef92a68d48cbd0da30cae650e608f5114a52305f81c4deea56ef42e4a0ec05b.yml
3-
openapi_spec_hash: 5b9e4ea9387648b156fdcfea9651ff58
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-99fe2a928c370e4958b4402331420035181618e4d0203cbf5048d197923e583e.yml
3+
openapi_spec_hash: 44279226783fee110b5fee1017d8edec
44
config_hash: a69d5c502ffbfb11a2c8ec61ca5823e9

src/supermemory/resources/search.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
from typing_extensions import Literal
6+
57
import httpx
68

79
from ..types import search_execute_params, search_memories_params, search_documents_params
@@ -249,6 +251,7 @@ def memories(
249251
limit: int | Omit = omit,
250252
rerank: bool | Omit = omit,
251253
rewrite_query: bool | Omit = omit,
254+
search_mode: Literal["memories", "hybrid"] | Omit = omit,
252255
threshold: float | Omit = omit,
253256
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
254257
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -276,6 +279,10 @@ def memories(
276279
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
277280
the latency by about 400ms
278281
282+
search_mode: Search mode. 'memories' searches only memory entries (default). 'hybrid'
283+
searches memories first, then falls back to document chunks if no memories are
284+
found.
285+
279286
threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
280287
most memories, more results), 1 is most sensitive (returns lesser memories,
281288
accurate results)
@@ -299,6 +306,7 @@ def memories(
299306
"limit": limit,
300307
"rerank": rerank,
301308
"rewrite_query": rewrite_query,
309+
"search_mode": search_mode,
302310
"threshold": threshold,
303311
},
304312
search_memories_params.SearchMemoriesParams,
@@ -536,6 +544,7 @@ async def memories(
536544
limit: int | Omit = omit,
537545
rerank: bool | Omit = omit,
538546
rewrite_query: bool | Omit = omit,
547+
search_mode: Literal["memories", "hybrid"] | Omit = omit,
539548
threshold: float | Omit = omit,
540549
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
541550
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -563,6 +572,10 @@ async def memories(
563572
rewrite_query: If true, rewrites the query to make it easier to find documents. This increases
564573
the latency by about 400ms
565574
575+
search_mode: Search mode. 'memories' searches only memory entries (default). 'hybrid'
576+
searches memories first, then falls back to document chunks if no memories are
577+
found.
578+
566579
threshold: Threshold / sensitivity for memories selection. 0 is least sensitive (returns
567580
most memories, more results), 1 is most sensitive (returns lesser memories,
568581
accurate results)
@@ -586,6 +599,7 @@ async def memories(
586599
"limit": limit,
587600
"rerank": rerank,
588601
"rewrite_query": rewrite_query,
602+
"search_mode": search_mode,
589603
"threshold": threshold,
590604
},
591605
search_memories_params.SearchMemoriesParams,

src/supermemory/types/search_memories_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ class SearchMemoriesParams(TypedDict, total=False):
359359
This increases the latency by about 400ms
360360
"""
361361

362+
search_mode: Annotated[Literal["memories", "hybrid"], PropertyInfo(alias="searchMode")]
363+
"""Search mode.
364+
365+
'memories' searches only memory entries (default). 'hybrid' searches memories
366+
first, then falls back to document chunks if no memories are found.
367+
"""
368+
362369
threshold: float
363370
"""Threshold / sensitivity for memories selection.
364371

src/supermemory/types/search_memories_response.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ class ResultDocument(BaseModel):
105105

106106
class Result(BaseModel):
107107
id: str
108-
"""Memory entry ID"""
109-
110-
memory: str
111-
"""The memory content"""
108+
"""Memory entry ID or chunk ID"""
112109

113110
metadata: Optional[Dict[str, object]] = None
114111
"""Memory metadata"""
@@ -119,6 +116,9 @@ class Result(BaseModel):
119116
updated_at: str = FieldInfo(alias="updatedAt")
120117
"""Memory last update date"""
121118

119+
chunk: Optional[str] = None
120+
"""The chunk content (only present for chunk results from hybrid search)"""
121+
122122
chunks: Optional[List[ResultChunk]] = None
123123
"""Relevant chunks from associated documents (only included when chunks=true)"""
124124

@@ -128,13 +128,21 @@ class Result(BaseModel):
128128
documents: Optional[List[ResultDocument]] = None
129129
"""Associated documents for this memory entry"""
130130

131+
memory: Optional[str] = None
132+
"""The memory content (only present for memory results)"""
133+
131134
version: Optional[float] = None
132135
"""Version number of this memory entry"""
133136

134137

135138
class SearchMemoriesResponse(BaseModel):
136139
results: List[Result]
137-
"""Array of matching memory entries with similarity scores"""
140+
"""Array of matching memory entries and chunks with similarity scores.
141+
142+
Contains memory results when searchMode='memories', or both memory and chunk
143+
results when searchMode='hybrid'. Memory results have 'memory' field, chunk
144+
results have 'chunk' field.
145+
"""
138146

139147
timing: float
140148
"""Search execution time in milliseconds"""

tests/api_resources/test_search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def test_method_memories_with_all_params(self, client: Supermemory) -> None:
187187
limit=10,
188188
rerank=False,
189189
rewrite_query=False,
190+
search_mode="memories",
190191
threshold=0.5,
191192
)
192193
assert_matches_type(SearchMemoriesResponse, search, path=["response"])
@@ -389,6 +390,7 @@ async def test_method_memories_with_all_params(self, async_client: AsyncSupermem
389390
limit=10,
390391
rerank=False,
391392
rewrite_query=False,
393+
search_mode="memories",
392394
threshold=0.5,
393395
)
394396
assert_matches_type(SearchMemoriesResponse, search, path=["response"])

0 commit comments

Comments
 (0)