Skip to content

Commit a4f4259

Browse files
feat(api): api update
1 parent 30d8e46 commit a4f4259

File tree

6 files changed

+102
-56
lines changed

6 files changed

+102
-56
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: 18
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-a75aed7778611ef91eff34326795cda9db48400c6be805428b81aa0fcb9ab0dc.yml
3-
openapi_spec_hash: 5d82339bc5339752f83f6155ec39e7c8
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-d3db80a2ee031274f023285c4ce7fe482d76ef850eac429bdef66c18da593ed8.yml
3+
openapi_spec_hash: 467b45efb291874fa8e76e80f492ec5e
44
config_hash: 9b9291a6c872b063900a46386729ba3c

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ from supermemory import Supermemory
160160
client = Supermemory()
161161

162162
try:
163-
client.memories.add()
163+
client.memories.add(
164+
content="This is a detailed article about machine learning concepts...",
165+
)
164166
except supermemory.APIConnectionError as e:
165167
print("The server could not be reached")
166168
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -203,7 +205,9 @@ client = Supermemory(
203205
)
204206

205207
# Or, configure per-request:
206-
client.with_options(max_retries=5).memories.add()
208+
client.with_options(max_retries=5).memories.add(
209+
content="This is a detailed article about machine learning concepts...",
210+
)
207211
```
208212

209213
### Timeouts
@@ -226,7 +230,9 @@ client = Supermemory(
226230
)
227231

228232
# Override per-request:
229-
client.with_options(timeout=5.0).memories.add()
233+
client.with_options(timeout=5.0).memories.add(
234+
content="This is a detailed article about machine learning concepts...",
235+
)
230236
```
231237

232238
On timeout, an `APITimeoutError` is thrown.
@@ -267,7 +273,9 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
267273
from supermemory import Supermemory
268274

269275
client = Supermemory()
270-
response = client.memories.with_raw_response.add()
276+
response = client.memories.with_raw_response.add(
277+
content="This is a detailed article about machine learning concepts...",
278+
)
271279
print(response.headers.get('X-My-Header'))
272280

273281
memory = response.parse() # get the object that `memories.add()` would have returned
@@ -285,7 +293,9 @@ The above interface eagerly reads the full response body when you make the reque
285293
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.
286294

