Skip to content

Commit db788d6

Browse files
stainless-app[bot]Dhravya
authored andcommitted
feat(api): manual updates
1 parent 3464f92 commit db788d6

File tree

9 files changed

+292
-26
lines changed

9 files changed

+292
-26
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 19
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-ebd5e757d0e76cb83013e01a1e0bb3dba62beb83b2a2ffa28d148ea032e96fd0.yml
33
openapi_spec_hash: f930474a6ad230545154244045cc602e
4-
config_hash: 23f1770611dec274363355d52f3918cc
4+
config_hash: ec08a36e60458b4d83e71798a8043484

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ from supermemory import Supermemory
160160
client = Supermemory()
161161

162162
try:
163-
client.memories.add(
163+
client.add(
164164
content="content",
165165
)
166166
except supermemory.APIConnectionError as e:
@@ -205,7 +205,7 @@ client = Supermemory(
205205
)
206206

207207
# Or, configure per-request:
208-
client.with_options(max_retries=5).memories.add(
208+
client.with_options(max_retries=5).add(
209209
content="content",
210210
)
211211
```
@@ -230,7 +230,7 @@ client = Supermemory(
230230
)
231231

232232
# Override per-request:
233-
client.with_options(timeout=5.0).memories.add(
233+
client.with_options(timeout=5.0).add(
234234
content="content",
235235
)
236236
```
@@ -273,13 +273,13 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
273273
from supermemory import Supermemory
274274

275275
client = Supermemory()
276-
response = client.memories.with_raw_response.add(
276+
response = client.with_raw_response.add(
277277
content="content",
278278
)
279279
print(response.headers.get('X-My-Header'))
280280

281-
memory = response.parse() # get the object that `memories.add()` would have returned
282-
print(memory.id)
281+
client = response.parse() # get the object that `add()` would have returned
282+
print(client.id)
283283
```
284284

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

295295
```python
296-
with client.memories.with_streaming_response.add(
296+
with client.with_streaming_response.add(
297297
content="content",
298298
) as response:
299299
print(response.headers.get("X-My-Header"))

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
Types:
44

55
```python
6-
from supermemory.types import ProfileResponse
6+
from supermemory.types import AddResponse, ProfileResponse
77
```
88

99
Methods:
1010

11+
- <code title="post /v3/documents">client.<a href="./src/supermemory/_client.py">add</a>(\*\*<a href="src/supermemory/types/client_add_params.py">params</a>) -> <a href="./src/supermemory/types/add_response.py">AddResponse</a></code>
1112
- <code title="post /v4/profile">client.<a href="./src/supermemory/_client.py">profile</a>(\*\*<a href="src/supermemory/types/client_profile_params.py">params</a>) -> <a href="./src/supermemory/types/profile_response.py">ProfileResponse</a></code>
1213

1314
# Memories

src/supermemory/_client.py

Lines changed: 128 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from __future__ import annotations
44

55
import os
6-
from typing import Any, Mapping
6+
from typing import Any, Dict, Union, Mapping
77
from typing_extensions import Self, override
88

99
import httpx
1010

1111
from . import _exceptions
1212
from ._qs import Querystring
13-
from .types import client_profile_params
13+
from .types import client_add_params, client_profile_params
1414
from ._types import (
1515
Body,
1616
Omit,
@@ -21,6 +21,7 @@
2121
Transport,
2222
ProxiesTypes,
2323
RequestOptions,
24+
SequenceNotStr,
2425
omit,
2526
not_given,
2627
)
@@ -46,6 +47,7 @@
4647
AsyncAPIClient,
4748
make_request_options,
4849
)
50+
from .types.add_response import AddResponse
4951
from .types.profile_response import ProfileResponse
5052

5153
__all__ = [
@@ -202,6 +204,62 @@ def copy(
202204
# client.with_options(timeout=10).foo.create(...)
203205
with_options = copy
204206

207+
def add(
208+
self,
209+
*,
210+
content: str,
211+
container_tag: str | Omit = omit,
212+
container_tags: SequenceNotStr[str] | Omit = omit,
213+
custom_id: str | Omit = omit,
214+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
215+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
216+
# The extra values given here take precedence over values defined on the client or passed to this method.
217+
extra_headers: Headers | None = None,
218+
extra_query: Query | None = None,
219+
extra_body: Body | None = None,
220+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
221+
) -> AddResponse:
222+
"""
223+
Add a document with any content type (text, url, file, etc.) and metadata
224+
225+
Args:
226+
content: The content to extract and process into a document. This can be a URL to a
227+
website, a PDF, an image, or a video.
228+
229+
container_tag: Optional tag this document should be containerized by. Max 100 characters,
230+
alphanumeric with hyphens and underscores only.
231+
232+
custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
233+
hyphens and underscores only.
234+
235+
metadata: Optional metadata for the document.
236+
237+
extra_headers: Send extra headers
238+
239+
extra_query: Add additional query parameters to the request
240+
241+
extra_body: Add additional JSON properties to the request
242+
243+
timeout: Override the client-level default timeout for this request, in seconds
244+
"""
245+
return self.post(
246+
"/v3/documents",
247+
body=maybe_transform(
248+
{
249+
"content": content,
250+
"container_tag": container_tag,
251+
"container_tags": container_tags,
252+
"custom_id": custom_id,
253+
"metadata": metadata,
254+
},
255+
client_add_params.ClientAddParams,
256+
),
257+
options=make_request_options(
258+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
259+
),
260+
cast_to=AddResponse,
261+
)
262+
205263
def profile(
206264
self,
207265
*,
@@ -422,6 +480,62 @@ def copy(
422480
# client.with_options(timeout=10).foo.create(...)
423481
with_options = copy
424482

483+
async def add(
484+
self,
485+
*,
486+
content: str,
487+
container_tag: str | Omit = omit,
488+
container_tags: SequenceNotStr[str] | Omit = omit,
489+
custom_id: str | Omit = omit,
490+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | Omit = omit,
491+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
492+
# The extra values given here take precedence over values defined on the client or passed to this method.
493+
extra_headers: Headers | None = None,
494+
extra_query: Query | None = None,
495+
extra_body: Body | None = None,
496+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
497+
) -> AddResponse:
498+
"""
499+
Add a document with any content type (text, url, file, etc.) and metadata
500+
501+
Args:
502+
content: The content to extract and process into a document. This can be a URL to a
503+
website, a PDF, an image, or a video.
504+
505+
container_tag: Optional tag this document should be containerized by. Max 100 characters,
506+
alphanumeric with hyphens and underscores only.
507+
508+
custom_id: Optional custom ID of the document. Max 100 characters, alphanumeric with
509+
hyphens and underscores only.
510+
511+
metadata: Optional metadata for the document.
512+
513+
extra_headers: Send extra headers
514+
515+
extra_query: Add additional query parameters to the request
516+
517+
extra_body: Add additional JSON properties to the request
518+
519+
timeout: Override the client-level default timeout for this request, in seconds
520+
"""
521+
return await self.post(
522+
"/v3/documents",
523+
body=await async_maybe_transform(
524+
{
525+
"content": content,
526+
"container_tag": container_tag,
527+
"container_tags": container_tags,
528+
"custom_id": custom_id,
529+
"metadata": metadata,
530+
},
531+
client_add_params.ClientAddParams,
532+
),
533+
options=make_request_options(
534+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
535+
),
536+
cast_to=AddResponse,
537+
)
538+
425539
async def profile(
426540
self,
427541
*,
@@ -508,6 +622,9 @@ def __init__(self, client: Supermemory) -> None:
508622
self.settings = settings.SettingsResourceWithRawResponse(client.settings)
509623
self.connections = connections.ConnectionsResourceWithRawResponse(client.connections)
510624

625+
self.add = to_raw_response_wrapper(
626+
client.add,
627+
)
511628
self.profile = to_raw_response_wrapper(
512629
client.profile,
513630
)
@@ -521,6 +638,9 @@ def __init__(self, client: AsyncSupermemory) -> None:
521638
self.settings = settings.AsyncSettingsResourceWithRawResponse(client.settings)
522639
self.connections = connections.AsyncConnectionsResourceWithRawResponse(client.connections)
523640

641+
self.add = async_to_raw_response_wrapper(
642+
client.add,
643+
)
524644
self.profile = async_to_raw_response_wrapper(
525645
client.profile,
526646
)
@@ -534,6 +654,9 @@ def __init__(self, client: Supermemory) -> None:
534654
self.settings = settings.SettingsResourceWithStreamingResponse(client.settings)
535655
self.connections = connections.ConnectionsResourceWithStreamingResponse(client.connections)
536656

657+
self.add = to_streamed_response_wrapper(
658+
client.add,
659+
)
537660
self.profile = to_streamed_response_wrapper(
538661
client.profile,
539662
)
@@ -547,6 +670,9 @@ def __init__(self, client: AsyncSupermemory) -> None:
547670
self.settings = settings.AsyncSettingsResourceWithStreamingResponse(client.settings)
548671
self.connections = connections.AsyncConnectionsResourceWithStreamingResponse(client.connections)
549672

673+
self.add = async_to_streamed_response_wrapper(
674+
client.add,
675+
)
550676
self.profile = async_to_streamed_response_wrapper(
551677
client.profile,
552678
)

src/supermemory/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from __future__ import annotations
44

5+
from .add_response import AddResponse as AddResponse
56
from .profile_response import ProfileResponse as ProfileResponse
7+
from .client_add_params import ClientAddParams as ClientAddParams
68
from .memory_add_params import MemoryAddParams as MemoryAddParams
79
from .memory_list_params import MemoryListParams as MemoryListParams
810
from .document_add_params import DocumentAddParams as DocumentAddParams
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .._models import BaseModel
4+
5+
__all__ = ["AddResponse"]
6+
7+
8+
class AddResponse(BaseModel):
9+
id: str
10+
"""Unique identifier of the document"""
11+
12+
status: str
13+
"""Status of the document"""
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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, Union
6+
from typing_extensions import Required, Annotated, TypedDict
7+
8+
from .._types import SequenceNotStr
9+
from .._utils import PropertyInfo
10+
11+
__all__ = ["ClientAddParams"]
12+
13+
14+
class ClientAddParams(TypedDict, total=False):
15+
content: Required[str]
16+
"""The content to extract and process into a document.
17+
18+
This can be a URL to a website, a PDF, an image, or a video.
19+
"""
20+
21+
container_tag: Annotated[str, PropertyInfo(alias="containerTag")]
22+
"""Optional tag this document should be containerized by.
23+
24+
Max 100 characters, alphanumeric with hyphens and underscores only.
25+
"""
26+
27+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
28+
29+
custom_id: Annotated[str, PropertyInfo(alias="customId")]
30+
"""Optional custom ID of the document.
31+
32+
Max 100 characters, alphanumeric with hyphens and underscores only.
33+
"""
34+
35+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]]
36+
"""Optional metadata for the document."""

0 commit comments

Comments
 (0)