| 1 |
import typing as _t |
| 2 |
|
| 3 |
from . import types |
| 4 |
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, omit, not_given |
| 5 |
from ._utils import file_from_path |
| 6 |
from ._client import Client, Stream, Timeout, Anthropic, AsyncClient, AsyncStream, AsyncAnthropic, RequestOptions |
| 7 |
from ._models import BaseModel |
| 8 |
from ._request import APIRequest |
| 9 |
from ._version import __title__, __version__ |
| 10 |
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse |
| 11 |
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS |
| 12 |
from ._exceptions import ( |
| 13 |
APIError, |
| 14 |
ConflictError, |
| 15 |
NotFoundError, |
| 16 |
AnthropicError, |
| 17 |
APIStatusError, |
| 18 |
RateLimitError, |
| 19 |
RetryableError, |
| 20 |
APITimeoutError, |
| 21 |
BadRequestError, |
| 22 |
OverloadedError, |
| 23 |
CredentialsError, |
| 24 |
APIConnectionError, |
| 25 |
AuthenticationError, |
| 26 |
InternalServerError, |
| 27 |
RequestTooLargeError, |
| 28 |
DeadlineExceededError, |
| 29 |
PermissionDeniedError, |
| 30 |
IdentityTokenFileError, |
| 31 |
ServiceUnavailableError, |
| 32 |
UnprocessableEntityError, |
| 33 |
APIWebhookValidationError, |
| 34 |
APIResponseValidationError, |
| 35 |
) |
| 36 |
from ._middleware import ( |
| 37 |
CallNext, |
| 38 |
Middleware, |
| 39 |
AsyncCallNext, |
| 40 |
MiddlewareInput, |
| 41 |
MiddlewareCallable, |
| 42 |
AsyncMiddlewareCallable, |
| 43 |
) |
| 44 |
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient |
| 45 |
from ._utils._logs import setup_logging as _setup_logging |
| 46 |
from .lib.middleware import BetaFallbackState, BetaRefusalFallbackMiddleware |
| 47 |
from .lib._parse._transform import transform_schema |
| 48 |
|
| 49 |
__all__ = [ |
| 50 |
"types", |
| 51 |
"__version__", |
| 52 |
"__title__", |
| 53 |
"NoneType", |
| 54 |
"NotGiven", |
| 55 |
"NOT_GIVEN", |
| 56 |
"not_given", |
| 57 |
"Omit", |
| 58 |
"omit", |
| 59 |
"AnthropicError", |
| 60 |
"APIError", |
| 61 |
"APIStatusError", |
| 62 |
"APITimeoutError", |
| 63 |
"APIConnectionError", |
| 64 |
"APIResponseValidationError", |
| 65 |
"APIWebhookValidationError", |
| 66 |
"BadRequestError", |
| 67 |
"AuthenticationError", |
| 68 |
"PermissionDeniedError", |
| 69 |
"NotFoundError", |
| 70 |
"ConflictError", |
| 71 |
"RequestTooLargeError", |
| 72 |
"UnprocessableEntityError", |
| 73 |
"RateLimitError", |
| 74 |
"InternalServerError", |
| 75 |
"ServiceUnavailableError", |
| 76 |
"OverloadedError", |
| 77 |
"DeadlineExceededError", |
| 78 |
"RetryableError", |
| 79 |
"CredentialsError", |
| 80 |
"IdentityTokenFileError", |
| 81 |
"Timeout", |
| 82 |
"RequestOptions", |
| 83 |
"Client", |
| 84 |
"AsyncClient", |
| 85 |
"Stream", |
| 86 |
"AsyncStream", |
| 87 |
"Anthropic", |
| 88 |
"AsyncAnthropic", |
| 89 |
"APIRequest", |
| 90 |
"Middleware", |
| 91 |
"MiddlewareInput", |
| 92 |
"MiddlewareCallable", |
| 93 |
"AsyncMiddlewareCallable", |
| 94 |
"CallNext", |
| 95 |
"AsyncCallNext", |
| 96 |
"BetaFallbackState", |
| 97 |
"BetaRefusalFallbackMiddleware", |
| 98 |
"file_from_path", |
| 99 |
"BaseModel", |
| 100 |
"DEFAULT_TIMEOUT", |
| 101 |
"DEFAULT_MAX_RETRIES", |
| 102 |
"DEFAULT_CONNECTION_LIMITS", |
| 103 |
"DefaultHttpxClient", |
| 104 |
"DefaultAsyncHttpxClient", |
| 105 |
"DefaultAioHttpClient", |
| 106 |
"beta_tool", |
| 107 |
"beta_async_tool", |
| 108 |
"transform_schema", |
| 109 |
] |
| 110 |
|
| 111 |
if not _t.TYPE_CHECKING: |
| 112 |
from ._utils._resources_proxy import resources as resources |
| 113 |
|
| 114 |
from .lib.aws import AnthropicAWS as AnthropicAWS, AsyncAnthropicAWS as AsyncAnthropicAWS |
| 115 |
from .lib.tools import beta_tool, beta_async_tool |
| 116 |
from .lib.vertex import * |
| 117 |
from .lib.bedrock import * |
| 118 |
from .lib.foundry import AnthropicFoundry as AnthropicFoundry, AsyncAnthropicFoundry as AsyncAnthropicFoundry |
| 119 |
from .lib.streaming import * |
| 120 |
from .lib.credentials import * |
| 121 |
from .lib.google_cloud import ( |
| 122 |
AnthropicGoogleCloud as AnthropicGoogleCloud, |
| 123 |
AsyncAnthropicGoogleCloud as AsyncAnthropicGoogleCloud, |
| 124 |
) |
| 125 |
|
| 126 |
_setup_logging() |
| 127 |
|
| 128 |
# Update the __module__ attribute for exported symbols so that |
| 129 |
# error messages point to this module instead of the module |
| 130 |
# it was originally defined in, e.g. |
| 131 |
# anthropic._exceptions.NotFoundError -> anthropic.NotFoundError |
| 132 |
__locals = locals() |
| 133 |
for __name in __all__: |
| 134 |
if not __name.startswith("__"): |
| 135 |
try: |
| 136 |
__locals[__name].__module__ = "anthropic" |
| 137 |
except (TypeError, AttributeError): |
| 138 |
# Some of our exported symbols are builtins which we can't set attributes for. |
| 139 |
pass |