supermemory 0.1.0a1__py3-none-any.whl → 3.0.0a2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. supermemory/__init__.py +7 -1
  2. supermemory/_base_client.py +44 -2
  3. supermemory/_client.py +21 -29
  4. supermemory/_models.py +2 -0
  5. supermemory/_types.py +2 -0
  6. supermemory/_utils/_proxy.py +4 -1
  7. supermemory/_utils/_resources_proxy.py +24 -0
  8. supermemory/_version.py +1 -1
  9. supermemory/resources/__init__.py +26 -40
  10. supermemory/resources/{connection.py → connections.py} +86 -80
  11. supermemory/resources/{memory.py → memories.py} +224 -176
  12. supermemory/resources/settings.py +102 -19
  13. supermemory/types/__init__.py +6 -7
  14. supermemory/types/connection_create_params.py +7 -2
  15. supermemory/types/connection_create_response.py +7 -1
  16. supermemory/types/connection_get_response.py +25 -0
  17. supermemory/types/memory_add_params.py +46 -0
  18. supermemory/types/{memory_create_response.py → memory_add_response.py} +2 -2
  19. supermemory/types/memory_get_response.py +79 -9
  20. supermemory/types/memory_update_params.py +46 -0
  21. supermemory/types/{memory_delete_response.py → memory_update_response.py} +5 -3
  22. supermemory/types/setting_get_response.py +45 -0
  23. supermemory/types/setting_update_params.py +28 -12
  24. supermemory/types/setting_update_response.py +31 -13
  25. {supermemory-0.1.0a1.dist-info → supermemory-3.0.0a2.dist-info}/METADATA +52 -15
  26. supermemory-3.0.0a2.dist-info/RECORD +46 -0
  27. supermemory/resources/search.py +0 -254
  28. supermemory/types/memory_create_params.py +0 -23
  29. supermemory/types/memory_list_params.py +0 -24
  30. supermemory/types/memory_list_response.py +0 -59
  31. supermemory/types/search_execute_params.py +0 -56
  32. supermemory/types/search_execute_response.py +0 -52
  33. supermemory-0.1.0a1.dist-info/RECORD +0 -47
  34. {supermemory-0.1.0a1.dist-info → supermemory-3.0.0a2.dist-info}/WHEEL +0 -0
  35. {supermemory-0.1.0a1.dist-info → supermemory-3.0.0a2.dist-info}/licenses/LICENSE +0 -0
supermemory/__init__.py CHANGED
@@ -1,5 +1,7 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ import typing as _t
4
+
3
5
  from . import types
4
6
  from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
5
7
  from ._utils import file_from_path
@@ -34,7 +36,7 @@ from ._exceptions import (
34
36
  UnprocessableEntityError,
35
37
  APIResponseValidationError,
36
38
  )
37
- from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
39
+ from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
38
40
  from ._utils._logs import setup_logging as _setup_logging
39
41
 
40
42
  __all__ = [
@@ -76,8 +78,12 @@ __all__ = [
76
78
  "DEFAULT_CONNECTION_LIMITS",
77
79
  "DefaultHttpxClient",
78
80
  "DefaultAsyncHttpxClient",
81
+ "DefaultAioHttpClient",
79
82
  ]
80
83
 
84
+ if not _t.TYPE_CHECKING:
85
+ from ._utils._resources_proxy import resources as resources
86
+
81
87
  _setup_logging()
82
88
 
83
89
  # Update the __module__ attribute for exported symbols so that
@@ -960,6 +960,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
960
960
  if self.custom_auth is not None:
961
961
  kwargs["auth"] = self.custom_auth
962
962
 
963
+ if options.follow_redirects is not None:
964
+ kwargs["follow_redirects"] = options.follow_redirects
965
+
963
966
  log.debug("Sending HTTP Request: %s %s", request.method, request.url)
964
967
 
965
968
  response = None
@@ -1068,7 +1071,14 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1068
1071
  ) -> ResponseT:
1069
1072
  origin = get_origin(cast_to) or cast_to
1070
1073
 
1071
- if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
1074
+ if (
1075
+ inspect.isclass(origin)
1076
+ and issubclass(origin, BaseAPIResponse)
1077
+ # we only want to actually return the custom BaseAPIResponse class if we're
1078
+ # returning the raw response, or if we're not streaming SSE, as if we're streaming
1079
+ # SSE then `cast_to` doesn't actively reflect the type we need to parse into
1080
+ and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
1081
+ ):
1072
1082
  if not issubclass(origin, APIResponse):
