You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-3Lines changed: 36 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ client = Supermemory(
32
32
api_key=os.environ.get("SUPERMEMORY_API_KEY"), # This is the default and can be omitted
33
33
)
34
34
35
-
response = client.search.execute(
35
+
response = client.search.documents(
36
36
q="documents related to python",
37
37
)
38
38
print(response.results)
@@ -58,7 +58,7 @@ client = AsyncSupermemory(
58
58
59
59
60
60
asyncdefmain() -> None:
61
-
response =await client.search.execute(
61
+
response =await client.search.documents(
62
62
q="documents related to python",
63
63
)
64
64
print(response.results)
@@ -93,7 +93,7 @@ async def main() -> None:
93
93
api_key="My API Key",
94
94
http_client=DefaultAioHttpClient(),
95
95
) as client:
96
-
response =await client.search.execute(
96
+
response =await client.search.documents(
97
97
q="documents related to python",
98
98
)
99
99
print(response.results)
@@ -111,6 +111,39 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
111
111
112
112
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
113
113
114
+
## Nested params
115
+
116
+
Nested parameters are dictionaries, typed using `TypedDict`, for example:
117
+
118
+
```python
119
+
from supermemory import Supermemory
120
+
121
+
client = Supermemory()
122
+
123
+
response = client.search.memories(
124
+
q="machine learning concepts",
125
+
include={},
126
+
)
127
+
print(response.include)
128
+
```
129
+
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
+
114
147
## Handling errors
115
148
116
149
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.
prefix=f"Expected entry at `{key}`"ifkeyisnotNoneelsef"Expected file input `{obj!r}`"
36
36
raiseRuntimeError(
37
-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
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"
0 commit comments