Debian Codegraph @

src/anthropic/lib/bedrock/_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
24 @cached_property
25 def with_raw_response(self) -> MessagesWithRawResponse:
26 """
27 This property can be used as a prefix for any HTTP method call to return the
28 the raw response object instead of the parsed content.
29
30 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
31 """
32 return MessagesWithRawResponse(self)
33
34 @cached_property
35 def with_streaming_response(self) -> MessagesWithStreamingResponse:
36 """
37 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38
39 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
40 """
41 return MessagesWithStreamingResponse(self)
42
43
44 class AsyncMessages(AsyncAPIResource):
45 create = FirstPartyAsyncMessagesAPI.create
46 parse = FirstPartyAsyncMessagesAPI.parse
47 stream = FirstPartyAsyncMessagesAPI.stream
48 tool_runner = FirstPartyAsyncMessagesAPI.tool_runner
49
50 @cached_property
51 def with_raw_response(self) -> AsyncMessagesWithRawResponse:
52 """
53 This property can be used as a prefix for any HTTP method call to return the
54 the raw response object instead of the parsed content.
55
56 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
57 """
58 return AsyncMessagesWithRawResponse(self)
59
60 @cached_property
61 def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
62 """
63 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
64
65 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
66 """
67 return AsyncMessagesWithStreamingResponse(self)
68
69
70 class MessagesWithRawResponse:
71 def __init__(self, messages: Messages) -> None:
72 self._messages = messages
73
74 self.create = to_raw_response_wrapper(
75 messages.create,
76 )
77
78
79 class AsyncMessagesWithRawResponse:
80 def __init__(self, messages: AsyncMessages) -> None:
81 self._messages = messages
82
83 self.create = async_to_raw_response_wrapper(
84 messages.create,
85 )
86
87
88 class MessagesWithStreamingResponse:
89 def __init__(self, messages: Messages) -> None:
90 self._messages = messages
91
92 self.create = to_streamed_response_wrapper(
93 messages.create,
94 )
95
96
97 class AsyncMessagesWithStreamingResponse:
98 def __init__(self, messages: AsyncMessages) -> None:
99 self._messages = messages
100
101 self.create = async_to_streamed_response_wrapper(
102 messages.create,
103 )