Skip to content
Open
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
20 changes: 19 additions & 1 deletion portkey_ai/api_resources/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import platform

from portkey_ai.api_resources.apis.create_headers import createHeaders
from .global_constants import PORTKEY_HEADER_PREFIX, DEFAULT_CONNECTION_LIMITS
from .global_constants import (
DEFAULT_TIMEOUT_CONFIG,
PORTKEY_HEADER_PREFIX,
DEFAULT_CONNECTION_LIMITS,
)
from .utils import remove_empty_values, Options, set_base_url
from .exceptions import (
APIStatusError,
Expand Down Expand Up @@ -178,12 +182,19 @@ def __init__(
)

self.allHeaders = self._build_headers(Options.construct())

if self.request_timeout:
timeout = httpx.Timeout(self.request_timeout, connect=5.0)
else:
timeout = DEFAULT_TIMEOUT_CONFIG

self._client = http_client or httpx.Client(
base_url=self.base_url,
headers={
"Accept": "application/json",
},
limits=DEFAULT_CONNECTION_LIMITS,
timeout=timeout,
)

self.response_headers: httpx.Headers | None = None
Expand Down Expand Up @@ -891,12 +902,19 @@ def __init__(
)

self.allHeaders = self._build_headers(Options.construct())

if self.request_timeout:
timeout = httpx.Timeout(self.request_timeout, connect=5.0)
else:
timeout = DEFAULT_TIMEOUT_CONFIG

self._client = http_client or AsyncHttpxClientWrapper(
base_url=self.base_url,
headers={
"Accept": "application/json",
},
limits=DEFAULT_CONNECTION_LIMITS,
timeout=timeout,
)

self.response_headers: httpx.Headers | None = None
Expand Down
1 change: 1 addition & 0 deletions portkey_ai/api_resources/global_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
DEFAULT_CONNECTION_LIMITS = httpx.Limits(
max_connections=1000, max_keepalive_connections=100
)
DEFAULT_TIMEOUT_CONFIG = httpx.Timeout(timeout=600, connect=5.0)
AUDIO_FILE_DURATION_HEADER = "x-portkey-audio-file-duration"