Skip to content

Commit

Permalink
feat(vertex): add messages beta
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Oct 22, 2024
1 parent cabe3fc commit 1c2d817
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 0 deletions.
102 changes: 102 additions & 0 deletions src/anthropic/lib/vertex/_beta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ._beta_messages import (
Messages,
AsyncMessages,
MessagesWithRawResponse,
AsyncMessagesWithRawResponse,
MessagesWithStreamingResponse,
AsyncMessagesWithStreamingResponse,
)

__all__ = ["Beta", "AsyncBeta"]


class Beta(SyncAPIResource):
@cached_property
def messages(self) -> Messages:
return Messages(self._client)

@cached_property
def with_raw_response(self) -> BetaWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return BetaWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> BetaWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return BetaWithStreamingResponse(self)


class AsyncBeta(AsyncAPIResource):
@cached_property
def messages(self) -> AsyncMessages:
return AsyncMessages(self._client)

@cached_property
def with_raw_response(self) -> AsyncBetaWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return AsyncBetaWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncBetaWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return AsyncBetaWithStreamingResponse(self)


class BetaWithRawResponse:
def __init__(self, beta: Beta) -> None:
self._beta = beta

@cached_property
def messages(self) -> MessagesWithRawResponse:
return MessagesWithRawResponse(self._beta.messages)


class AsyncBetaWithRawResponse:
def __init__(self, beta: AsyncBeta) -> None:
self._beta = beta

@cached_property
def messages(self) -> AsyncMessagesWithRawResponse:
return AsyncMessagesWithRawResponse(self._beta.messages)


class BetaWithStreamingResponse:
def __init__(self, beta: Beta) -> None:
self._beta = beta

@cached_property
def messages(self) -> MessagesWithStreamingResponse:
return MessagesWithStreamingResponse(self._beta.messages)


class AsyncBetaWithStreamingResponse:
def __init__(self, beta: AsyncBeta) -> None:
self._beta = beta

@cached_property
def messages(self) -> AsyncMessagesWithStreamingResponse:
return AsyncMessagesWithStreamingResponse(self._beta.messages)
93 changes: 93 additions & 0 deletions src/anthropic/lib/vertex/_beta_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from ... import _legacy_response
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...resources.beta import Messages as FirstPartyMessagesAPI, AsyncMessages as FirstPartyAsyncMessagesAPI

__all__ = ["Messages", "AsyncMessages"]


class Messages(SyncAPIResource):
create = FirstPartyMessagesAPI.create

@cached_property
def with_raw_response(self) -> MessagesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return MessagesWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> MessagesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return MessagesWithStreamingResponse(self)


class AsyncMessages(AsyncAPIResource):
create = FirstPartyAsyncMessagesAPI.create

@cached_property
def with_raw_response(self) -> AsyncMessagesWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return AsyncMessagesWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return AsyncMessagesWithStreamingResponse(self)


class MessagesWithRawResponse:
def __init__(self, messages: Messages) -> None:
self._messages = messages

self.create = _legacy_response.to_raw_response_wrapper(
messages.create,
)


class AsyncMessagesWithRawResponse:
def __init__(self, messages: AsyncMessages) -> None:
self._messages = messages

self.create = _legacy_response.async_to_raw_response_wrapper(
messages.create,
)


class MessagesWithStreamingResponse:
def __init__(self, messages: Messages) -> None:
self._messages = messages

self.create = to_streamed_response_wrapper(
messages.create,
)


class AsyncMessagesWithStreamingResponse:
def __init__(self, messages: AsyncMessages) -> None:
self._messages = messages

self.create = async_to_streamed_response_wrapper(
messages.create,
)
5 changes: 5 additions & 0 deletions src/anthropic/lib/vertex/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from ... import _exceptions
from ._auth import load_auth, refresh_auth
from ._beta import Beta, AsyncBeta
from ..._types import NOT_GIVEN, NotGiven, Transport, ProxiesTypes, AsyncTransport
from ..._utils import is_dict, asyncify, is_given
from ..._compat import model_copy, typed_cached_property
Expand Down Expand Up @@ -85,6 +86,7 @@ def _make_status_error(

class AnthropicVertex(BaseVertexClient[httpx.Client, Stream[Any]], SyncAPIClient):
messages: Messages
beta: Beta

def __init__(
self,
Expand Down Expand Up @@ -142,6 +144,7 @@ def __init__(
self.credentials = credentials

self.messages = Messages(self)
self.beta = Beta(self)

@override
def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
Expand Down Expand Up @@ -251,6 +254,7 @@ def copy(

class AsyncAnthropicVertex(BaseVertexClient[httpx.AsyncClient, AsyncStream[Any]], AsyncAPIClient):
messages: AsyncMessages
beta: AsyncBeta

def __init__(
self,
Expand Down Expand Up @@ -308,6 +312,7 @@ def __init__(
self.credentials = credentials

self.messages = AsyncMessages(self)
self.beta = AsyncBeta(self)

@override
async def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
Expand Down

0 comments on commit 1c2d817

Please sign in to comment.