Skip to content

Commit

Permalink
feat(api): api update (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Dec 16, 2024
1 parent 9a4cd72 commit f295a74
Show file tree
Hide file tree
Showing 24 changed files with 477 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 40
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-e4c301de216e3c01c130dfbf82f7d5272939867cc4b452aa00d6f0e081767bec.yml
configured_endpoints: 41
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-9c89a1623da5f8289d05c3c8a8fa7778d7d89f8679e4e8a3589c1cb2735c70aa.yml
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ client = Honcho(
)

app = client.apps.create(
name="name",
name="x",
)
print(app.id)
```
Expand Down Expand Up @@ -62,7 +62,7 @@ client = AsyncHoncho(

async def main() -> None:
app = await client.apps.create(
name="name",
name="x",
)
print(app.id)

Expand Down Expand Up @@ -169,7 +169,7 @@ client = Honcho()

try:
client.apps.create(
name="name",
name="x",
)
except honcho.APIConnectionError as e:
print("The server could not be reached")
Expand Down Expand Up @@ -214,7 +214,7 @@ client = Honcho(

# Or, configure per-request:
client.with_options(max_retries=5).apps.create(
name="name",
name="x",
)
```

Expand All @@ -239,7 +239,7 @@ client = Honcho(

# Override per-request:
client.with_options(timeout=5.0).apps.create(
name="name",
name="x",
)
```

Expand Down Expand Up @@ -282,7 +282,7 @@ from honcho import Honcho

client = Honcho()
response = client.apps.with_raw_response.create(
name="name",
name="x",
)
print(response.headers.get('X-My-Header'))

Expand All @@ -302,7 +302,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi

```python
with client.apps.with_streaming_response.create(
name="name",
name="x",
) as response:
print(response.headers.get("X-My-Header"))

Expand Down
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ Methods:
Types:

```python
from honcho.types.apps.users.sessions import Message, PageMessage
from honcho.types.apps.users.sessions import Message, PageMessage, MessageBatchResponse
```

Methods:

- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">create</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_create_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>
- <code title="put /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">update</a>(message_id, \*, app_id, user_id, session_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_update_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>
- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/list">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">list</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_list_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message.py">SyncPage[Message]</a></code>
- <code title="post /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">batch</a>(session_id, \*, app_id, user_id, \*\*<a href="src/honcho/types/apps/users/sessions/message_batch_params.py">params</a>) -> <a href="./src/honcho/types/apps/users/sessions/message_batch_response.py">MessageBatchResponse</a></code>
- <code title="get /v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/{message_id}">client.apps.users.sessions.messages.<a href="./src/honcho/resources/apps/users/sessions/messages.py">get</a>(message_id, \*, app_id, user_id, session_id) -> <a href="./src/honcho/types/apps/users/sessions/message.py">Message</a></code>

#### Metamessages
Expand Down
4 changes: 2 additions & 2 deletions src/honcho/resources/apps/users/collections/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create(
*,
app_id: str,
name: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -358,7 +358,7 @@ async def create(
*,
app_id: str,
name: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/honcho/resources/apps/users/collections/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create(
app_id: str,
user_id: str,
content: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -375,7 +375,7 @@ async def create(
app_id: str,
user_id: str,
content: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
112 changes: 108 additions & 4 deletions src/honcho/resources/apps/users/sessions/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Dict, Optional
from typing import Dict, Iterable, Optional

import httpx

Expand All @@ -21,8 +21,14 @@
)
from .....pagination import SyncPage, AsyncPage
from ....._base_client import AsyncPaginator, make_request_options
from .....types.apps.users.sessions import message_list_params, message_create_params, message_update_params
from .....types.apps.users.sessions import (
message_list_params,
message_batch_params,
message_create_params,
message_update_params,
)
from .....types.apps.users.sessions.message import Message
from .....types.apps.users.sessions.message_batch_response import MessageBatchResponse

__all__ = ["MessagesResource", "AsyncMessagesResource"]

Expand Down Expand Up @@ -104,7 +110,7 @@ def update(
app_id: str,
user_id: str,
session_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -202,6 +208,49 @@ def list(
method="post",
)

def batch(
self,
session_id: str,
*,
app_id: str,
user_id: str,
messages: Iterable[message_batch_params.Message],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> MessageBatchResponse:
"""Bulk create messages for a session while maintaining order.
Maximum 100 messages
per batch.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not app_id:
raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not session_id:
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
return self._post(
f"/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch",
body=maybe_transform({"messages": messages}, message_batch_params.MessageBatchParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=MessageBatchResponse,
)

def get(
self,
message_id: str,
Expand Down Expand Up @@ -322,7 +371,7 @@ async def update(
app_id: str,
user_id: str,
session_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -420,6 +469,49 @@ def list(
method="post",
)

async def batch(
self,
session_id: str,
*,
app_id: str,
user_id: str,
messages: Iterable[message_batch_params.Message],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> MessageBatchResponse:
"""Bulk create messages for a session while maintaining order.
Maximum 100 messages
per batch.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not app_id:
raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}")
if not user_id:
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
if not session_id:
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
return await self._post(
f"/v1/apps/{app_id}/users/{user_id}/sessions/{session_id}/messages/batch",
body=await async_maybe_transform({"messages": messages}, message_batch_params.MessageBatchParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=MessageBatchResponse,
)

async def get(
self,
message_id: str,
Expand Down Expand Up @@ -476,6 +568,9 @@ def __init__(self, messages: MessagesResource) -> None:
self.list = to_raw_response_wrapper(
messages.list,
)
self.batch = to_raw_response_wrapper(
messages.batch,
)
self.get = to_raw_response_wrapper(
messages.get,
)
Expand All @@ -494,6 +589,9 @@ def __init__(self, messages: AsyncMessagesResource) -> None:
self.list = async_to_raw_response_wrapper(
messages.list,
)
self.batch = async_to_raw_response_wrapper(
messages.batch,
)
self.get = async_to_raw_response_wrapper(
messages.get,
)
Expand All @@ -512,6 +610,9 @@ def __init__(self, messages: MessagesResource) -> None:
self.list = to_streamed_response_wrapper(
messages.list,
)
self.batch = to_streamed_response_wrapper(
messages.batch,
)
self.get = to_streamed_response_wrapper(
messages.get,
)
Expand All @@ -530,6 +631,9 @@ def __init__(self, messages: AsyncMessagesResource) -> None:
self.list = async_to_streamed_response_wrapper(
messages.list,
)
self.batch = async_to_streamed_response_wrapper(
messages.batch,
)
self.get = async_to_streamed_response_wrapper(
messages.get,
)
4 changes: 2 additions & 2 deletions src/honcho/resources/apps/users/sessions/metamessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create(
content: str,
message_id: str,
metamessage_type: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -304,7 +304,7 @@ async def create(
content: str,
message_id: str,
metamessage_type: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/honcho/resources/apps/users/sessions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def update(
*,
app_id: str,
user_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -507,7 +507,7 @@ async def update(
*,
app_id: str,
user_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
metadata: Dict[str, object],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/honcho/types/apps/users/collection_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Dict, Optional
from typing import Dict
from typing_extensions import Required, TypedDict

__all__ = ["CollectionCreateParams"]
Expand All @@ -13,4 +13,4 @@ class CollectionCreateParams(TypedDict, total=False):

name: Required[str]

metadata: Optional[Dict[str, object]]
metadata: Dict[str, object]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Dict, Optional
from typing import Dict
from typing_extensions import Required, TypedDict

__all__ = ["DocumentCreateParams"]
Expand All @@ -15,4 +15,4 @@ class DocumentCreateParams(TypedDict, total=False):

content: Required[str]

metadata: Optional[Dict[str, object]]
metadata: Dict[str, object]
4 changes: 2 additions & 2 deletions src/honcho/types/apps/users/session_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Dict, Optional
from typing import Dict
from typing_extensions import Required, TypedDict

__all__ = ["SessionUpdateParams"]
Expand All @@ -13,4 +13,4 @@ class SessionUpdateParams(TypedDict, total=False):

user_id: Required[str]

metadata: Optional[Dict[str, object]]
metadata: Required[Dict[str, object]]
2 changes: 2 additions & 0 deletions src/honcho/types/apps/users/sessions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from .page_message import PageMessage as PageMessage
from .page_metamessage import PageMetamessage as PageMetamessage
from .message_list_params import MessageListParams as MessageListParams
from .message_batch_params import MessageBatchParams as MessageBatchParams
from .message_create_params import MessageCreateParams as MessageCreateParams
from .message_update_params import MessageUpdateParams as MessageUpdateParams
from .message_batch_response import MessageBatchResponse as MessageBatchResponse
from .metamessage_get_params import MetamessageGetParams as MetamessageGetParams
from .metamessage_list_params import MetamessageListParams as MetamessageListParams
from .metamessage_create_params import MetamessageCreateParams as MetamessageCreateParams
Expand Down
Loading

0 comments on commit f295a74

Please sign in to comment.