287295
```python
288-
with client.memories.with_streaming_response.add() as response:
296+
with client.memories.with_streaming_response.add(
297+
content="This is a detailed article about machine learning concepts...",
298+
) as response:
289299
print(response.headers.get("X-My-Header"))
290300

291301
for line in response.iter_lines():

src/supermemory/resources/memories.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ def delete(
223223
def add(
224224
self,
225225
*,
226+
content: str,
226227
container_tag: str | NotGiven = NOT_GIVEN,
227228
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
228-
content: str | NotGiven = NOT_GIVEN,
229229
custom_id: str | NotGiven = NOT_GIVEN,
230230
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
231231
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -239,13 +239,6 @@ def add(
239239
Add a memory with any content type (text, url, file, etc.) and metadata
240240
241241
Args:
242-
container_tag: Optional tag this memory should be containerized by. This can be an ID for your
243-
user, a project ID, or any other identifier you wish to use to group memories.
244-
245-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
246-
containerized by. This can be an ID for your user, a project ID, or any other
247-
identifier you wish to use to group memories.
248-
249242
content: The content to extract and process into a memory. This can be a URL to a
250243
website, a PDF, an image, or a video.
251244
@@ -255,6 +248,13 @@ def add(
255248
256249
We automatically detect the content type from the url's response format.
257250
251+
container_tag: Optional tag this memory should be containerized by. This can be an ID for your
252+
user, a project ID, or any other identifier you wish to use to group memories.
253+
254+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
255+
containerized by. This can be an ID for your user, a project ID, or any other
256+
identifier you wish to use to group memories.
257+
258258
custom_id: Optional custom ID of the memory. This could be an ID from your database that
259259
will uniquely identify this memory.
260260
@@ -276,9 +276,9 @@ def add(
276276
"/v3/memories",
277277
body=maybe_transform(
278278
{
279+
"content": content,
279280
"container_tag": container_tag,
280281
"container_tags": container_tags,
281-
"content": content,
282282
"custom_id": custom_id,
283283
"metadata": metadata,
284284
},
@@ -564,9 +564,9 @@ async def delete(
564564
async def add(
565565
self,
566566
*,
567+
content: str,
567568
container_tag: str | NotGiven = NOT_GIVEN,
568569
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
569-
content: str | NotGiven = NOT_GIVEN,
570570
custom_id: str | NotGiven = NOT_GIVEN,
571571
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
572572
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -580,13 +580,6 @@ async def add(
580580
Add a memory with any content type (text, url, file, etc.) and metadata
581581
582582
Args:
583-
container_tag: Optional tag this memory should be containerized by. This can be an ID for your
584-
user, a project ID, or any other identifier you wish to use to group memories.
585-
586-
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
587-
containerized by. This can be an ID for your user, a project ID, or any other
588-
identifier you wish to use to group memories.
589-
590583
content: The content to extract and process into a memory. This can be a URL to a
591584
website, a PDF, an image, or a video.
592585
@@ -596,6 +589,13 @@ async def add(
596589
597590
We automatically detect the content type from the url's response format.
598591
592+
container_tag: Optional tag this memory should be containerized by. This can be an ID for your
593+
user, a project ID, or any other identifier you wish to use to group memories.
594+
595+
container_tags: (DEPRECATED: Use containerTag instead) Optional tags this memory should be
596+
containerized by. This can be an ID for your user, a project ID, or any other
597+
identifier you wish to use to group memories.
598+
599599
custom_id: Optional custom ID of the memory. This could be an ID from your database that
600600
will uniquely identify this memory.
601601
@@ -617,9 +617,9 @@ async def add(
617617
"/v3/memories",
618618
body=await async_maybe_transform(
619619
{
620+
"content": content,
620621
"container_tag": container_tag,
621622
"container_tags": container_tags,
622-
"content": content,
623623
"custom_id": custom_id,
624624
"metadata": metadata,
625625
},

src/supermemory/types/memory_add_params.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Dict, Union
6-
from typing_extensions import Annotated, TypedDict
6+
from typing_extensions import Required, Annotated, TypedDict
77

88
from .._types import SequenceNotStr
99
from .._utils import PropertyInfo
@@ -12,6 +12,18 @@
1212

1313

1414
class MemoryAddParams(TypedDict, total=False):
15+
content: Required[str]
16+
"""The content to extract and process into a memory.
17+
18+
This can be a URL to a website, a PDF, an image, or a video.
19+
20+
Plaintext: Any plaintext format
21+
22+
URL: A URL to a website, PDF, image, or video
23+
24+
We automatically detect the content type from the url's response format.
25+
"""
26+
1527
container_tag: Annotated[str, PropertyInfo(alias="containerTag")]
1628
"""Optional tag this memory should be containerized by.
1729
@@ -26,18 +38,6 @@ class MemoryAddParams(TypedDict, total=False):
2638
identifier you wish to use to group memories.
2739
"""
2840

29-
content: str
30-
"""The content to extract and process into a memory.
31-
32-
This can be a URL to a website, a PDF, an image, or a video.
33-
34-
Plaintext: Any plaintext format
35-
36-
URL: A URL to a website, PDF, image, or video
37-
38-
We automatically detect the content type from the url's response format.
39-
"""
40-
4141
custom_id: Annotated[str, PropertyInfo(alias="customId")]
4242
"""Optional custom ID of the memory.
4343

tests/api_resources/test_memories.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,18 @@ def test_path_params_delete(self, client: Supermemory) -> None:
172172
@pytest.mark.skip(reason="Prism tests are disabled")
173173
@parametrize
174174
def test_method_add(self, client: Supermemory) -> None:
175-
memory = client.memories.add()
175+
memory = client.memories.add(
176+
content="This is a detailed article about machine learning concepts...",
177+
)
176178
assert_matches_type(MemoryAddResponse, memory, path=["response"])
177179

178180
@pytest.mark.skip(reason="Prism tests are disabled")
179181
@parametrize
180182
def test_method_add_with_all_params(self, client: Supermemory) -> None:
181183
memory = client.memories.add(
184+
content="This is a detailed article about machine learning concepts...",
182185
container_tag="user_123",
183186
container_tags=["user_123", "project_123"],
184-
content="This is a detailed article about machine learning concepts...",
185187
custom_id="mem_abc123",
186188
metadata={
187189
"category": "technology",
@@ -197,7 +199,9 @@ def test_method_add_with_all_params(self, client: Supermemory) -> None:
197199
@pytest.mark.skip(reason="Prism tests are disabled")
198200
@parametrize
199201
def test_raw_response_add(self, client: Supermemory) -> None:
200-
response = client.memories.with_raw_response.add()
202+
response = client.memories.with_raw_response.add(
203+
content="This is a detailed article about machine learning concepts...",
204+
)
201205

202206
assert response.is_closed is True
203207
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -207,7 +211,9 @@ def test_raw_response_add(self, client: Supermemory) -> None:
207211
@pytest.mark.skip(reason="Prism tests are disabled")
208212
@parametrize
209213
def test_streaming_response_add(self, client: Supermemory) -> None:
210-
with client.memories.with_streaming_response.add() as response:
214+
with client.memories.with_streaming_response.add(
215+
content="This is a detailed article about machine learning concepts...",
216+
) as response:
211217
assert not response.is_closed
212218
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
213219

@@ -456,16 +462,18 @@ async def test_path_params_delete(self, async_client: AsyncSupermemory) -> None:
456462
@pytest.mark.skip(reason="Prism tests are disabled")
457463
@parametrize
458464
async def test_method_add(self, async_client: AsyncSupermemory) -> None:
459-
memory = await async_client.memories.add()
465+
memory = await async_client.memories.add(
466+
content="This is a detailed article about machine learning concepts...",
467+
)
460468
assert_matches_type(MemoryAddResponse, memory, path=["response"])
461469

462470
@pytest.mark.skip(reason="Prism tests are disabled")
463471
@parametrize
464472
async def test_method_add_with_all_params(self, async_client: AsyncSupermemory) -> None:
465473
memory = await async_client.memories.add(
474+
content="This is a detailed article about machine learning concepts...",
466475
container_tag="user_123",
467476
container_tags=["user_123", "project_123"],
468-
content="This is a detailed article about machine learning concepts...",
469477
custom_id="mem_abc123",
470478
metadata={
471479
"category": "technology",
@@ -481,7 +489,9 @@ async def test_method_add_with_all_params(self, async_client: AsyncSupermemory)
481489
@pytest.mark.skip(reason="Prism tests are disabled")
482490
@parametrize
483491
async def test_raw_response_add(self, async_client: AsyncSupermemory) -> None:
484-
response = await async_client.memories.with_raw_response.add()
492+
response = await async_client.memories.with_raw_response.add(
493+
content="This is a detailed article about machine learning concepts...",
494+
)
485495

486496
assert response.is_closed is True
487497
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -491,7 +501,9 @@ async def test_raw_response_add(self, async_client: AsyncSupermemory) -> None:
491501
@pytest.mark.skip(reason="Prism tests are disabled")
492502
@parametrize
493503
async def test_streaming_response_add(self, async_client: AsyncSupermemory) -> None:
494-
async with async_client.memories.with_streaming_response.add() as response:
504+
async with async_client.memories.with_streaming_response.add(
505+
content="This is a detailed article about machine learning concepts...",
506+
) as response:
495507
assert not response.is_closed
496508
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
497509

0 commit comments

Comments
 (0)