Skip to content

Commit af34c01

Browse files
feat(api): manual updates
1 parent 637811c commit af34c01

File tree

10 files changed

+421
-48
lines changed

10 files changed

+421
-48
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-3fa2583744becce1e91ec5ad18f45d2cf17778def3a8f70537a15b08c746c2fb.yml
3-
openapi_spec_hash: bf3c5827e7ddb8b32435aeb671fe7845
1+
configured_endpoints: 9
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-a280bf0a406a709c156d5e3fe7c8ae93ebe607d937af8d725d0a2997cab07a7d.yml
3+
openapi_spec_hash: 15c602571db9cbcce4703c929b994d82
44
config_hash: b9c958a39a94966479e516e9061818be

README.md

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

34-
memories = client.memories.list(
35-
"id",
34+
memory = client.memories.update(
35+
path_id="id",
36+
body_id="acxV5LHMEsG2hMSNb4umbn",
37+
content="This is a detailed article about machine learning concepts...",
3638
)
37-
print(memories.success)
39+
print(memory.id)
3840
```
3941

4042
While you can provide an `api_key` keyword argument,
@@ -57,10 +59,12 @@ client = AsyncSupermemory(
5759

5860

5961
async def main() -> None:
60-
memories = await client.memories.list(
61-
"id",
62+
memory = await client.memories.update(
63+
path_id="id",
64+
body_id="acxV5LHMEsG2hMSNb4umbn",
65+
content="This is a detailed article about machine learning concepts...",
6266
)
63-
print(memories.success)
67+
print(memory.id)
6468

6569

6670
asyncio.run(main())
@@ -93,8 +97,10 @@ from supermemory import Supermemory
9397
client = Supermemory()
9498

9599
try:
96-
client.memories.list(
97-
"id",
100+
client.memories.update(
101+
path_id="id",
102+
body_id="acxV5LHMEsG2hMSNb4umbn",
103+
content="This is a detailed article about machine learning concepts...",
98104
)
99105
except supermemory.APIConnectionError as e:
100106
print("The server could not be reached")
@@ -138,8 +144,10 @@ client = Supermemory(
138144
)
139145

140146
# Or, configure per-request:
141-
client.with_options(max_retries=5).memories.list(
142-
"id",
147+
client.with_options(max_retries=5).memories.update(
148+
path_id="id",
149+
body_id="acxV5LHMEsG2hMSNb4umbn",
150+
content="This is a detailed article about machine learning concepts...",
143151
)
144152
```
145153

@@ -163,8 +171,10 @@ client = Supermemory(
163171
)
164172

165173
# Override per-request:
166-
client.with_options(timeout=5.0).memories.list(
167-
"id",
174+
client.with_options(timeout=5.0).memories.update(
175+
path_id="id",
176+
body_id="acxV5LHMEsG2hMSNb4umbn",
177+
content="This is a detailed article about machine learning concepts...",
168178
)
169179
```
170180

@@ -206,13 +216,15 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
206216
from supermemory import Supermemory
207217

208218
client = Supermemory()
209-
response = client.memories.with_raw_response.list(
210-
"id",
219+
response = client.memories.with_raw_response.update(
220+
path_id="id",
221+
body_id="acxV5LHMEsG2hMSNb4umbn",
222+
content="This is a detailed article about machine learning concepts...",
211223
)
212224
print(response.headers.get('X-My-Header'))
213225

214-
memory = response.parse() # get the object that `memories.list()` would have returned
215-
print(memory.success)
226+
memory = response.parse() # get the object that `memories.update()` would have returned
227+
print(memory.id)
216228
```
217229

218230
These methods return an [`APIResponse`](https://github.com/supermemoryai/python-sdk/tree/main/src/supermemory/_response.py) object.
@@ -226,8 +238,10 @@ The above interface eagerly reads the full response body when you make the reque
226238
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
227239

228240
```python
229-
with client.memories.with_streaming_response.list(
230-
"id",
241+
with client.memories.with_streaming_response.update(
242+
path_id="id",
243+
body_id="acxV5LHMEsG2hMSNb4umbn",
244+
content="This is a detailed article about machine learning concepts...",
231245
) as response:
232246
print(response.headers.get("X-My-Header"))
233247

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Types:
44

55
```python
66
from supermemory.types import (
7+
MemoryUpdateResponse,
78
MemoryListResponse,
89
MemoryDeleteResponse,
910
MemoryAddResponse,
@@ -13,6 +14,7 @@ from supermemory.types import (
1314

1415
Methods:
1516

17+
- <code title="patch /v3/memories/{id}">client.memories.<a href="./src/supermemory/resources/memories.py">update</a>(path_id, \*\*<a href="src/supermemory/types/memory_update_params.py">params</a>) -> <a href="./src/supermemory/types/memory_update_response.py">MemoryUpdateResponse</a></code>
1618
- <code title="delete /v3/memories/{id}">client.memories.<a href="./src/supermemory/resources/memories.py">list</a>(id) -> <a href="./src/supermemory/types/memory_list_response.py">MemoryListResponse</a></code>
1719
- <code title="get /v3/memories/{id}">client.memories.<a href="./src/supermemory/resources/memories.py">delete</a>(id) -> <a href="./src/supermemory/types/memory_delete_response.py">MemoryDeleteResponse</a></code>
1820
- <code title="post /v3/memories">client.memories.<a href="./src/supermemory/resources/memories.py">add</a>(\*\*<a href="src/supermemory/types/memory_add_params.py">params</a>) -> <a href="./src/supermemory/types/memory_add_response.py">MemoryAddResponse</a></code>

src/supermemory/resources/memories.py

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import httpx
88

9-
from ..types import memory_add_params
9+
from ..types import memory_add_params, memory_update_params
1010
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1111
from .._utils import maybe_transform, async_maybe_transform
1212
from .._compat import cached_property
@@ -22,6 +22,7 @@
2222
from ..types.memory_get_response import MemoryGetResponse
2323
from ..types.memory_list_response import MemoryListResponse
2424
from ..types.memory_delete_response import MemoryDeleteResponse
25+
from ..types.memory_update_response import MemoryUpdateResponse
2526

2627
__all__ = ["MemoriesResource", "AsyncMemoriesResource"]
2728

@@ -46,6 +47,52 @@ def with_streaming_response(self) -> MemoriesResourceWithStreamingResponse:
4647
"""
4748
return MemoriesResourceWithStreamingResponse(self)
4849

50+
def update(
51+
self,
52+
path_id: str,
53+
*,
54+
body_id: str,
55+
content: str,
56+
container_tags: List[str] | NotGiven = NOT_GIVEN,
57+
metadata: Dict[str, Union[str, float, bool]] | NotGiven = NOT_GIVEN,
58+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
59+
# The extra values given here take precedence over values defined on the client or passed to this method.
60+
extra_headers: Headers | None = None,
61+
extra_query: Query | None = None,
62+
extra_body: Body | None = None,
63+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
64+
) -> MemoryUpdateResponse:
65+
"""
66+
Update a memory with any content type (text, url, file, etc.) and metadata
67+
68+
Args:
69+
extra_headers: Send extra headers
70+
71+
extra_query: Add additional query parameters to the request
72+
73+
extra_body: Add additional JSON properties to the request
74+
75+
timeout: Override the client-level default timeout for this request, in seconds
76+
"""
77+
if not path_id:
78+
raise ValueError(f"Expected a non-empty value for `path_id` but received {path_id!r}")
79+
return self._patch(
80+
f"/v3/memories/{path_id}",
81+
body=maybe_transform(
82+
{
83+
"body_id": body_id,
84+
"content": content,
85+
"container_tags": container_tags,
86+
"metadata": metadata,
87+
},
88+
memory_update_params.MemoryUpdateParams,
89+
),
90+
options=make_request_options(
91+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
92+
),
93+
cast_to=MemoryUpdateResponse,
94+
)
95+
4996
def list(
5097
self,
5198
id: str,
@@ -207,6 +254,52 @@ def with_streaming_response(self) -> AsyncMemoriesResourceWithStreamingResponse:
207254
"""
208255
return AsyncMemoriesResourceWithStreamingResponse(self)
209256

257+
async def update(
258+
self,
259+
path_id: str,
260+
*,
261+
body_id: str,
262+
content: str,
263+
container_tags: List[str] | NotGiven = NOT_GIVEN,
264+
metadata: Dict[str, Union[str, float, bool]] | NotGiven = NOT_GIVEN,
265+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
266+
# The extra values given here take precedence over values defined on the client or passed to this method.
267+
extra_headers: Headers | None = None,
268+
extra_query: Query | None = None,
269+
extra_body: Body | None = None,
270+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
271+
) -> MemoryUpdateResponse:
272+
"""
273+
Update a memory with any content type (text, url, file, etc.) and metadata
274+
275+
Args:
276+
extra_headers: Send extra headers
277+
278+
extra_query: Add additional query parameters to the request
279+
280+
extra_body: Add additional JSON properties to the request
281+
282+
timeout: Override the client-level default timeout for this request, in seconds
283+
"""
284+
if not path_id:
285+
raise ValueError(f"Expected a non-empty value for `path_id` but received {path_id!r}")
286+
return await self._patch(
287+
f"/v3/memories/{path_id}",
288+
body=await async_maybe_transform(
289+
{
290+
"body_id": body_id,
291+
"content": content,
292+
"container_tags": container_tags,
293+
"metadata": metadata,
294+
},
295+
memory_update_params.MemoryUpdateParams,
296+
),
297+
options=make_request_options(
298+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
299+
),
300+
cast_to=MemoryUpdateResponse,
301+
)
302+
210303
async def list(
211304
self,
212305
id: str,
@@ -352,6 +445,9 @@ class MemoriesResourceWithRawResponse:
352445
def __init__(self, memories: MemoriesResource) -> None:
353446
self._memories = memories
354447

448+
self.update = to_raw_response_wrapper(
449+
memories.update,
450+
)
355451
self.list = to_raw_response_wrapper(
356452
memories.list,
357453
)
@@ -370,6 +466,9 @@ class AsyncMemoriesResourceWithRawResponse:
370466
def __init__(self, memories: AsyncMemoriesResource) -> None:
371467
self._memories = memories
372468

469+
self.update = async_to_raw_response_wrapper(
470+
memories.update,
471+
)
373472
self.list = async_to_raw_response_wrapper(
374473
memories.list,
375474
)
@@ -388,6 +487,9 @@ class MemoriesResourceWithStreamingResponse:
388487
def __init__(self, memories: MemoriesResource) -> None:
389488
self._memories = memories
390489

490+
self.update = to_streamed_response_wrapper(
491+
memories.update,
492+
)
391493
self.list = to_streamed_response_wrapper(
392494
memories.list,
393495
)
@@ -406,6 +508,9 @@ class AsyncMemoriesResourceWithStreamingResponse:
406508
def __init__(self, memories: AsyncMemoriesResource) -> None:
407509
self._memories = memories
408510

511+
self.update = async_to_streamed_response_wrapper(
512+
memories.update,
513+
)
409514
self.list = async_to_streamed_response_wrapper(
410515
memories.list,
411516
)

src/supermemory/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
from .memory_add_response import MemoryAddResponse as MemoryAddResponse
77
from .memory_get_response import MemoryGetResponse as MemoryGetResponse
88
from .memory_list_response import MemoryListResponse as MemoryListResponse
9+
from .memory_update_params import MemoryUpdateParams as MemoryUpdateParams
910
from .setting_get_response import SettingGetResponse as SettingGetResponse
1011
from .setting_update_params import SettingUpdateParams as SettingUpdateParams
1112
from .memory_delete_response import MemoryDeleteResponse as MemoryDeleteResponse
13+
from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
1214
from .connection_get_response import ConnectionGetResponse as ConnectionGetResponse
1315
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
1416
from .connection_list_response import ConnectionListResponse as ConnectionListResponse

src/supermemory/types/connection_create_response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
class ConnectionCreateResponse(BaseModel):
11-
expires_in: str = FieldInfo(alias="expiresIn")
11+
id: str
12+
13+
auth_link: str = FieldInfo(alias="authLink")
1214

13-
magic_link: str = FieldInfo(alias="magicLink")
15+
expires_in: str = FieldInfo(alias="expiresIn")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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
6+
from typing_extensions import Required, Annotated, TypedDict
7+
8+
from .._utils import PropertyInfo
9+
10+
__all__ = ["MemoryUpdateParams"]
11+
12+
13+
class MemoryUpdateParams(TypedDict, total=False):
14+
body_id: Required[Annotated[str, PropertyInfo(alias="id")]]
15+
16+
content: Required[str]
17+
18+
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
19+
20+
metadata: Dict[str, Union[str, float, bool]]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .._models import BaseModel
4+
5+
__all__ = ["MemoryUpdateResponse"]
6+
7+
8+
class MemoryUpdateResponse(BaseModel):
9+
id: str
10+
11+
status: str

0 commit comments

Comments
 (0)