Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.33.1"
".": "3.34.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-3d1ed08ae874eafef0c275748f38e21c1e6a245ecad05db24dee27f4166f18db.yml
openapi_spec_hash: fa7ccfe7d4574c280f3189d020401032
config_hash: f3eb5ca71172780678106f6d46f15dda
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-f09b91ede978d3fd05810d3750fcc837f8baa6430fa1be9208ba3088ecaef7f4.yml
openapi_spec_hash: 957d1e254f2f5933d0c22f3b310122e9
config_hash: cde97ef3188581c5f4924c633ec33ddb
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 3.34.0 (2026-04-18)

Full Changelog: [v3.33.1...v3.34.0](https://github.com/supermemoryai/python-sdk/compare/v3.33.1...v3.34.0)

### Features

* **api:** api update ([5b92603](https://github.com/supermemoryai/python-sdk/commit/5b9260335ff2514491b0c41f6544872ee58485fb))
* **api:** api update ([ab60a76](https://github.com/supermemoryai/python-sdk/commit/ab60a7657699fc974c8648adcb74a0dba9a4fe5b))
* **api:** api update ([0950bae](https://github.com/supermemoryai/python-sdk/commit/0950bae08a126b09a2844839db673e99cfc13f75))


### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([421e80e](https://github.com/supermemoryai/python-sdk/commit/421e80e55548a1ea7b348683e841060c350b56e7))

## 3.33.1 (2026-04-11)

Full Changelog: [v3.33.0...v3.33.1](https://github.com/supermemoryai/python-sdk/compare/v3.33.0...v3.33.1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "supermemory"
version = "3.33.1"
version = "3.34.0"
description = "The official Python library for the supermemory API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
22 changes: 21 additions & 1 deletion src/supermemory/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from typing import TYPE_CHECKING, Any, Dict, Union, Mapping
from typing_extensions import Self, override
from typing_extensions import Self, Literal, override

import httpx

Expand Down Expand Up @@ -245,7 +245,9 @@ def add(
container_tags: SequenceNotStr[str] | Omit = omit,
custom_id: str | Omit = omit,
entity_context: str | Omit = omit,
filepath: str | Omit = omit,
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
task_type: Literal["memory", "superrag"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -269,8 +271,14 @@ def add(
entity_context: Optional entity context for this container tag. Max 1500 characters. Used during
document processing to guide memory extraction.

filepath: Optional file path for the document. Used by supermemoryfs to store the full
path of the file.

metadata: Optional metadata for the document.

task_type: Task type: "memory" (default) for full context layer with SuperRAG built in,
"superrag" for managed RAG as a service.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -288,7 +296,9 @@ def add(
"container_tags": container_tags,
"custom_id": custom_id,
"entity_context": entity_context,
"filepath": filepath,
"metadata": metadata,
"task_type": task_type,
},
client_add_params.ClientAddParams,
),
Expand Down Expand Up @@ -561,7 +571,9 @@ async def add(
container_tags: SequenceNotStr[str] | Omit = omit,
custom_id: str | Omit = omit,
entity_context: str | Omit = omit,
filepath: str | Omit = omit,
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
task_type: Literal["memory", "superrag"] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -585,8 +597,14 @@ async def add(
entity_context: Optional entity context for this container tag. Max 1500 characters. Used during
document processing to guide memory extraction.

filepath: Optional file path for the document. Used by supermemoryfs to store the full
path of the file.

metadata: Optional metadata for the document.

task_type: Task type: "memory" (default) for full context layer with SuperRAG built in,
"superrag" for managed RAG as a service.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -604,7 +622,9 @@ async def add(
"container_tags": container_tags,
"custom_id": custom_id,
"entity_context": entity_context,
"filepath": filepath,
"metadata": metadata,
"task_type": task_type,
},
client_add_params.ClientAddParams,
),
Expand Down
56 changes: 53 additions & 3 deletions src/supermemory/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io
import os
import pathlib
from typing import overload
from typing_extensions import TypeGuard
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard

import anyio

Expand All @@ -17,7 +17,9 @@
HttpxFileContent,
HttpxRequestFiles,
)
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t

_T = TypeVar("_T")


def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
Expand Down Expand Up @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
return await anyio.Path(file).read_bytes()

return file


def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
"""Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
{
"foo": {
"bar": {"baz": {}},
"files": {"file": <content>}
}
}
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
"""
return _deepcopy_with_paths(item, paths, 0)


def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
if not paths:
return item
if is_mapping(item):
key_to_paths: dict[str, list[Sequence[str]]] = {}
for path in paths:
if index < len(path):
key_to_paths.setdefault(path[index], []).append(path)

# if no path continues through this mapping, it won't be mutated and copying it is redundant
if not key_to_paths:
return item

result = dict(item)
for key, subpaths in key_to_paths.items():
if key in result:
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
return cast(_T, result)
if is_list(item):
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]

# if no path expects a list here, nothing will be mutated inside it - return by reference
if not array_paths:
return cast(_T, item)
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
return item
1 change: 0 additions & 1 deletion src/supermemory/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
coerce_integer as coerce_integer,
file_from_path as file_from_path,
strip_not_given as strip_not_given,
deepcopy_minimal as deepcopy_minimal,
get_async_library as get_async_library,
maybe_coerce_float as maybe_coerce_float,
get_required_header as get_required_header,
Expand Down
15 changes: 0 additions & 15 deletions src/supermemory/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
return isinstance(obj, Iterable)


def deepcopy_minimal(item: _T) -> _T:
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:

- mappings, e.g. `dict`
- list

This is done for performance reasons.
"""
if is_mapping(item):
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
if is_list(item):
return cast(_T, [deepcopy_minimal(entry) for entry in item])
return item


# copied from https://github.com/Rapptz/RoboDanny
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
size = len(seq)
Expand Down
2 changes: 1 addition & 1 deletion src/supermemory/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "supermemory"
__version__ = "3.33.1" # x-release-please-version
__version__ = "3.34.0" # x-release-please-version
4 changes: 4 additions & 0 deletions src/supermemory/resources/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ def resources(
connection_id: str,
*,
page: float | Omit = omit,
parent_id: str | Omit = omit,
per_page: float | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -449,6 +450,7 @@ def resources(
query=maybe_transform(
{
"page": page,
"parent_id": parent_id,
"per_page": per_page,
},
connection_resources_params.ConnectionResourcesParams,
Expand Down Expand Up @@ -839,6 +841,7 @@ async def resources(
connection_id: str,
*,
page: float | Omit = omit,
parent_id: str | Omit = omit,
per_page: float | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -871,6 +874,7 @@ async def resources(
query=await async_maybe_transform(
{
"page": page,
"parent_id": parent_id,
"per_page": per_page,
},
connection_resources_params.ConnectionResourcesParams,
Expand Down
Loading