Skip to content

Commit b7df28e

Browse files
feat(api): api update
1 parent 2b1b499 commit b7df28e

22 files changed

+47
-2075
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: 18
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-2e25417520c33948724b7835b9b98cdb13e719c64bb30310d63e6cfbb8f8c02a.yml
3-
openapi_spec_hash: e1117a859f74f4c7d41a8aee21c433e8
1+
configured_endpoints: 12
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-13d3700bbf9ff52715f14809e3a297c6f76e956a19b86d51ddf27059d846d276.yml
3+
openapi_spec_hash: c4f9fe259a4f8f58114611fc6f87f4f2
44
config_hash: 9b9291a6c872b063900a46386729ba3c

README.md

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,6 @@ response = client.search.memories(
127127
print(response.include)
128128
```
129129

130-
## File uploads
131-
132-
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
133-
134-
```python
135-
from pathlib import Path
136-
from supermemory import Supermemory
137-
138-
client = Supermemory()
139-
140-
client.memories.upload_file(
141-
file=Path("/path/to/file"),
142-
)
143-
```
144-
145-
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
146-
147130
## Handling errors
148131

149132
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `supermemory.APIConnectionError` is raised.
@@ -160,8 +143,8 @@ from supermemory import Supermemory
160143
client = Supermemory()
161144

162145
try:
163-
client.memories.add(
164-
content="This is a detailed article about machine learning concepts...",
146+
client.search.documents(
147+
q="machine learning concepts",
165148
)
166149
except supermemory.APIConnectionError as e:
167150
print("The server could not be reached")
@@ -205,8 +188,8 @@ client = Supermemory(
205188
)
206189

207190
# Or, configure per-request:
208-
client.with_options(max_retries=5).memories.add(
209-
content="This is a detailed article about machine learning concepts...",
191+
client.with_options(max_retries=5).search.documents(
192+
q="machine learning concepts",
210193
)
211194
```
212195

@@ -230,8 +213,8 @@ client = Supermemory(
230213
)
231214

232215
# Override per-request:
233-
client.with_options(timeout=5.0).memories.add(
234-
content="This is a detailed article about machine learning concepts...",
216+
client.with_options(timeout=5.0).search.documents(
217+
q="machine learning concepts",
235218
)
236219
```
237220

@@ -273,13 +256,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
273256
from supermemory import Supermemory
274257

275258
client = Supermemory()
276-
response = client.memories.with_raw_response.add(
277-
content="This is a detailed article about machine learning concepts...",
259+
response = client.search.with_raw_response.documents(
260+
q="machine learning concepts",
278261
)
279262
print(response.headers.get('X-My-Header'))
280263

281-
memory = response.parse() # get the object that `memories.add()` would have returned
282-
print(memory.id)
264+
search = response.parse() # get the object that `search.documents()` would have returned
265+
print(search.results)
283266
```
284267

285268
These methods return an [`APIResponse`](https://github.com/supermemoryai/python-sdk/tree/main/src/supermemory/_response.py) object.
@@ -293,8 +276,8 @@ The above interface eagerly reads the full response body when you make the reque
293276
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.
294277

295278
```python
296-
with client.memories.with_streaming_response.add(
297-
content="This is a detailed article about machine learning concepts...",
279+
with client.search.with_streaming_response.documents(
280+
q="machine learning concepts",
298281
) as response:
299282
print(response.headers.get("X-My-Header"))
300283

api.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
# Memories
2-
3-
Types:
4-
5-
```python
6-
from supermemory.types import (
7-
MemoryUpdateResponse,
8-
MemoryListResponse,
9-
MemoryAddResponse,
10-
MemoryGetResponse,
11-
MemoryUploadFileResponse,
12-
)
13-
```
14-
15-
Methods:
16-
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>
18-
- <code title="post /v3/memories/list">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>
19-
- <code title="delete /v3/memories/{id}">client.memories.<a href="./src/supermemory/resources/memories.py">delete</a>(id) -> None</code>
20-
- <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>
21-
- <code title="get /v3/memories/{id}">client.memories.<a href="./src/supermemory/resources/memories.py">get</a>(id) -> <a href="./src/supermemory/types/memory_get_response.py">MemoryGetResponse</a></code>
22-
- <code title="post /v3/memories/file">client.memories.<a href="./src/supermemory/resources/memories.py">upload_file</a>(\*\*<a href="src/supermemory/types/memory_upload_file_params.py">params</a>) -> <a href="./src/supermemory/types/memory_upload_file_response.py">MemoryUploadFileResponse</a></code>
23-
241
# Search
252

263
Types:

src/supermemory/_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222
from ._utils import is_given, get_async_library
2323
from ._version import __version__
24-
from .resources import search, memories, settings, connections
24+
from .resources import search, settings, connections
2525
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2626
from ._exceptions import APIStatusError, SupermemoryError
2727
from ._base_client import (
@@ -43,7 +43,6 @@
4343

4444

4545
class Supermemory(SyncAPIClient):
46-
memories: memories.MemoriesResource
4746
search: search.SearchResource
4847
settings: settings.SettingsResource
4948
connections: connections.ConnectionsResource
@@ -104,7 +103,6 @@ def __init__(
104103
_strict_response_validation=_strict_response_validation,
105104
)
106105

107-
self.memories = memories.MemoriesResource(self)
108106
self.search = search.SearchResource(self)
109107
self.settings = settings.SettingsResource(self)
110108
self.connections = connections.ConnectionsResource(self)
@@ -217,7 +215,6 @@ def _make_status_error(
217215

218216

219217
class AsyncSupermemory(AsyncAPIClient):
220-
memories: memories.AsyncMemoriesResource
221218
search: search.AsyncSearchResource
222219
settings: settings.AsyncSettingsResource
223220
connections: connections.AsyncConnectionsResource
@@ -278,7 +275,6 @@ def __init__(
278275
_strict_response_validation=_strict_response_validation,
279276
)
280277

281-
self.memories = memories.AsyncMemoriesResource(self)
282278
self.search = search.AsyncSearchResource(self)
283279
self.settings = settings.AsyncSettingsResource(self)
284280
self.connections = connections.AsyncConnectionsResource(self)
@@ -392,31 +388,27 @@ def _make_status_error(
392388

393389
class SupermemoryWithRawResponse:
394390
def __init__(self, client: Supermemory) -> None:
395-
self.memories = memories.MemoriesResourceWithRawResponse(client.memories)
396391
self.search = search.SearchResourceWithRawResponse(client.search)
397392
self.settings = settings.SettingsResourceWithRawResponse(client.settings)
398393
self.connections = connections.ConnectionsResourceWithRawResponse(client.connections)
399394

400395

401396
class AsyncSupermemoryWithRawResponse:
402397
def __init__(self, client: AsyncSupermemory) -> None:
403-
self.memories = memories.AsyncMemoriesResourceWithRawResponse(client.memories)
404398
self.search = search.AsyncSearchResourceWithRawResponse(client.search)
405399
self.settings = settings.AsyncSettingsResourceWithRawResponse(client.settings)
406400
self.connections = connections.AsyncConnectionsResourceWithRawResponse(client.connections)
407401

408402

409403
class SupermemoryWithStreamedResponse:
410404
def __init__(self, client: Supermemory) -> None:
411-
self.memories = memories.MemoriesResourceWithStreamingResponse(client.memories)
412405
self.search = search.SearchResourceWithStreamingResponse(client.search)
413406
self.settings = settings.SettingsResourceWithStreamingResponse(client.settings)
414407
self.connections = connections.ConnectionsResourceWithStreamingResponse(client.connections)
415408

416409

417410
class AsyncSupermemoryWithStreamedResponse:
418411
def __init__(self, client: AsyncSupermemory) -> None:
419-
self.memories = memories.AsyncMemoriesResourceWithStreamingResponse(client.memories)
420412
self.search = search.AsyncSearchResourceWithStreamingResponse(client.search)
421413
self.settings = settings.AsyncSettingsResourceWithStreamingResponse(client.settings)
422414
self.connections = connections.AsyncConnectionsResourceWithStreamingResponse(client.connections)

src/supermemory/_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
3434
if not is_file_content(obj):
3535
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
3636
raise RuntimeError(
37-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/supermemoryai/python-sdk/tree/main#file-uploads"
37+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
3838
) from None
3939

4040

src/supermemory/resources/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
SearchResourceWithStreamingResponse,
99
AsyncSearchResourceWithStreamingResponse,
1010
)
11-
from .memories import (
12-
MemoriesResource,
13-
AsyncMemoriesResource,
14-
MemoriesResourceWithRawResponse,
15-
AsyncMemoriesResourceWithRawResponse,
16-
MemoriesResourceWithStreamingResponse,
17-
AsyncMemoriesResourceWithStreamingResponse,
18-
)
1911
from .settings import (
2012
SettingsResource,
2113
AsyncSettingsResource,
@@ -34,12 +26,6 @@
3426
)
3527

3628
__all__ = [
37-
"MemoriesResource",
38-
"AsyncMemoriesResource",
39-
"MemoriesResourceWithRawResponse",
40-
"AsyncMemoriesResourceWithRawResponse",
41-
"MemoriesResourceWithStreamingResponse",
42-
"AsyncMemoriesResourceWithStreamingResponse",
4329
"SearchResource",
4430
"AsyncSearchResource",
4531
"SearchResourceWithRawResponse",

0 commit comments

Comments
 (0)