Debian Codegraph @

src/anthropic/lib/vertex/_beta_messages.py

raw
1 # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3 from __future__ import annotations
4
5 from ..._compat import cached_property
6 from ..._resource import SyncAPIResource, AsyncAPIResource
7 from ..._response import (
8 to_raw_response_wrapper,
9 to_streamed_response_wrapper,
10 async_to_raw_response_wrapper,
11 async_to_streamed_response_wrapper,
12 )
13 from ...resources.beta import Messages as FirstPartyMessagesAPI, AsyncMessages as FirstPartyAsyncMessagesAPI
14
15 __all__ = ["Messages", "AsyncMessages"]
16
17
18 class Messages(SyncAPIResource):
19 create = FirstPartyMessagesAPI.create
20 parse = FirstPartyMessagesAPI.parse
21 stream = FirstPartyMessagesAPI.stream
22 tool_runner = FirstPartyMessagesAPI.tool_runner
23 count_tokens = FirstPartyMessagesAPI.count_tokens
24
25 @cached_property
26 def with_raw_response(self) -> MessagesWithRawResponse:
27 """
28 This property can be used as a prefix for any HTTP method call to return the
29 the raw response object instead of the parsed content.
30
31 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
32 """
33 return MessagesWithRawResponse(self)
34
35 @cached_property
36 def with_streaming_response(self) -> MessagesWithStreamingResponse:
37 """
38 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
39
40 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
41 """
42 return MessagesWithStreamingResponse(self)
43
44
45 class AsyncMessages(AsyncAPIResource):
46 create = FirstPartyAsyncMessagesAPI.create
47 parse = FirstPartyAsyncMessagesAPI.parse
48 stream = FirstPartyAsyncMessagesAPI.stream
49 tool_runner = FirstPartyAsyncMessagesAPI.tool_runner
50 count_tokens = FirstPartyAsyncMessagesAPI.count_tokens
51
52 @cached_property
53 def with_raw_response(self) -> AsyncMessagesWithRawResponse:
54 """
55 This property can be used as a prefix for any HTTP method call to return the
56 the raw response object instead of the parsed content.
57
58 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
59 """
60 return AsyncMessagesWithRawResponse(self)
61
62 @cached_property
63 def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
64 """
65 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
66
67 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
68 """
69 return AsyncMessagesWithStreamingResponse(self)
70
71
72 class MessagesWithRawResponse:
73 def __init__(self, messages: Messages) -> None:
74 self._messages = messages
75
76 self.create = to_raw_response_wrapper(
77 messages.create,
78 )
79
80
81 class AsyncMessagesWithRawResponse:
82 def __init__(self, messages: AsyncMessages) -> None:
83 self._messages = messages
84
85 self.create = async_to_raw_response_wrapper(
86 messages.create,
87 )
88
89
90 class MessagesWithStreamingResponse:
91 def __init__(self, messages: Messages) -> None:
92 self._messages = messages
93
94 self.create = to_streamed_response_wrapper(
95 messages.create,
96 )
97
98
99 class AsyncMessagesWithStreamingResponse:
100 def __init__(self, messages: AsyncMessages) -> None:
101 self._messages = messages
102
103 self.create = async_to_streamed_response_wrapper(
104 messages.create,
105 )