1073
1083
  raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
1074
1084
 
@@ -1279,6 +1289,24 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
1279
1289
  super().__init__(**kwargs)
1280
1290
 
1281
1291
 
1292
+ try:
1293
+ import httpx_aiohttp
1294
+ except ImportError:
1295
+
1296
+ class _DefaultAioHttpClient(httpx.AsyncClient):
1297
+ def __init__(self, **_kwargs: Any) -> None:
1298
+ raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
1299
+ else:
1300
+
1301
+ class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
1302
+ def __init__(self, **kwargs: Any) -> None:
1303
+ kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
1304
+ kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
1305
+ kwargs.setdefault("follow_redirects", True)
1306
+
1307
+ super().__init__(**kwargs)
1308
+
1309
+
1282
1310
  if TYPE_CHECKING:
1283
1311
  DefaultAsyncHttpxClient = httpx.AsyncClient
1284
1312
  """An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
@@ -1287,8 +1315,12 @@ if TYPE_CHECKING:
1287
1315
  This is useful because overriding the `http_client` with your own instance of
1288
1316
  `httpx.AsyncClient` will result in httpx's defaults being used, not ours.
1289
1317
  """
1318
+
1319
+ DefaultAioHttpClient = httpx.AsyncClient
1320
+ """An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
1290
1321
  else:
1291
1322
  DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
1323
+ DefaultAioHttpClient = _DefaultAioHttpClient
1292
1324
 
1293
1325
 
1294
1326
  class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
@@ -1460,6 +1492,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1460
1492
  if self.custom_auth is not None:
1461
1493
  kwargs["auth"] = self.custom_auth
1462
1494
 
1495
+ if options.follow_redirects is not None:
1496
+ kwargs["follow_redirects"] = options.follow_redirects
1497
+
1463
1498
  log.debug("Sending HTTP Request: %s %s", request.method, request.url)
1464
1499
 
1465
1500
  response = None
@@ -1568,7 +1603,14 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1568
1603
  ) -> ResponseT:
1569
1604
  origin = get_origin(cast_to) or cast_to
1570
1605
 
1571
- if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
1606
+ if (
1607
+ inspect.isclass(origin)
1608
+ and issubclass(origin, BaseAPIResponse)
1609
+ # we only want to actually return the custom BaseAPIResponse class if we're
1610
+ # returning the raw response, or if we're not streaming SSE, as if we're streaming
1611
+ # SSE then `cast_to` doesn't actively reflect the type we need to parse into
1612
+ and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
1613
+ ):
1572
1614
  if not issubclass(origin, AsyncAPIResponse):
1573
1615
  raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
1574
1616
 
supermemory/_client.py CHANGED
@@ -21,7 +21,7 @@ from ._types import (
21
21
  )
22
22
  from ._utils import is_given, get_async_library
23
23
  from ._version import __version__
24
- from .resources import memory, search, settings, connection
24
+ from .resources import memories, settings, connections
25
25
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
26
26
  from ._exceptions import APIStatusError, SupermemoryError
27
27
  from ._base_client import (
@@ -43,10 +43,9 @@ __all__ = [
43
43
 
44
44
 
45
45
  class Supermemory(SyncAPIClient):
46
+ memories: memories.MemoriesResource
46
47
  settings: settings.SettingsResource
47
- memory: memory.MemoryResource
48
- search: search.SearchResource
49
- connection: connection.ConnectionResource
48
+ connections: connections.ConnectionsResource
50
49
  with_raw_response: SupermemoryWithRawResponse
51
50
  with_streaming_response: SupermemoryWithStreamedResponse
52
51
 
@@ -91,7 +90,7 @@ class Supermemory(SyncAPIClient):
91
90
  if base_url is None:
92
91
  base_url = os.environ.get("SUPERMEMORY_BASE_URL")
93
92
  if base_url is None:
94
- base_url = f"https://v2.api.supermemory.ai"
93
+ base_url = f"https://api.supermemory.ai/"
95
94
 
96
95
  super().__init__(
97
96
  version=__version__,
@@ -104,10 +103,9 @@ class Supermemory(SyncAPIClient):
104
103
  _strict_response_validation=_strict_response_validation,
105
104
  )
106
105
 
106
+ self.memories = memories.MemoriesResource(self)
107
107
  self.settings = settings.SettingsResource(self)
108
- self.memory = memory.MemoryResource(self)
109
- self.search = search.SearchResource(self)
110
- self.connection = connection.ConnectionResource(self)
108
+ self.connections = connections.ConnectionsResource(self)
111
109
  self.with_raw_response = SupermemoryWithRawResponse(self)
112
110
  self.with_streaming_response = SupermemoryWithStreamedResponse(self)
113
111
 
@@ -120,7 +118,7 @@ class Supermemory(SyncAPIClient):
120
118
  @override
121
119
  def auth_headers(self) -> dict[str, str]:
122
120
  api_key = self.api_key
123
- return {"X-API-Key": api_key}
121
+ return {"Authorization": f"Bearer {api_key}"}
124
122
 
125
123
  @property
126
124
  @override
@@ -217,10 +215,9 @@ class Supermemory(SyncAPIClient):
217
215
 
218
216
 
219
217
  class AsyncSupermemory(AsyncAPIClient):
218
+ memories: memories.AsyncMemoriesResource
220
219
  settings: settings.AsyncSettingsResource
221
- memory: memory.AsyncMemoryResource
222
- search: search.AsyncSearchResource
223
- connection: connection.AsyncConnectionResource
220
+ connections: connections.AsyncConnectionsResource
224
221
  with_raw_response: AsyncSupermemoryWithRawResponse
225
222
  with_streaming_response: AsyncSupermemoryWithStreamedResponse
226
223
 
@@ -265,7 +262,7 @@ class AsyncSupermemory(AsyncAPIClient):
265
262
  if base_url is None:
266
263
  base_url = os.environ.get("SUPERMEMORY_BASE_URL")
267
264
  if base_url is None:
268
- base_url = f"https://v2.api.supermemory.ai"
265
+ base_url = f"https://api.supermemory.ai/"
269
266
 
270
267
  super().__init__(
271
268
  version=__version__,
@@ -278,10 +275,9 @@ class AsyncSupermemory(AsyncAPIClient):
278
275
  _strict_response_validation=_strict_response_validation,
279
276
  )
280
277
 
278
+ self.memories = memories.AsyncMemoriesResource(self)
281
279
  self.settings = settings.AsyncSettingsResource(self)
282
- self.memory = memory.AsyncMemoryResource(self)
283
- self.search = search.AsyncSearchResource(self)
284
- self.connection = connection.AsyncConnectionResource(self)
280
+ self.connections = connections.AsyncConnectionsResource(self)
285
281
  self.with_raw_response = AsyncSupermemoryWithRawResponse(self)
286
282
  self.with_streaming_response = AsyncSupermemoryWithStreamedResponse(self)
287
283
 
@@ -294,7 +290,7 @@ class AsyncSupermemory(AsyncAPIClient):
294
290
  @override
295
291
  def auth_headers(self) -> dict[str, str]:
296
292
  api_key = self.api_key
297
- return {"X-API-Key": api_key}
293
+ return {"Authorization": f"Bearer {api_key}"}
298
294
 
299
295
  @property
300
296
  @override
@@ -392,34 +388,30 @@ class AsyncSupermemory(AsyncAPIClient):
392
388
 
393
389
  class SupermemoryWithRawResponse:
394
390
  def __init__(self, client: Supermemory) -> None:
391
+ self.memories = memories.MemoriesResourceWithRawResponse(client.memories)
395
392
  self.settings = settings.SettingsResourceWithRawResponse(client.settings)
396
- self.memory = memory.MemoryResourceWithRawResponse(client.memory)
397
- self.search = search.SearchResourceWithRawResponse(client.search)
398
- self.connection = connection.ConnectionResourceWithRawResponse(client.connection)
393
+ self.connections = connections.ConnectionsResourceWithRawResponse(client.connections)
399
394
 
400
395
 
401
396
  class AsyncSupermemoryWithRawResponse:
402
397
  def __init__(self, client: AsyncSupermemory) -> None:
398
+ self.memories = memories.AsyncMemoriesResourceWithRawResponse(client.memories)
403
399
  self.settings = settings.AsyncSettingsResourceWithRawResponse(client.settings)
404
- self.memory = memory.AsyncMemoryResourceWithRawResponse(client.memory)
405
- self.search = search.AsyncSearchResourceWithRawResponse(client.search)
406
- self.connection = connection.AsyncConnectionResourceWithRawResponse(client.connection)
400
+ self.connections = connections.AsyncConnectionsResourceWithRawResponse(client.connections)
407
401
 
408
402
 
409
403
  class SupermemoryWithStreamedResponse:
410
404
  def __init__(self, client: Supermemory) -> None:
405
+ self.memories = memories.MemoriesResourceWithStreamingResponse(client.memories)
411
406
  self.settings = settings.SettingsResourceWithStreamingResponse(client.settings)
412
- self.memory = memory.MemoryResourceWithStreamingResponse(client.memory)
413
- self.search = search.SearchResourceWithStreamingResponse(client.search)
414
- self.connection = connection.ConnectionResourceWithStreamingResponse(client.connection)
407
+ self.connections = connections.ConnectionsResourceWithStreamingResponse(client.connections)
415
408
 
416
409
 
417
410
  class AsyncSupermemoryWithStreamedResponse:
418
411
  def __init__(self, client: AsyncSupermemory) -> None:
412
+ self.memories = memories.AsyncMemoriesResourceWithStreamingResponse(client.memories)
419
413
  self.settings = settings.AsyncSettingsResourceWithStreamingResponse(client.settings)
420
- self.memory = memory.AsyncMemoryResourceWithStreamingResponse(client.memory)
421
- self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
422
- self.connection = connection.AsyncConnectionResourceWithStreamingResponse(client.connection)
414
+ self.connections = connections.AsyncConnectionsResourceWithStreamingResponse(client.connections)
423
415
 
424
416
 
425
417
  Client = Supermemory
supermemory/_models.py CHANGED
@@ -737,6 +737,7 @@ class FinalRequestOptionsInput(TypedDict, total=False):
737
737
  idempotency_key: str
738
738
  json_data: Body
739
739
  extra_json: AnyMapping
740
+ follow_redirects: bool
740
741
 
741
742
 
742
743
  @final
@@ -750,6 +751,7 @@ class FinalRequestOptions(pydantic.BaseModel):
750
751
  files: Union[HttpxRequestFiles, None] = None
751
752
  idempotency_key: Union[str, None] = None
752
753
  post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
754
+ follow_redirects: Union[bool, None] = None
753
755
 
754
756
  # It should be noted that we cannot use `json` here as that would override
755
757
  # a BaseModel method in an incompatible fashion.
supermemory/_types.py CHANGED
@@ -100,6 +100,7 @@ class RequestOptions(TypedDict, total=False):
100
100
  params: Query
101
101
  extra_json: AnyMapping
102
102
  idempotency_key: str
103
+ follow_redirects: bool
103
104
 
104
105
 
105
106
  # Sentinel class used until PEP 0661 is accepted
@@ -215,3 +216,4 @@ class _GenericAlias(Protocol):
215
216
 
216
217
  class HttpxSendArgs(TypedDict, total=False):
217
218
  auth: httpx.Auth
219
+ follow_redirects: bool
@@ -46,7 +46,10 @@ class LazyProxy(Generic[T], ABC):
46
46
  @property # type: ignore
47
47
  @override
48
48
  def __class__(self) -> type: # pyright: ignore
49
- proxied = self.__get_proxied__()
49
+ try:
50
+ proxied = self.__get_proxied__()
51
+ except Exception:
52
+ return type(self)
50
53
  if issubclass(type(proxied), LazyProxy):
51
54
  return type(proxied)
52
55
  return proxied.__class__
@@ -0,0 +1,24 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+ from typing_extensions import override
5
+
6
+ from ._proxy import LazyProxy
7
+
8
+
9
+ class ResourcesProxy(LazyProxy[Any]):
10
+ """A proxy for the `supermemory.resources` module.
11
+
12
+ This is used so that we can lazily import `supermemory.resources` only when
13
+ needed *and* so that users can just import `supermemory` and reference `supermemory.resources`
14
+ """
15
+
16
+ @override
17
+ def __load__(self) -> Any:
18
+ import importlib
19
+
20
+ mod = importlib.import_module("supermemory.resources")
21
+ return mod
22
+
23
+
24
+ resources = ResourcesProxy().__as_proxied__()
supermemory/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "supermemory"
4
- __version__ = "0.1.0-alpha.1" # x-release-please-version
4
+ __version__ = "3.0.0-alpha.2" # x-release-please-version
@@ -1,20 +1,12 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- from .memory import (
4
- MemoryResource,
5
- AsyncMemoryResource,
6
- MemoryResourceWithRawResponse,
7
- AsyncMemoryResourceWithRawResponse,
8
- MemoryResourceWithStreamingResponse,
9
- AsyncMemoryResourceWithStreamingResponse,
10
- )
11
- from .search import (
12
- SearchResource,
13
- AsyncSearchResource,
14
- SearchResourceWithRawResponse,
15
- AsyncSearchResourceWithRawResponse,
16
- SearchResourceWithStreamingResponse,
17
- AsyncSearchResourceWithStreamingResponse,
3
+ from .memories import (
4
+ MemoriesResource,
5
+ AsyncMemoriesResource,
6
+ MemoriesResourceWithRawResponse,
7
+ AsyncMemoriesResourceWithRawResponse,
8
+ MemoriesResourceWithStreamingResponse,
9
+ AsyncMemoriesResourceWithStreamingResponse,
18
10
  )
19
11
  from .settings import (
20
12
  SettingsResource,
@@ -24,38 +16,32 @@ from .settings import (
24
16
  SettingsResourceWithStreamingResponse,
25
17
  AsyncSettingsResourceWithStreamingResponse,
26
18
  )
27
- from .connection import (
28
- ConnectionResource,
29
- AsyncConnectionResource,
30
- ConnectionResourceWithRawResponse,
31
- AsyncConnectionResourceWithRawResponse,
32
- ConnectionResourceWithStreamingResponse,
33
- AsyncConnectionResourceWithStreamingResponse,
19
+ from .connections import (
20
+ ConnectionsResource,
21
+ AsyncConnectionsResource,
22
+ ConnectionsResourceWithRawResponse,
23
+ AsyncConnectionsResourceWithRawResponse,
24
+ ConnectionsResourceWithStreamingResponse,
25
+ AsyncConnectionsResourceWithStreamingResponse,
34
26
  )
35
27
 
36
28
  __all__ = [
29
+ "MemoriesResource",
30
+ "AsyncMemoriesResource",
31
+ "MemoriesResourceWithRawResponse",
32
+ "AsyncMemoriesResourceWithRawResponse",
33
+ "MemoriesResourceWithStreamingResponse",
34
+ "AsyncMemoriesResourceWithStreamingResponse",
37
35
  "SettingsResource",
38
36
  "AsyncSettingsResource",
39
37
  "SettingsResourceWithRawResponse",
40
38
  "AsyncSettingsResourceWithRawResponse",
41
39
  "SettingsResourceWithStreamingResponse",
42
40
  "AsyncSettingsResourceWithStreamingResponse",
43
- "MemoryResource",
44
- "AsyncMemoryResource",
45
- "MemoryResourceWithRawResponse",
46
- "AsyncMemoryResourceWithRawResponse",
47
- "MemoryResourceWithStreamingResponse",
48
- "AsyncMemoryResourceWithStreamingResponse",
49
- "SearchResource",
50
- "AsyncSearchResource",
51
- "SearchResourceWithRawResponse",
52
- "AsyncSearchResourceWithRawResponse",
53
- "SearchResourceWithStreamingResponse",
54
- "AsyncSearchResourceWithStreamingResponse",
55
- "ConnectionResource",
56
- "AsyncConnectionResource",
57
- "ConnectionResourceWithRawResponse",
58
- "AsyncConnectionResourceWithRawResponse",
59
- "ConnectionResourceWithStreamingResponse",
60
- "AsyncConnectionResourceWithStreamingResponse",
41
+ "ConnectionsResource",
42
+ "AsyncConnectionsResource",
43
+ "ConnectionsResourceWithRawResponse",
44
+ "AsyncConnectionsResourceWithRawResponse",
45
+ "ConnectionsResourceWithStreamingResponse",
46
+ "AsyncConnectionsResourceWithStreamingResponse",
61
47
  ]