Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(package): export default constants #423

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/anthropic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
from ._constants import AI_PROMPT as AI_PROMPT, HUMAN_PROMPT as HUMAN_PROMPT
from ._constants import (
AI_PROMPT as AI_PROMPT,
HUMAN_PROMPT as HUMAN_PROMPT,
DEFAULT_TIMEOUT,
DEFAULT_MAX_RETRIES,
DEFAULT_CONNECTION_LIMITS,
)
from ._exceptions import (
APIError,
ConflictError,
Expand Down Expand Up @@ -69,6 +75,9 @@
"AsyncAnthropic",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
"DEFAULT_MAX_RETRIES",
"DEFAULT_CONNECTION_LIMITS",
"HUMAN_PROMPT",
"AI_PROMPT",
]
Expand Down
6 changes: 3 additions & 3 deletions src/anthropic/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
extract_response_type,
)
from ._constants import (
DEFAULT_LIMITS,
DEFAULT_TIMEOUT,
MAX_RETRY_DELAY,
DEFAULT_MAX_RETRIES,
INITIAL_RETRY_DELAY,
RAW_RESPONSE_HEADER,
OVERRIDE_CAST_TO_HEADER,
DEFAULT_CONNECTION_LIMITS,
)
from ._streaming import Stream, SSEDecoder, AsyncStream, SSEBytesDecoder
from ._exceptions import (
Expand Down Expand Up @@ -747,7 +747,7 @@ def __init__(
if http_client is not None:
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
else:
limits = DEFAULT_LIMITS
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
warnings.warn(
Expand Down Expand Up @@ -1294,7 +1294,7 @@ def __init__(
if http_client is not None:
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
else:
limits = DEFAULT_LIMITS
limits = DEFAULT_CONNECTION_LIMITS

if transport is not None:
warnings.warn(
Expand Down
6 changes: 3 additions & 3 deletions src/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
async_get_tokenizer,
)
from ._base_client import (
DEFAULT_LIMITS,
DEFAULT_MAX_RETRIES,
DEFAULT_CONNECTION_LIMITS,
SyncAPIClient,
AsyncAPIClient,
SyncHttpxClientWrapper,
Expand Down Expand Up @@ -239,7 +239,7 @@ def copy(

http_client = None
else:
if self._limits is not DEFAULT_LIMITS:
if self._limits is not DEFAULT_CONNECTION_LIMITS:
connection_pool_limits = self._limits
else:
connection_pool_limits = None
Expand Down Expand Up @@ -499,7 +499,7 @@ def copy(

http_client = None
else:
if self._limits is not DEFAULT_LIMITS:
if self._limits is not DEFAULT_CONNECTION_LIMITS:
connection_pool_limits = self._limits
else:
connection_pool_limits = None
Expand Down
2 changes: 1 addition & 1 deletion src/anthropic/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# default timeout is 10 minutes
DEFAULT_TIMEOUT = httpx.Timeout(timeout=600.0, connect=5.0)
DEFAULT_MAX_RETRIES = 2
DEFAULT_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)

INITIAL_RETRY_DELAY = 0.5
MAX_RETRY_DELAY = 8.0
Expand Down