Skip to content

Commit ef54b87

Browse files
feat(api): api update
1 parent 846bd47 commit ef54b87

File tree

6 files changed

+93
-9
lines changed

6 files changed

+93
-9
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-8a2f638d23709e5ca31c359b3b82ac806c4f2dbb238ca28ee2afed599b3f7be3.yml
3-
openapi_spec_hash: 87a76bf487509cec077df5d5679a03de
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-e519a815da9102647222f1f73920926f2d8b63d16995d3687213b604963f5ec5.yml
3+
openapi_spec_hash: 4de453d3c2fca716f7f645d4c2c8f921
44
config_hash: f3eb5ca71172780678106f6d46f15dda

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ from supermemory import Supermemory
130130

131131
client = Supermemory()
132132

133-
response = client.search.memories(
134-
q="machine learning concepts",
135-
include={},
133+
response = client.memories.update_memory(
134+
container_tag="user_123",
135+
new_content="John now prefers light mode",
136+
temporal_context={},
136137
)
137-
print(response.include)
138+
print(response.temporal_context)
138139
```
139140

140141
## File uploads

src/supermemory/resources/memories.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, Union
5+
from typing import Dict, Union, Optional
66

77
import httpx
88

@@ -105,7 +105,10 @@ def update_memory(
105105
new_content: str,
106106
id: str | Omit = omit,
107107
content: str | Omit = omit,
108+
forget_after: Optional[str] | Omit = omit,
109+
forget_reason: Optional[str] | Omit = omit,
108110
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
111+
temporal_context: memory_update_memory_params.TemporalContext | Omit = omit,
109112
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
110113
# The extra values given here take precedence over values defined on the client or passed to this method.
111114
extra_headers: Headers | None = None,
@@ -128,8 +131,18 @@ def update_memory(
128131
content: Exact content match of the memory entry to operate on. Use this when you don't
129132
have the ID.
130133
134+
forget_after: ISO 8601 datetime string. The memory will be auto-forgotten after this time.
135+
Pass null to clear an existing expiry. Omit to inherit from the previous
136+
version.
137+
138+
forget_reason: Optional reason for the scheduled forgetting. Cleared automatically when
139+
forgetAfter is set to null.
140+
131141
metadata: Optional metadata. If not provided, inherits from the previous version.
132142
143+
temporal_context: Structured temporal metadata. Merged into the metadata JSON column. If omitted,
144+
existing temporalContext is preserved.
145+
133146
extra_headers: Send extra headers
134147
135148
extra_query: Add additional query parameters to the request
@@ -146,7 +159,10 @@ def update_memory(
146159
"new_content": new_content,
147160
"id": id,
148161
"content": content,
162+
"forget_after": forget_after,
163+
"forget_reason": forget_reason,
149164
"metadata": metadata,
165+
"temporal_context": temporal_context,
150166
},
151167
memory_update_memory_params.MemoryUpdateMemoryParams,
152168
),
@@ -238,7 +254,10 @@ async def update_memory(
238254
new_content: str,
239255
id: str | Omit = omit,
240256
content: str | Omit = omit,
257+
forget_after: Optional[str] | Omit = omit,
258+
forget_reason: Optional[str] | Omit = omit,
241259
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
260+
temporal_context: memory_update_memory_params.TemporalContext | Omit = omit,
242261
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
243262
# The extra values given here take precedence over values defined on the client or passed to this method.
244263
extra_headers: Headers | None = None,
@@ -261,8 +280,18 @@ async def update_memory(
261280
content: Exact content match of the memory entry to operate on. Use this when you don't
262281
have the ID.
263282
283+
forget_after: ISO 8601 datetime string. The memory will be auto-forgotten after this time.
284+
Pass null to clear an existing expiry. Omit to inherit from the previous
285+
version.
286+
287+
forget_reason: Optional reason for the scheduled forgetting. Cleared automatically when
288+
forgetAfter is set to null.
289+
264290
metadata: Optional metadata. If not provided, inherits from the previous version.
265291
292+
temporal_context: Structured temporal metadata. Merged into the metadata JSON column. If omitted,
293+
existing temporalContext is preserved.
294+
266295
extra_headers: Send extra headers
267296
268297
extra_query: Add additional query parameters to the request
@@ -279,7 +308,10 @@ async def update_memory(
279308
"new_content": new_content,
280309
"id": id,
281310
"content": content,
311+
"forget_after": forget_after,
312+
"forget_reason": forget_reason,
282313
"metadata": metadata,
314+
"temporal_context": temporal_context,
283315
},
284316
memory_update_memory_params.MemoryUpdateMemoryParams,
285317
),

src/supermemory/types/memory_update_memory_params.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, Union
5+
from typing import Dict, Union, Optional
66
from typing_extensions import Required, Annotated, TypedDict
77

88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
1010

11-
__all__ = ["MemoryUpdateMemoryParams"]
11+
__all__ = ["MemoryUpdateMemoryParams", "TemporalContext"]
1212

1313

1414
class MemoryUpdateMemoryParams(TypedDict, total=False):
@@ -27,5 +27,38 @@ class MemoryUpdateMemoryParams(TypedDict, total=False):
2727
Use this when you don't have the ID.
2828
"""
2929

30+
forget_after: Annotated[Optional[str], PropertyInfo(alias="forgetAfter")]
31+
"""ISO 8601 datetime string.
32+
33+
The memory will be auto-forgotten after this time. Pass null to clear an
34+
existing expiry. Omit to inherit from the previous version.
35+
"""
36+
37+
forget_reason: Annotated[Optional[str], PropertyInfo(alias="forgetReason")]
38+
"""Optional reason for the scheduled forgetting.
39+
40+
Cleared automatically when forgetAfter is set to null.
41+
"""
42+
3043
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]]
3144
"""Optional metadata. If not provided, inherits from the previous version."""
45+
46+
temporal_context: Annotated[TemporalContext, PropertyInfo(alias="temporalContext")]
47+
"""Structured temporal metadata.
48+
49+
Merged into the metadata JSON column. If omitted, existing temporalContext is
50+
preserved.
51+
"""
52+
53+
54+
class TemporalContext(TypedDict, total=False):
55+
"""Structured temporal metadata.
56+
57+
Merged into the metadata JSON column. If omitted, existing temporalContext is preserved.
58+
"""
59+
60+
document_date: Annotated[Optional[str], PropertyInfo(alias="documentDate")]
61+
"""Date the document was authored"""
62+
63+
event_date: Annotated[Optional[SequenceNotStr[str]], PropertyInfo(alias="eventDate")]
64+
"""Dates of events referenced in the memory"""

src/supermemory/types/memory_update_memory_response.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class MemoryUpdateMemoryResponse(BaseModel):
1818
created_at: str = FieldInfo(alias="createdAt")
1919
"""When this memory version was created"""
2020

21+
forget_after: Optional[str] = FieldInfo(alias="forgetAfter", default=None)
22+
"""When this memory will be auto-forgotten, or null if no expiry"""
23+
24+
forget_reason: Optional[str] = FieldInfo(alias="forgetReason", default=None)
25+
"""Reason for the scheduled forgetting, or null"""
26+
2127
memory: str
2228
"""The content of the new memory version"""
2329

tests/api_resources/test_memories.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ def test_method_update_memory_with_all_params(self, client: Supermemory) -> None
8282
new_content="John now prefers light mode",
8383
id="mem_abc123",
8484
content="John prefers dark mode",
85+
forget_after="2026-06-01T00:00:00Z",
86+
forget_reason="temporary project deadline",
8587
metadata={"foo": "string"},
88+
temporal_context={
89+
"document_date": "documentDate",
90+
"event_date": ["string"],
91+
},
8692
)
8793
assert_matches_type(MemoryUpdateMemoryResponse, memory, path=["response"])
8894

@@ -182,7 +188,13 @@ async def test_method_update_memory_with_all_params(self, async_client: AsyncSup
182188
new_content="John now prefers light mode",
183189
id="mem_abc123",
184190
content="John prefers dark mode",
191+
forget_after="2026-06-01T00:00:00Z",
192+
forget_reason="temporary project deadline",
185193
metadata={"foo": "string"},
194+
temporal_context={
195+
"document_date": "documentDate",
196+
"event_date": ["string"],
197+
},
186198
)
187199
assert_matches_type(MemoryUpdateMemoryResponse, memory, path=["response"])
188200

0 commit comments

Comments
 (0)