supermemory 0.1.0a1__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.
- supermemory/__init__.py +94 -0
- supermemory/_base_client.py +1943 -0
- supermemory/_client.py +427 -0
- supermemory/_compat.py +219 -0
- supermemory/_constants.py +14 -0
- supermemory/_exceptions.py +108 -0
- supermemory/_files.py +123 -0
- supermemory/_models.py +803 -0
- supermemory/_qs.py +150 -0
- supermemory/_resource.py +43 -0
- supermemory/_response.py +832 -0
- supermemory/_streaming.py +333 -0
- supermemory/_types.py +217 -0
- supermemory/_utils/__init__.py +57 -0
- supermemory/_utils/_logs.py +25 -0
- supermemory/_utils/_proxy.py +62 -0
- supermemory/_utils/_reflection.py +42 -0
- supermemory/_utils/_streams.py +12 -0
- supermemory/_utils/_sync.py +86 -0
- supermemory/_utils/_transform.py +447 -0
- supermemory/_utils/_typing.py +151 -0
- supermemory/_utils/_utils.py +422 -0
- supermemory/_version.py +4 -0
- supermemory/lib/.keep +4 -0
- supermemory/py.typed +0 -0
- supermemory/resources/__init__.py +61 -0
- supermemory/resources/connection.py +267 -0
- supermemory/resources/memory.py +487 -0
- supermemory/resources/search.py +254 -0
- supermemory/resources/settings.py +195 -0
- supermemory/types/__init__.py +16 -0
- supermemory/types/connection_create_params.py +15 -0
- supermemory/types/connection_create_response.py +13 -0
- supermemory/types/memory_create_params.py +23 -0
- supermemory/types/memory_create_response.py +11 -0
- supermemory/types/memory_delete_response.py +9 -0
- supermemory/types/memory_get_response.py +27 -0
- supermemory/types/memory_list_params.py +24 -0
- supermemory/types/memory_list_response.py +59 -0
- supermemory/types/search_execute_params.py +56 -0
- supermemory/types/search_execute_response.py +52 -0
- supermemory/types/setting_update_params.py +30 -0
- supermemory/types/setting_update_response.py +35 -0
- supermemory-0.1.0a1.dist-info/METADATA +376 -0
- supermemory-0.1.0a1.dist-info/RECORD +47 -0
- supermemory-0.1.0a1.dist-info/WHEEL +4 -0
- supermemory-0.1.0a1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing import Dict, List, Union, Iterable
|
6
|
+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
7
|
+
|
8
|
+
from .._utils import PropertyInfo
|
9
|
+
|
10
|
+
__all__ = ["SearchExecuteParams", "Filters", "FiltersUnionMember0"]
|
11
|
+
|
12
|
+
|
13
|
+
class SearchExecuteParams(TypedDict, total=False):
|
14
|
+
q: Required[str]
|
15
|
+
"""Search query string"""
|
16
|
+
|
17
|
+
categories_filter: Annotated[
|
18
|
+
List[Literal["technology", "science", "business", "health"]], PropertyInfo(alias="categoriesFilter")
|
19
|
+
]
|
20
|
+
"""Optional category filters"""
|
21
|
+
|
22
|
+
chunk_threshold: Annotated[float, PropertyInfo(alias="chunkThreshold")]
|
23
|
+
"""Maximum number of chunks to return"""
|
24
|
+
|
25
|
+
doc_id: Annotated[str, PropertyInfo(alias="docId")]
|
26
|
+
"""Optional document ID to search within"""
|
27
|
+
|
28
|
+
document_threshold: Annotated[float, PropertyInfo(alias="documentThreshold")]
|
29
|
+
"""Maximum number of documents to return"""
|
30
|
+
|
31
|
+
filters: Filters
|
32
|
+
"""Optional filters to apply to the search"""
|
33
|
+
|
34
|
+
include_summary: Annotated[bool, PropertyInfo(alias="includeSummary")]
|
35
|
+
"""If true, include document summary in the response.
|
36
|
+
|
37
|
+
This is helpful if you want a chatbot to know the context of the document.
|
38
|
+
"""
|
39
|
+
|
40
|
+
limit: int
|
41
|
+
"""Maximum number of results to return"""
|
42
|
+
|
43
|
+
only_matching_chunks: Annotated[bool, PropertyInfo(alias="onlyMatchingChunks")]
|
44
|
+
"""If true, only return matching chunks without context"""
|
45
|
+
|
46
|
+
user_id: Annotated[str, PropertyInfo(alias="userId")]
|
47
|
+
"""End user ID this search is associated with"""
|
48
|
+
|
49
|
+
|
50
|
+
class FiltersUnionMember0(TypedDict, total=False):
|
51
|
+
and_: Annotated[Iterable[object], PropertyInfo(alias="AND")]
|
52
|
+
|
53
|
+
or_: Annotated[Iterable[object], PropertyInfo(alias="OR")]
|
54
|
+
|
55
|
+
|
56
|
+
Filters: TypeAlias = Union[FiltersUnionMember0, Dict[str, object]]
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from typing import Dict, List, Optional
|
4
|
+
from datetime import datetime
|
5
|
+
|
6
|
+
from pydantic import Field as FieldInfo
|
7
|
+
|
8
|
+
from .._models import BaseModel
|
9
|
+
|
10
|
+
__all__ = ["SearchExecuteResponse", "Result", "ResultChunk"]
|
11
|
+
|
12
|
+
|
13
|
+
class ResultChunk(BaseModel):
|
14
|
+
content: str
|
15
|
+
"""Content of the matching chunk"""
|
16
|
+
|
17
|
+
is_relevant: bool = FieldInfo(alias="isRelevant")
|
18
|
+
"""Whether this chunk is relevant to the query"""
|
19
|
+
|
20
|
+
score: float
|
21
|
+
"""Similarity score for this chunk"""
|
22
|
+
|
23
|
+
|
24
|
+
class Result(BaseModel):
|
25
|
+
chunks: List[ResultChunk]
|
26
|
+
"""Matching content chunks from the document"""
|
27
|
+
|
28
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
29
|
+
"""Document creation date"""
|
30
|
+
|
31
|
+
document_id: str = FieldInfo(alias="documentId")
|
32
|
+
"""ID of the matching document"""
|
33
|
+
|
34
|
+
metadata: Optional[Dict[str, object]] = None
|
35
|
+
"""Document metadata"""
|
36
|
+
|
37
|
+
score: float
|
38
|
+
"""Relevance score of the match"""
|
39
|
+
|
40
|
+
title: str
|
41
|
+
"""Document title"""
|
42
|
+
|
43
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
44
|
+
"""Document last update date"""
|
45
|
+
|
46
|
+
|
47
|
+
class SearchExecuteResponse(BaseModel):
|
48
|
+
results: List[Result]
|
49
|
+
|
50
|
+
timing: float
|
51
|
+
|
52
|
+
total: float
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
from typing import List, Iterable
|
6
|
+
from typing_extensions import Required, Annotated, TypedDict
|
7
|
+
|
8
|
+
from .._utils import PropertyInfo
|
9
|
+
|
10
|
+
__all__ = ["SettingUpdateParams", "FilterTag"]
|
11
|
+
|
12
|
+
|
13
|
+
class SettingUpdateParams(TypedDict, total=False):
|
14
|
+
categories: List[str]
|
15
|
+
|
16
|
+
exclude_items: Annotated[List[str], PropertyInfo(alias="excludeItems")]
|
17
|
+
|
18
|
+
filter_prompt: Annotated[str, PropertyInfo(alias="filterPrompt")]
|
19
|
+
|
20
|
+
filter_tags: Annotated[Iterable[FilterTag], PropertyInfo(alias="filterTags")]
|
21
|
+
|
22
|
+
include_items: Annotated[List[str], PropertyInfo(alias="includeItems")]
|
23
|
+
|
24
|
+
should_llm_filter: Annotated[bool, PropertyInfo(alias="shouldLLMFilter")]
|
25
|
+
|
26
|
+
|
27
|
+
class FilterTag(TypedDict, total=False):
|
28
|
+
score: Required[float]
|
29
|
+
|
30
|
+
tag: Required[str]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from typing import List, Optional
|
4
|
+
|
5
|
+
from pydantic import Field as FieldInfo
|
6
|
+
|
7
|
+
from .._models import BaseModel
|
8
|
+
|
9
|
+
__all__ = ["SettingUpdateResponse", "Settings", "SettingsFilterTag"]
|
10
|
+
|
11
|
+
|
12
|
+
class SettingsFilterTag(BaseModel):
|
13
|
+
score: float
|
14
|
+
|
15
|
+
tag: str
|
16
|
+
|
17
|
+
|
18
|
+
class Settings(BaseModel):
|
19
|
+
categories: Optional[List[str]] = None
|
20
|
+
|
21
|
+
exclude_items: Optional[List[str]] = FieldInfo(alias="excludeItems", default=None)
|
22
|
+
|
23
|
+
filter_prompt: Optional[str] = FieldInfo(alias="filterPrompt", default=None)
|
24
|
+
|
25
|
+
filter_tags: Optional[List[SettingsFilterTag]] = FieldInfo(alias="filterTags", default=None)
|
26
|
+
|
27
|
+
include_items: Optional[List[str]] = FieldInfo(alias="includeItems", default=None)
|
28
|
+
|
29
|
+
should_llm_filter: Optional[bool] = FieldInfo(alias="shouldLLMFilter", default=None)
|
30
|
+
|
31
|
+
|
32
|
+
class SettingUpdateResponse(BaseModel):
|
33
|
+
message: str
|
34
|
+
|
35
|
+
settings: Settings
|
@@ -0,0 +1,376 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: supermemory
|
3
|
+
Version: 0.1.0a1
|
4
|
+
Summary: The official Python library for the supermemory API
|
5
|
+
Project-URL: Homepage, https://github.com/supermemoryai/python-sdk
|
6
|
+
Project-URL: Repository, https://github.com/supermemoryai/python-sdk
|
7
|
+
Author-email: Supermemory <dhravya@supermemory.com>
|
8
|
+
License: Apache-2.0
|
9
|
+
Classifier: Intended Audience :: Developers
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
11
|
+
Classifier: Operating System :: MacOS
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
13
|
+
Classifier: Operating System :: OS Independent
|
14
|
+
Classifier: Operating System :: POSIX
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
22
|
+
Classifier: Typing :: Typed
|
23
|
+
Requires-Python: >=3.8
|
24
|
+
Requires-Dist: anyio<5,>=3.5.0
|
25
|
+
Requires-Dist: distro<2,>=1.7.0
|
26
|
+
Requires-Dist: httpx<1,>=0.23.0
|
27
|
+
Requires-Dist: pydantic<3,>=1.9.0
|
28
|
+
Requires-Dist: sniffio
|
29
|
+
Requires-Dist: typing-extensions<5,>=4.10
|
30
|
+
Description-Content-Type: text/markdown
|
31
|
+
|
32
|
+
# Supermemory Python API library
|
33
|
+
|
34
|
+
[](https://pypi.org/project/supermemory/)
|
35
|
+
|
36
|
+
The Supermemory Python library provides convenient access to the Supermemory REST API from any Python 3.8+
|
37
|
+
application. The library includes type definitions for all request params and response fields,
|
38
|
+
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
|
39
|
+
|
40
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
41
|
+
|
42
|
+
## Documentation
|
43
|
+
|
44
|
+
The REST API documentation can be found on [docs.supermemory.com](https://docs.supermemory.com). The full API of this library can be found in [api.md](https://github.com/supermemoryai/python-sdk/tree/main/api.md).
|
45
|
+
|
46
|
+
## Installation
|
47
|
+
|
48
|
+
```sh
|
49
|
+
# install from PyPI
|
50
|
+
pip install --pre supermemory
|
51
|
+
```
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
The full API of this library can be found in [api.md](https://github.com/supermemoryai/python-sdk/tree/main/api.md).
|
56
|
+
|
57
|
+
```python
|
58
|
+
import os
|
59
|
+
from supermemory import Supermemory
|
60
|
+
|
61
|
+
client = Supermemory(
|
62
|
+
api_key=os.environ.get("SUPERMEMORY_API_KEY"), # This is the default and can be omitted
|
63
|
+
)
|
64
|
+
|
65
|
+
response = client.search.execute(
|
66
|
+
q="documents related to python",
|
67
|
+
)
|
68
|
+
print(response.results)
|
69
|
+
```
|
70
|
+
|
71
|
+
While you can provide an `api_key` keyword argument,
|
72
|
+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
73
|
+
to add `SUPERMEMORY_API_KEY="My API Key"` to your `.env` file
|
74
|
+
so that your API Key is not stored in source control.
|
75
|
+
|
76
|
+
## Async usage
|
77
|
+
|
78
|
+
Simply import `AsyncSupermemory` instead of `Supermemory` and use `await` with each API call:
|
79
|
+
|
80
|
+
```python
|
81
|
+
import os
|
82
|
+
import asyncio
|
83
|
+
from supermemory import AsyncSupermemory
|
84
|
+
|
85
|
+
client = AsyncSupermemory(
|
86
|
+
api_key=os.environ.get("SUPERMEMORY_API_KEY"), # This is the default and can be omitted
|
87
|
+
)
|
88
|
+
|
89
|
+
|
90
|
+
async def main() -> None:
|
91
|
+
response = await client.search.execute(
|
92
|
+
q="documents related to python",
|
93
|
+
)
|
94
|
+
print(response.results)
|
95
|
+
|
96
|
+
|
97
|
+
asyncio.run(main())
|
98
|
+
```
|
99
|
+
|
100
|
+
Functionality between the synchronous and asynchronous clients is otherwise identical.
|
101
|
+
|
102
|
+
## Using types
|
103
|
+
|
104
|
+
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
|
105
|
+
|
106
|
+
- Serializing back into JSON, `model.to_json()`
|
107
|
+
- Converting to a dictionary, `model.to_dict()`
|
108
|
+
|
109
|
+
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`.
|
110
|
+
|
111
|
+
## Handling errors
|
112
|
+
|
113
|
+
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.
|
114
|
+
|
115
|
+
When the API returns a non-success status code (that is, 4xx or 5xx
|
116
|
+
response), a subclass of `supermemory.APIStatusError` is raised, containing `status_code` and `response` properties.
|
117
|
+
|
118
|
+
All errors inherit from `supermemory.APIError`.
|
119
|
+
|
120
|
+
```python
|
121
|
+
import supermemory
|
122
|
+
from supermemory import Supermemory
|
123
|
+
|
124
|
+
client = Supermemory()
|
125
|
+
|
126
|
+
try:
|
127
|
+
client.memory.create(
|
128
|
+
content="This is a detailed article about machine learning concepts...",
|
129
|
+
)
|
130
|
+
except supermemory.APIConnectionError as e:
|
131
|
+
print("The server could not be reached")
|
132
|
+
print(e.__cause__) # an underlying Exception, likely raised within httpx.
|
133
|
+
except supermemory.RateLimitError as e:
|
134
|
+
print("A 429 status code was received; we should back off a bit.")
|
135
|
+
except supermemory.APIStatusError as e:
|
136
|
+
print("Another non-200-range status code was received")
|
137
|
+
print(e.status_code)
|
138
|
+
print(e.response)
|
139
|
+
```
|
140
|
+
|
141
|
+
Error codes are as follows:
|
142
|
+
|
143
|
+
| Status Code | Error Type |
|
144
|
+
| ----------- | -------------------------- |
|
145
|
+
| 400 | `BadRequestError` |
|
146
|
+
| 401 | `AuthenticationError` |
|
147
|
+
| 403 | `PermissionDeniedError` |
|
148
|
+
| 404 | `NotFoundError` |
|
149
|
+
| 422 | `UnprocessableEntityError` |
|
150
|
+
| 429 | `RateLimitError` |
|
151
|
+
| >=500 | `InternalServerError` |
|
152
|
+
| N/A | `APIConnectionError` |
|
153
|
+
|
154
|
+
### Retries
|
155
|
+
|
156
|
+
Certain errors are automatically retried 2 times by default, with a short exponential backoff.
|
157
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
158
|
+
429 Rate Limit, and >=500 Internal errors are all retried by default.
|
159
|
+
|
160
|
+
You can use the `max_retries` option to configure or disable retry settings:
|
161
|
+
|
162
|
+
```python
|
163
|
+
from supermemory import Supermemory
|
164
|
+
|
165
|
+
# Configure the default for all requests:
|
166
|
+
client = Supermemory(
|
167
|
+
# default is 2
|
168
|
+
max_retries=0,
|
169
|
+
)
|
170
|
+
|
171
|
+
# Or, configure per-request:
|
172
|
+
client.with_options(max_retries=5).memory.create(
|
173
|
+
content="This is a detailed article about machine learning concepts...",
|
174
|
+
)
|
175
|
+
```
|
176
|
+
|
177
|
+
### Timeouts
|
178
|
+
|
179
|
+
By default requests time out after 1 minute. You can configure this with a `timeout` option,
|
180
|
+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
|
181
|
+
|
182
|
+
```python
|
183
|
+
from supermemory import Supermemory
|
184
|
+
|
185
|
+
# Configure the default for all requests:
|
186
|
+
client = Supermemory(
|
187
|
+
# 20 seconds (default is 1 minute)
|
188
|
+
timeout=20.0,
|
189
|
+
)
|
190
|
+
|
191
|
+
# More granular control:
|
192
|
+
client = Supermemory(
|
193
|
+
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
|
194
|
+
)
|
195
|
+
|
196
|
+
# Override per-request:
|
197
|
+
client.with_options(timeout=5.0).memory.create(
|
198
|
+
content="This is a detailed article about machine learning concepts...",
|
199
|
+
)
|
200
|
+
```
|
201
|
+
|
202
|
+
On timeout, an `APITimeoutError` is thrown.
|
203
|
+
|
204
|
+
Note that requests that time out are [retried twice by default](https://github.com/supermemoryai/python-sdk/tree/main/#retries).
|
205
|
+
|
206
|
+
## Advanced
|
207
|
+
|
208
|
+
### Logging
|
209
|
+
|
210
|
+
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
|
211
|
+
|
212
|
+
You can enable logging by setting the environment variable `SUPERMEMORY_LOG` to `info`.
|
213
|
+
|
214
|
+
```shell
|
215
|
+
$ export SUPERMEMORY_LOG=info
|
216
|
+
```
|
217
|
+
|
218
|
+
Or to `debug` for more verbose logging.
|
219
|
+
|
220
|
+
### How to tell whether `None` means `null` or missing
|
221
|
+
|
222
|
+
In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
|
223
|
+
|
224
|
+
```py
|
225
|
+
if response.my_field is None:
|
226
|
+
if 'my_field' not in response.model_fields_set:
|
227
|
+
print('Got json like {}, without a "my_field" key present at all.')
|
228
|
+
else:
|
229
|
+
print('Got json like {"my_field": null}.')
|
230
|
+
```
|
231
|
+
|
232
|
+
### Accessing raw response data (e.g. headers)
|
233
|
+
|
234
|
+
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
|
235
|
+
|
236
|
+
```py
|
237
|
+
from supermemory import Supermemory
|
238
|
+
|
239
|
+
client = Supermemory()
|
240
|
+
response = client.memory.with_raw_response.create(
|
241
|
+
content="This is a detailed article about machine learning concepts...",
|
242
|
+
)
|
243
|
+
print(response.headers.get('X-My-Header'))
|
244
|
+
|
245
|
+
memory = response.parse() # get the object that `memory.create()` would have returned
|
246
|
+
print(memory.id)
|
247
|
+
```
|
248
|
+
|
249
|
+
These methods return an [`APIResponse`](https://github.com/supermemoryai/python-sdk/tree/main/src/supermemory/_response.py) object.
|
250
|
+
|
251
|
+
The async client returns an [`AsyncAPIResponse`](https://github.com/supermemoryai/python-sdk/tree/main/src/supermemory/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
|
252
|
+
|
253
|
+
#### `.with_streaming_response`
|
254
|
+
|
255
|
+
The above interface eagerly reads the full response body when you make the request, which may not always be what you want.
|
256
|
+
|
257
|
+
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.
|
258
|
+
|
259
|
+
```python
|
260
|
+
with client.memory.with_streaming_response.create(
|
261
|
+
content="This is a detailed article about machine learning concepts...",
|
262
|
+
) as response:
|
263
|
+
print(response.headers.get("X-My-Header"))
|
264
|
+
|
265
|
+
for line in response.iter_lines():
|
266
|
+
print(line)
|
267
|
+
```
|
268
|
+
|
269
|
+
The context manager is required so that the response will reliably be closed.
|
270
|
+
|
271
|
+
### Making custom/undocumented requests
|
272
|
+
|
273
|
+
This library is typed for convenient access to the documented API.
|
274
|
+
|
275
|
+
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
|
276
|
+
|
277
|
+
#### Undocumented endpoints
|
278
|
+
|
279
|
+
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
|
280
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
281
|
+
|
282
|
+
```py
|
283
|
+
import httpx
|
284
|
+
|
285
|
+
response = client.post(
|
286
|
+
"/foo",
|
287
|
+
cast_to=httpx.Response,
|
288
|
+
body={"my_param": True},
|
289
|
+
)
|
290
|
+
|
291
|
+
print(response.headers.get("x-foo"))
|
292
|
+
```
|
293
|
+
|
294
|
+
#### Undocumented request params
|
295
|
+
|
296
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
|
297
|
+
options.
|
298
|
+
|
299
|
+
#### Undocumented response properties
|
300
|
+
|
301
|
+
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
|
302
|
+
can also get all the extra fields on the Pydantic model as a dict with
|
303
|
+
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
|
304
|
+
|
305
|
+
### Configuring the HTTP client
|
306
|
+
|
307
|
+
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
|
308
|
+
|
309
|
+
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
|
310
|
+
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
|
311
|
+
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
|
312
|
+
|
313
|
+
```python
|
314
|
+
import httpx
|
315
|
+
from supermemory import Supermemory, DefaultHttpxClient
|
316
|
+
|
317
|
+
client = Supermemory(
|
318
|
+
# Or use the `SUPERMEMORY_BASE_URL` env var
|
319
|
+
base_url="http://my.test.server.example.com:8083",
|
320
|
+
http_client=DefaultHttpxClient(
|
321
|
+
proxy="http://my.test.proxy.example.com",
|
322
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
323
|
+
),
|
324
|
+
)
|
325
|
+
```
|
326
|
+
|
327
|
+
You can also customize the client on a per-request basis by using `with_options()`:
|
328
|
+
|
329
|
+
```python
|
330
|
+
client.with_options(http_client=DefaultHttpxClient(...))
|
331
|
+
```
|
332
|
+
|
333
|
+
### Managing HTTP resources
|
334
|
+
|
335
|
+
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
|
336
|
+
|
337
|
+
```py
|
338
|
+
from supermemory import Supermemory
|
339
|
+
|
340
|
+
with Supermemory() as client:
|
341
|
+
# make requests here
|
342
|
+
...
|
343
|
+
|
344
|
+
# HTTP client is now closed
|
345
|
+
```
|
346
|
+
|
347
|
+
## Versioning
|
348
|
+
|
349
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
350
|
+
|
351
|
+
1. Changes that only affect static types, without breaking runtime behavior.
|
352
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
353
|
+
3. Changes that we do not expect to impact the vast majority of users in practice.
|
354
|
+
|
355
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
356
|
+
|
357
|
+
We are keen for your feedback; please open an [issue](https://www.github.com/supermemoryai/python-sdk/issues) with questions, bugs, or suggestions.
|
358
|
+
|
359
|
+
### Determining the installed version
|
360
|
+
|
361
|
+
If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.
|
362
|
+
|
363
|
+
You can determine the version that is being used at runtime with:
|
364
|
+
|
365
|
+
```py
|
366
|
+
import supermemory
|
367
|
+
print(supermemory.__version__)
|
368
|
+
```
|
369
|
+
|
370
|
+
## Requirements
|
371
|
+
|
372
|
+
Python 3.8 or higher.
|
373
|
+
|
374
|
+
## Contributing
|
375
|
+
|
376
|
+
See [the contributing documentation](https://github.com/supermemoryai/python-sdk/tree/main/./CONTRIBUTING.md).
|
@@ -0,0 +1,47 @@
|
|
1
|
+
supermemory/__init__.py,sha256=zmdpovY5xGPUklfTkFT_KJkaLs5W9DZ3fVG2EDMWIXA,2503
|
2
|
+
supermemory/_base_client.py,sha256=9HYnqL_kzsVgh2Ju7mJ3ODnE6lr-ITvlAsN1orWPyrE,64849
|
3
|
+
supermemory/_client.py,sha256=CZKei9ZiIUQm_D9cfvdRL3TBmywARU8U8lN97UpfZaI,16777
|
4
|
+
supermemory/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
|
5
|
+
supermemory/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
6
|
+
supermemory/_exceptions.py,sha256=5nnX7W8L_eA6LkX3SBl7csJy5d9QEcDqRVuwDq8wVh8,3230
|
7
|
+
supermemory/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
|
8
|
+
supermemory/_models.py,sha256=mB2r2VWQq49jG-F0RIXDrBxPp3v-Eg12wMOtVTNxtv4,29057
|
9
|
+
supermemory/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
10
|
+
supermemory/_resource.py,sha256=_wuaB1exMy-l-qqdJJdTv15hH5qBSN2Rj9CFwjXTZJU,1130
|
11
|
+
supermemory/_response.py,sha256=Yh869-U8INkojKZHFsNw69z5Y2BrK2isgRJ8mifEURM,28848
|
12
|
+
supermemory/_streaming.py,sha256=MGbosxSTqq0_JG52hvH2Z-Mr_Y95ws5UdFw77_iYukc,10120
|
13
|
+
supermemory/_types.py,sha256=l9FVOIsfa8FG9tbvxFBA1mj_yLc5ibf1niQ8xecMYdY,6148
|
14
|
+
supermemory/_version.py,sha256=yL5hpU0Q4na57UkkEOGFiZI4tWBdExc1T2LnhLSkaQA,171
|
15
|
+
supermemory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
+
supermemory/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
|
17
|
+
supermemory/_utils/_logs.py,sha256=iceljYaEUb4Q4q1SgbSzwSrlJA64ISbaccczzZ8Z9Vg,789
|
18
|
+
supermemory/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
|
19
|
+
supermemory/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
|
20
|
+
supermemory/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
|
21
|
+
supermemory/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
|
22
|
+
supermemory/_utils/_transform.py,sha256=n7kskEWz6o__aoNvhFoGVyDoalNe6mJwp-g7BWkdj88,15617
|
23
|
+
supermemory/_utils/_typing.py,sha256=D0DbbNu8GnYQTSICnTSHDGsYXj8TcAKyhejb0XcnjtY,4602
|
24
|
+
supermemory/_utils/_utils.py,sha256=ts4CiiuNpFiGB6YMdkQRh2SZvYvsl7mAF-JWHCcLDf4,12312
|
25
|
+
supermemory/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
26
|
+
supermemory/resources/__init__.py,sha256=dx0g3SAuMRAeRsNdMWR4Wtna-6UKmhSbh-iOFEAcJI4,1980
|
27
|
+
supermemory/resources/connection.py,sha256=uzsEXN02BVJgbzN289qCmPYqDW-4BanY6eb8CYWOTXU,10017
|
28
|
+
supermemory/resources/memory.py,sha256=DU5i4Ftgh2o2anu6exptosd58d5g2PZGvvFzg3MxJqc,17362
|
29
|
+
supermemory/resources/search.py,sha256=Qe0GMFVTsDMg7CCtffK4NL-7I_AYccuL25u0nzbfMUI,9536
|
30
|
+
supermemory/resources/settings.py,sha256=VKqzCi7e4z6hJuNfwr0zW1kFzhWKGkCZdlDwQKfiyg4,7392
|
31
|
+
supermemory/types/__init__.py,sha256=CMR0HNDklN-fOm6r0-WQQfRTrwc1yqdpDCLHdm-xkvo,1080
|
32
|
+
supermemory/types/connection_create_params.py,sha256=NVHZ152C3ioga5on597HRYAM7HBsK0T4AGua2V5R0qE,404
|
33
|
+
supermemory/types/connection_create_response.py,sha256=jSshnS9cEjZSzucWNIgEe3Xna_NSb71oHCUSDpihJYU,348
|
34
|
+
supermemory/types/memory_create_params.py,sha256=sgK_rNTI1NyHN9Kkb7-OTe0XoAeGSDJCnyDEsLh69dg,614
|
35
|
+
supermemory/types/memory_create_response.py,sha256=zPcyrKM1aYK62tjGLWGn9g-K_svhgHBobKQoS99dNxc,225
|
36
|
+
supermemory/types/memory_delete_response.py,sha256=1kb_ExXPaaZLyuv4-fQuumBamTPklFrpvMv0ZHhZf2U,214
|
37
|
+
supermemory/types/memory_get_response.py,sha256=qb_D77eNJJ1v07I0Dpu-vh3YKAndcEWeNg3oQvlCI60,565
|
38
|
+
supermemory/types/memory_list_params.py,sha256=kjyYz3NcnjgKzE-g442lQ1kyIsAtMMXQG-baLHvJ4KU,546
|
39
|
+
supermemory/types/memory_list_response.py,sha256=W9NyBc1hWew9fgyslHKuIy2SCQxi7cXRKa4qd3f0V8Q,1544
|
40
|
+
supermemory/types/search_execute_params.py,sha256=WOw_Ijj1IxCmEU3O0zQzbmj1ud-DVgVop7UoKBALvew,1870
|
41
|
+
supermemory/types/search_execute_response.py,sha256=Z0T76z1xKA7bdKZ96kyXTOkiMRk7TzUHYKEdR6VNcHw,1216
|
42
|
+
supermemory/types/setting_update_params.py,sha256=P7P0mZsGRtM-zEhAQNaYxssJZsToK1YGPHUvqWgrqWo,861
|
43
|
+
supermemory/types/setting_update_response.py,sha256=R3PR04k_DoYkcM54UqHjI_vP7G6AvThoSd4lcyZjDoE,935
|
44
|
+
supermemory-0.1.0a1.dist-info/METADATA,sha256=t4wQ5u7EdrjoyzV8vJysE_SneJKiJrRTkkXPM3GhP0Q,13174
|
45
|
+
supermemory-0.1.0a1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
46
|
+
supermemory-0.1.0a1.dist-info/licenses/LICENSE,sha256=M2NcpYEBpakciOULpWzo-xO2Lincf74gGwfaU00Sct0,11341
|
47
|
+
supermemory-0.1.0a1.dist-info/RECORD,,
|