Skip to content

Commit 063cf45

Browse files
feat(api): api update
1 parent 7a81e80 commit 063cf45

File tree

8 files changed

+271
-6
lines changed

8 files changed

+271
-6
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: 10
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: 11
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-7db7d7a82f3e3d16db6481789ab9d65a18481ed036db6fcc1ef993f4a3e0e255.yml
3+
openapi_spec_hash: 3a969e6bf3d693c02ba142fcd8e64dd8
44
config_hash: c8c1f2b0d63387d621f0cf066ae3379f

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>(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="get /v3/memories">client.memories.<a href="./src/supermemory/resources/memories.py">list</a>(\*\*<a href="src/supermemory/types/memory_list_params.py">params</a>) -> <a href="./src/supermemory/types/memory_list_response.py">MemoryListResponse</a></code>
1719
- <code title="delete /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: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ..types import memory_add_params, memory_list_params
10+
from ..types import memory_add_params, memory_list_params, memory_update_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
@@ -23,6 +23,7 @@
2323
from ..types.memory_get_response import MemoryGetResponse
2424
from ..types.memory_list_response import MemoryListResponse
2525
from ..types.memory_delete_response import MemoryDeleteResponse
26+
from ..types.memory_update_response import MemoryUpdateResponse
2627

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

@@ -47,6 +48,50 @@ def with_streaming_response(self) -> MemoriesResourceWithStreamingResponse:
4748
"""
4849
return MemoriesResourceWithStreamingResponse(self)
4950

51+
def update(
52+
self,
53+
id: str,
54+
*,
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 id:
78+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
79+
return self._patch(
80+
f"/v3/memories/{id}",
81+
body=maybe_transform(
82+
{
83+
"content": content,
84+
"container_tags": container_tags,
85+
"metadata": metadata,
86+
},
87+
memory_update_params.MemoryUpdateParams,
88+
),
89+
options=make_request_options(
90+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
91+
),
92+
cast_to=MemoryUpdateResponse,
93+
)
94+
5095
def list(
5196
self,
5297
*,
@@ -233,6 +278,50 @@ def with_streaming_response(self) -> AsyncMemoriesResourceWithStreamingResponse:
233278
"""
234279
return AsyncMemoriesResourceWithStreamingResponse(self)
235280

281+
async def update(
282+
self,
283+
id: str,
284+
*,
285+
content: str,
286+
container_tags: List[str] | NotGiven = NOT_GIVEN,
287+
metadata: Dict[str, Union[str, float, bool]] | NotGiven = NOT_GIVEN,
288+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
289+
# The extra values given here take precedence over values defined on the client or passed to this method.
290+
extra_headers: Headers | None = None,
291+
extra_query: Query | None = None,
292+
extra_body: Body | None = None,
293+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
294+
) -> MemoryUpdateResponse:
295+
"""
296+
Update a memory with any content type (text, url, file, etc.) and metadata
297+
298+
Args:
299+
extra_headers: Send extra headers
300+
301+
extra_query: Add additional query parameters to the request
302+
303+
extra_body: Add additional JSON properties to the request
304+
305+
timeout: Override the client-level default timeout for this request, in seconds
306+
"""
307+
if not id:
308+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
309+
return await self._patch(
310+
f"/v3/memories/{id}",
311+
body=await async_maybe_transform(
312+
{
313+
"content": content,
314+
"container_tags": container_tags,
315+
"metadata": metadata,
316+
},
317+
memory_update_params.MemoryUpdateParams,
318+
),
319+
options=make_request_options(
320+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
321+
),
322+
cast_to=MemoryUpdateResponse,
323+
)
324+
236325
async def list(
237326
self,
238327
*,
@@ -403,6 +492,9 @@ class MemoriesResourceWithRawResponse:
403492
def __init__(self, memories: MemoriesResource) -> None:
404493
self._memories = memories
405494

495+
self.update = to_raw_response_wrapper(
496+
memories.update,
497+
)
406498
self.list = to_raw_response_wrapper(
407499
memories.list,
408500
)
@@ -421,6 +513,9 @@ class AsyncMemoriesResourceWithRawResponse:
421513
def __init__(self, memories: AsyncMemoriesResource) -> None:
422514
self._memories = memories
423515

516+
self.update = async_to_raw_response_wrapper(
517+
memories.update,
518+
)
424519
self.list = async_to_raw_response_wrapper(
425520
memories.list,
426521
)
@@ -439,6 +534,9 @@ class MemoriesResourceWithStreamingResponse:
439534
def __init__(self, memories: MemoriesResource) -> None:
440535
self._memories = memories
441536

537+
self.update = to_streamed_response_wrapper(
538+
memories.update,
539+
)
442540
self.list = to_streamed_response_wrapper(
443541
memories.list,
444542
)
@@ -457,6 +555,9 @@ class AsyncMemoriesResourceWithStreamingResponse:
457555
def __init__(self, memories: AsyncMemoriesResource) -> None:
458556
self._memories = memories
459557

558+
self.update = async_to_streamed_response_wrapper(
559+
memories.update,
560+
)
460561
self.list = async_to_streamed_response_wrapper(
461562
memories.list,
462563
)

src/supermemory/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from .memory_add_response import MemoryAddResponse as MemoryAddResponse
88
from .memory_get_response import MemoryGetResponse as MemoryGetResponse
99
from .memory_list_response import MemoryListResponse as MemoryListResponse
10+
from .memory_update_params import MemoryUpdateParams as MemoryUpdateParams
1011
from .setting_get_response import SettingGetResponse as SettingGetResponse
1112
from .search_execute_params import SearchExecuteParams as SearchExecuteParams
1213
from .setting_update_params import SettingUpdateParams as SettingUpdateParams
1314
from .memory_delete_response import MemoryDeleteResponse as MemoryDeleteResponse
15+
from .memory_update_response import MemoryUpdateResponse as MemoryUpdateResponse
1416
from .connection_get_response import ConnectionGetResponse as ConnectionGetResponse
1517
from .search_execute_response import SearchExecuteResponse as SearchExecuteResponse
1618
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
content: Required[str]
15+
16+
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
17+
18+
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

tests/api_resources/test_memories.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
MemoryGetResponse,
1515
MemoryListResponse,
1616
MemoryDeleteResponse,
17+
MemoryUpdateResponse,
1718
)
1819

1920
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -22,6 +23,70 @@
2223
class TestMemories:
2324
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2425

26+
@pytest.mark.skip()
27+
@parametrize
28+
def test_method_update(self, client: Supermemory) -> None:
29+
memory = client.memories.update(
30+
id="id",
31+
content="This is a detailed article about machine learning concepts...",
32+
)
33+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
34+
35+
@pytest.mark.skip()
36+
@parametrize
37+
def test_method_update_with_all_params(self, client: Supermemory) -> None:
38+
memory = client.memories.update(
39+
id="id",
40+
content="This is a detailed article about machine learning concepts...",
41+
container_tags=["string"],
42+
metadata={
43+
"source": "web",
44+
"category": "technology",
45+
"tag_1": "ai",
46+
"tag_2": "machine-learning",
47+
"readingTime": 5,
48+
"isPublic": True,
49+
},
50+
)
51+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
52+
53+
@pytest.mark.skip()
54+
@parametrize
55+
def test_raw_response_update(self, client: Supermemory) -> None:
56+
response = client.memories.with_raw_response.update(
57+
id="id",
58+
content="This is a detailed article about machine learning concepts...",
59+
)
60+
61+
assert response.is_closed is True
62+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
63+
memory = response.parse()
64+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
65+
66+
@pytest.mark.skip()
67+
@parametrize
68+
def test_streaming_response_update(self, client: Supermemory) -> None:
69+
with client.memories.with_streaming_response.update(
70+
id="id",
71+
content="This is a detailed article about machine learning concepts...",
72+
) as response:
73+
assert not response.is_closed
74+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
75+
76+
memory = response.parse()
77+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
78+
79+
assert cast(Any, response.is_closed) is True
80+
81+
@pytest.mark.skip()
82+
@parametrize
83+
def test_path_params_update(self, client: Supermemory) -> None:
84+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
85+
client.memories.with_raw_response.update(
86+
id="",
87+
content="This is a detailed article about machine learning concepts...",
88+
)
89+
2590
@pytest.mark.skip()
2691
@parametrize
2792
def test_method_list(self, client: Supermemory) -> None:
@@ -201,6 +266,70 @@ def test_path_params_get(self, client: Supermemory) -> None:
201266
class TestAsyncMemories:
202267
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
203268

269+
@pytest.mark.skip()
270+
@parametrize
271+
async def test_method_update(self, async_client: AsyncSupermemory) -> None:
272+
memory = await async_client.memories.update(
273+
id="id",
274+
content="This is a detailed article about machine learning concepts...",
275+
)
276+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
277+
278+
@pytest.mark.skip()
279+
@parametrize
280+
async def test_method_update_with_all_params(self, async_client: AsyncSupermemory) -> None:
281+
memory = await async_client.memories.update(
282+
id="id",
283+
content="This is a detailed article about machine learning concepts...",
284+
container_tags=["string"],
285+
metadata={
286+
"source": "web",
287+
"category": "technology",
288+
"tag_1": "ai",
289+
"tag_2": "machine-learning",
290+
"readingTime": 5,
291+
"isPublic": True,
292+
},
293+
)
294+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
295+
296+
@pytest.mark.skip()
297+
@parametrize
298+
async def test_raw_response_update(self, async_client: AsyncSupermemory) -> None:
299+
response = await async_client.memories.with_raw_response.update(
300+
id="id",
301+
content="This is a detailed article about machine learning concepts...",
302+
)
303+
304+
assert response.is_closed is True
305+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
306+
memory = await response.parse()
307+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
308+
309+
@pytest.mark.skip()
310+
@parametrize
311+
async def test_streaming_response_update(self, async_client: AsyncSupermemory) -> None:
312+
async with async_client.memories.with_streaming_response.update(
313+
id="id",
314+
content="This is a detailed article about machine learning concepts...",
315+
) as response:
316+
assert not response.is_closed
317+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
318+
319+
memory = await response.parse()
320+
assert_matches_type(MemoryUpdateResponse, memory, path=["response"])
321+
322+
assert cast(Any, response.is_closed) is True
323+
324+
@pytest.mark.skip()
325+
@parametrize
326+
async def test_path_params_update(self, async_client: AsyncSupermemory) -> None:
327+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
328+
await async_client.memories.with_raw_response.update(
329+
id="",
330+
content="This is a detailed article about machine learning concepts...",
331+
)
332+
204333
@pytest.mark.skip()
205334
@parametrize
206335
async def test_method_list(self, async_client: AsyncSupermemory) -> None:

0 commit comments

Comments
 (0)