Skip to content

Commit 02a5d82

Browse files
feat(api): api update
1 parent b8f38a9 commit 02a5d82

5 files changed

Lines changed: 142 additions & 116 deletions

File tree

.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/supermemory-new-cc0ff5a1831707e8733abeeaa245215c4ba276f8f485ed36beeeaa4f0580a203.yml
3-
openapi_spec_hash: d49d49625c82142babe4a6ac4d2cd8d4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc/supermemory-new-26f4b89c531711844d1ee4abe2451e7b8459a4ba1a0c2d63d2b9914075e83c87.yml
3+
openapi_spec_hash: 6921ba2bd43309aa97748d0af48adb13
44
config_hash: cde97ef3188581c5f4924c633ec33ddb

src/supermemory/resources/documents.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def batch_add(
338338
container_tag: str | Omit = omit,
339339
container_tags: SequenceNotStr[str] | Omit = omit,
340340
content: None | Omit = omit,
341+
entity_context: str | Omit = omit,
341342
filepath: str | Omit = omit,
342343
filter_by_metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
343344
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
@@ -363,6 +364,9 @@ def batch_add(
363364
containerized by. This can be an ID for your user, a project ID, or any other
364365
identifier you wish to use to group documents.
365366
367+
entity_context: Optional entity context for this container tag. Max 1500 characters. Used during
368+
document processing to guide memory extraction.
369+
366370
filepath: Optional file path for the document (e.g., '/documents/reports/file.pdf'). Used
367371
by supermemoryfs to map documents to filesystem paths.
368372
@@ -396,6 +400,7 @@ def batch_add(
396400
"container_tag": container_tag,
397401
"container_tags": container_tags,
398402
"content": content,
403+
"entity_context": entity_context,
399404
"filepath": filepath,
400405
"filter_by_metadata": filter_by_metadata,
401406
"metadata": metadata,
@@ -915,6 +920,7 @@ async def batch_add(
915920
container_tag: str | Omit = omit,
916921
container_tags: SequenceNotStr[str] | Omit = omit,
917922
content: None | Omit = omit,
923+
entity_context: str | Omit = omit,
918924
filepath: str | Omit = omit,
919925
filter_by_metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
920926
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
@@ -940,6 +946,9 @@ async def batch_add(
940946
containerized by. This can be an ID for your user, a project ID, or any other
941947
identifier you wish to use to group documents.
942948
949+
entity_context: Optional entity context for this container tag. Max 1500 characters. Used during
950+
document processing to guide memory extraction.
951+
943952
filepath: Optional file path for the document (e.g., '/documents/reports/file.pdf'). Used
944953
by supermemoryfs to map documents to filesystem paths.
945954
@@ -973,6 +982,7 @@ async def batch_add(
973982
"container_tag": container_tag,
974983
"container_tags": container_tags,
975984
"content": content,
985+
"entity_context": entity_context,
976986
"filepath": filepath,
977987
"filter_by_metadata": filter_by_metadata,
978988
"metadata": metadata,

src/supermemory/types/document_batch_add_params.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class DocumentBatchAddParams(TypedDict, total=False):
3030

3131
content: None
3232

33+
entity_context: Annotated[str, PropertyInfo(alias="entityContext")]
34+
"""Optional entity context for this container tag.
35+
36+
Max 1500 characters. Used during document processing to guide memory extraction.
37+
"""
38+
3339
filepath: str
3440
"""Optional file path for the document (e.g., '/documents/reports/file.pdf').
3541
@@ -96,6 +102,12 @@ class DocumentsUnionMember0(TypedDict, total=False):
96102
document.
97103
"""
98104

105+
entity_context: Annotated[str, PropertyInfo(alias="entityContext")]
106+
"""Optional entity context for this container tag.
107+
108+
Max 1500 characters. Used during document processing to guide memory extraction.
109+
"""
110+
99111
filepath: str
100112
"""Optional file path for the document (e.g., '/documents/reports/file.pdf').
101113

tests/api_resources/test_documents.py

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,18 @@ def test_method_update(self, client: Supermemory) -> None:
3939
def test_method_update_with_all_params(self, client: Supermemory) -> None:
4040
document = client.documents.update(
4141
id="id",
42-
container_tag="user_123",
43-
container_tags=["user_123", "project_123"],
44-
content="This is a detailed article about machine learning concepts...",
45-
custom_id="mem_abc123",
42+
container_tag="user_alex",
43+
container_tags=["_:_k--W2K_1V"],
44+
content="Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s.",
45+
custom_id="doc-api-rate-limits",
4646
filepath="/documents/reports/file.pdf",
4747
filter_by_metadata={
4848
"department": "engineering",
4949
"region": "us",
5050
},
5151
metadata={
52-
"category": "technology",
53-
"isPublic": True,
54-
"readingTime": 5,
55-
"source": "web",
56-
"tag_1": "ai",
57-
"tag_2": "machine-learning",
52+
"source": "upload",
53+
"language": "en",
5854
},
5955
task_type="memory",
6056
)
@@ -104,8 +100,8 @@ def test_method_list(self, client: Supermemory) -> None:
104100
@parametrize
105101
def test_method_list_with_all_params(self, client: Supermemory) -> None:
106102
document = client.documents.list(
107-
container_tags=["user_123", "project_123"],
108-
filepath="/docs/",
103+
container_tags=["_:_k--W2K_1V"],
104+
filepath="filepath",
109105
filters={
110106
"and_": [
111107
{
@@ -252,7 +248,11 @@ def test_streaming_response_add(self, client: Supermemory) -> None:
252248
@parametrize
253249
def test_method_batch_add(self, client: Supermemory) -> None:
254250
document = client.documents.batch_add(
255-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
251+
documents=[
252+
{
253+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
254+
}
255+
],
256256
)
257257
assert_matches_type(DocumentBatchAddResponse, document, path=["response"])
258258

@@ -262,41 +262,35 @@ def test_method_batch_add_with_all_params(self, client: Supermemory) -> None:
262262
document = client.documents.batch_add(
263263
documents=[
264264
{
265-
"content": "This is a detailed article about machine learning concepts...",
266-
"container_tag": "user_123",
267-
"container_tags": ["user_123", "project_123"],
268-
"custom_id": "mem_abc123",
265+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s.",
266+
"container_tag": "user_alex",
267+
"container_tags": ["_:_k--W2K_1V"],
268+
"custom_id": "doc-api-rate-limits",
269+
"entity_context": "User's name is {XYZ}",
269270
"filepath": "/documents/reports/file.pdf",
270271
"filter_by_metadata": {
271272
"department": "engineering",
272273
"region": "us",
273274
},
274275
"metadata": {
275-
"category": "technology",
276-
"isPublic": True,
277-
"readingTime": 5,
278-
"source": "web",
279-
"tag_1": "ai",
280-
"tag_2": "machine-learning",
276+
"source": "upload",
277+
"language": "en",
281278
},
282279
"task_type": "memory",
283280
}
284281
],
285-
container_tag="user_123",
286-
container_tags=["user_123", "project_123"],
282+
container_tag="user_alex",
283+
container_tags=["_:_k--W2K_1V"],
287284
content=None,
285+
entity_context="User's name is {XYZ}",
288286
filepath="/documents/reports/file.pdf",
289287
filter_by_metadata={
290288
"department": "engineering",
291289
"region": "us",
292290
},
293291
metadata={
294-
"category": "technology",
295-
"isPublic": True,
296-
"readingTime": 5,
297-
"source": "web",
298-
"tag_1": "ai",
299-
"tag_2": "machine-learning",
292+
"source": "upload",
293+
"language": "en",
300294
},
301295
task_type="memory",
302296
)
@@ -306,7 +300,11 @@ def test_method_batch_add_with_all_params(self, client: Supermemory) -> None:
306300
@parametrize
307301
def test_raw_response_batch_add(self, client: Supermemory) -> None:
308302
response = client.documents.with_raw_response.batch_add(
309-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
303+
documents=[
304+
{
305+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
306+
}
307+
],
310308
)
311309

312310
assert response.is_closed is True
@@ -318,7 +316,11 @@ def test_raw_response_batch_add(self, client: Supermemory) -> None:
318316
@parametrize
319317
def test_streaming_response_batch_add(self, client: Supermemory) -> None:
320318
with client.documents.with_streaming_response.batch_add(
321-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
319+
documents=[
320+
{
321+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
322+
}
323+
],
322324
) as response:
323325
assert not response.is_closed
324326
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -338,8 +340,8 @@ def test_method_delete_bulk(self, client: Supermemory) -> None:
338340
@parametrize
339341
def test_method_delete_bulk_with_all_params(self, client: Supermemory) -> None:
340342
document = client.documents.delete_bulk(
341-
container_tags=["user_123", "project_123"],
342-
filepath="/docs/old/",
343+
container_tags=["_:_k--W2K_1V"],
344+
filepath="filepath",
343345
ids=["acxV5LHMEsG2hMSNb4umbn", "bxcV5LHMEsG2hMSNb4umbn"],
344346
)
345347
assert_matches_type(DocumentDeleteBulkResponse, document, path=["response"])
@@ -450,9 +452,9 @@ def test_method_upload_file_with_all_params(self, client: Supermemory) -> None:
450452
document = client.documents.upload_file(
451453
file=b"Example data",
452454
container_tag="user",
453-
container_tags='["user_123", "project_123"]',
455+
container_tags="containerTags",
454456
custom_id="mem_abc123",
455-
entity_context="This user is a software engineer who prefers concise technical documentation.",
457+
entity_context="User's name is {XYZ}",
456458
filepath="/documents/reports/file.pdf",
457459
file_type="image",
458460
filter_by_metadata='{"department": "engineering"}',
@@ -508,22 +510,18 @@ async def test_method_update(self, async_client: AsyncSupermemory) -> None:
508510
async def test_method_update_with_all_params(self, async_client: AsyncSupermemory) -> None:
509511
document = await async_client.documents.update(
510512
id="id",
511-
container_tag="user_123",
512-
container_tags=["user_123", "project_123"],
513-
content="This is a detailed article about machine learning concepts...",
514-
custom_id="mem_abc123",
513+
container_tag="user_alex",
514+
container_tags=["_:_k--W2K_1V"],
515+
content="Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s.",
516+
custom_id="doc-api-rate-limits",
515517
filepath="/documents/reports/file.pdf",
516518
filter_by_metadata={
517519
"department": "engineering",
518520
"region": "us",
519521
},
520522
metadata={
521-
"category": "technology",
522-
"isPublic": True,
523-
"readingTime": 5,
524-
"source": "web",
525-
"tag_1": "ai",
526-
"tag_2": "machine-learning",
523+
"source": "upload",
524+
"language": "en",
527525
},
528526
task_type="memory",
529527
)
@@ -573,8 +571,8 @@ async def test_method_list(self, async_client: AsyncSupermemory) -> None:
573571
@parametrize
574572
async def test_method_list_with_all_params(self, async_client: AsyncSupermemory) -> None:
575573
document = await async_client.documents.list(
576-
container_tags=["user_123", "project_123"],
577-
filepath="/docs/",
574+
container_tags=["_:_k--W2K_1V"],
575+
filepath="filepath",
578576
filters={
579577
"and_": [
580578
{
@@ -721,7 +719,11 @@ async def test_streaming_response_add(self, async_client: AsyncSupermemory) -> N
721719
@parametrize
722720
async def test_method_batch_add(self, async_client: AsyncSupermemory) -> None:
723721
document = await async_client.documents.batch_add(
724-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
722+
documents=[
723+
{
724+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
725+
}
726+
],
725727
)
726728
assert_matches_type(DocumentBatchAddResponse, document, path=["response"])
727729

@@ -731,41 +733,35 @@ async def test_method_batch_add_with_all_params(self, async_client: AsyncSuperme
731733
document = await async_client.documents.batch_add(
732734
documents=[
733735
{
734-
"content": "This is a detailed article about machine learning concepts...",
735-
"container_tag": "user_123",
736-
"container_tags": ["user_123", "project_123"],
737-
"custom_id": "mem_abc123",
736+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s.",
737+
"container_tag": "user_alex",
738+
"container_tags": ["_:_k--W2K_1V"],
739+
"custom_id": "doc-api-rate-limits",
740+
"entity_context": "User's name is {XYZ}",
738741
"filepath": "/documents/reports/file.pdf",
739742
"filter_by_metadata": {
740743
"department": "engineering",
741744
"region": "us",
742745
},
743746
"metadata": {
744-
"category": "technology",
745-
"isPublic": True,
746-
"readingTime": 5,
747-
"source": "web",
748-
"tag_1": "ai",
749-
"tag_2": "machine-learning",
747+
"source": "upload",
748+
"language": "en",
750749
},
751750
"task_type": "memory",
752751
}
753752
],
754-
container_tag="user_123",
755-
container_tags=["user_123", "project_123"],
753+
container_tag="user_alex",
754+
container_tags=["_:_k--W2K_1V"],
756755
content=None,
756+
entity_context="User's name is {XYZ}",
757757
filepath="/documents/reports/file.pdf",
758758
filter_by_metadata={
759759
"department": "engineering",
760760
"region": "us",
761761
},
762762
metadata={
763-
"category": "technology",
764-
"isPublic": True,
765-
"readingTime": 5,
766-
"source": "web",
767-
"tag_1": "ai",
768-
"tag_2": "machine-learning",
763+
"source": "upload",
764+
"language": "en",
769765
},
770766
task_type="memory",
771767
)
@@ -775,7 +771,11 @@ async def test_method_batch_add_with_all_params(self, async_client: AsyncSuperme
775771
@parametrize
776772
async def test_raw_response_batch_add(self, async_client: AsyncSupermemory) -> None:
777773
response = await async_client.documents.with_raw_response.batch_add(
778-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
774+
documents=[
775+
{
776+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
777+
}
778+
],
779779
)
780780

781781
assert response.is_closed is True
@@ -787,7 +787,11 @@ async def test_raw_response_batch_add(self, async_client: AsyncSupermemory) -> N
787787
@parametrize
788788
async def test_streaming_response_batch_add(self, async_client: AsyncSupermemory) -> None:
789789
async with async_client.documents.with_streaming_response.batch_add(
790-
documents=[{"content": "This is a detailed article about machine learning concepts..."}],
790+
documents=[
791+
{
792+
"content": "Our API rate limits are 100 req/min on free and 1000 on pro. Clients should use exponential backoff on 429s."
793+
}
794+
],
791795
) as response:
792796
assert not response.is_closed
793797
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -807,8 +811,8 @@ async def test_method_delete_bulk(self, async_client: AsyncSupermemory) -> None:
807811
@parametrize
808812
async def test_method_delete_bulk_with_all_params(self, async_client: AsyncSupermemory) -> None:
809813
document = await async_client.documents.delete_bulk(
810-
container_tags=["user_123", "project_123"],
811-
filepath="/docs/old/",
814+
container_tags=["_:_k--W2K_1V"],
815+
filepath="filepath",
812816
ids=["acxV5LHMEsG2hMSNb4umbn", "bxcV5LHMEsG2hMSNb4umbn"],
813817
)
814818
assert_matches_type(DocumentDeleteBulkResponse, document, path=["response"])
@@ -919,9 +923,9 @@ async def test_method_upload_file_with_all_params(self, async_client: AsyncSuper
919923
document = await async_client.documents.upload_file(
920924
file=b"Example data",
921925
container_tag="user",
922-
container_tags='["user_123", "project_123"]',
926+
container_tags="containerTags",
923927
custom_id="mem_abc123",
924-
entity_context="This user is a software engineer who prefers concise technical documentation.",
928+
entity_context="User's name is {XYZ}",
925929
filepath="/documents/reports/file.pdf",
926930
file_type="image",
927931
filter_by_metadata='{"department": "engineering"}',

0 commit comments

Comments
 (0)