maitai-python 1.2.21__tar.gz → 1.2.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {maitai_python-1.2.21 → maitai_python-1.2.22}/PKG-INFO +1 -1
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_maitai_async.py +1 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_maitai_client.py +30 -17
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_common/version.py +1 -1
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.2.21 → maitai_python-1.2.22}/README.md +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/__init__.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_config.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_config_listener.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_context.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_inference.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_maitai.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_types.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/_utils.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/exceptions.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/application.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/chat.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/config.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/event.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/inference.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/key.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/models/sentinel.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/setup.cfg +0 -0
- {maitai_python-1.2.21 → maitai_python-1.2.22}/setup.py +0 -0
|
@@ -5,6 +5,21 @@ import httpx
|
|
|
5
5
|
|
|
6
6
|
from maitai_common.version import version
|
|
7
7
|
|
|
8
|
+
# Common client settings to ensure consistency
|
|
9
|
+
CLIENT_SETTINGS = {
|
|
10
|
+
"http2": True,
|
|
11
|
+
"limits": httpx.Limits(
|
|
12
|
+
max_keepalive_connections=200,
|
|
13
|
+
max_connections=1000,
|
|
14
|
+
),
|
|
15
|
+
"timeout": httpx.Timeout(timeout=600, connect=5.0),
|
|
16
|
+
"follow_redirects": True,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# In _base_client.py, they define DEFAULT_MAX_RETRIES = 2
|
|
20
|
+
# We'll incorporate that into our transport settings
|
|
21
|
+
DEFAULT_MAX_RETRIES = 2
|
|
22
|
+
|
|
8
23
|
|
|
9
24
|
def _get_aws_instance_metadata(url, timeout=2):
|
|
10
25
|
try:
|
|
@@ -93,37 +108,27 @@ class MaitaiClient:
|
|
|
93
108
|
def get_client(self):
|
|
94
109
|
if self._client is None:
|
|
95
110
|
self._client = httpx.Client(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
max_keepalive_connections=200,
|
|
99
|
-
max_connections=1000,
|
|
100
|
-
keepalive_expiry=300,
|
|
101
|
-
),
|
|
102
|
-
transport=httpx.HTTPTransport(retries=3),
|
|
111
|
+
**CLIENT_SETTINGS,
|
|
112
|
+
transport=httpx.HTTPTransport(retries=DEFAULT_MAX_RETRIES),
|
|
103
113
|
)
|
|
104
114
|
return self._client
|
|
105
115
|
|
|
106
116
|
async def get_async_client(self):
|
|
107
117
|
if self._async_client is None:
|
|
108
118
|
self._async_client = httpx.AsyncClient(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
max_keepalive_connections=200,
|
|
112
|
-
max_connections=1000,
|
|
113
|
-
keepalive_expiry=300,
|
|
114
|
-
),
|
|
115
|
-
transport=httpx.AsyncHTTPTransport(retries=3),
|
|
119
|
+
**CLIENT_SETTINGS,
|
|
120
|
+
transport=httpx.AsyncHTTPTransport(retries=DEFAULT_MAX_RETRIES),
|
|
116
121
|
)
|
|
117
122
|
return self._async_client
|
|
118
123
|
|
|
119
124
|
def cleanup(self):
|
|
120
125
|
try:
|
|
121
126
|
self.executor.shutdown()
|
|
122
|
-
except Exception
|
|
127
|
+
except Exception:
|
|
123
128
|
pass
|
|
124
129
|
try:
|
|
125
130
|
self.close_client()
|
|
126
|
-
except Exception
|
|
131
|
+
except Exception:
|
|
127
132
|
pass
|
|
128
133
|
|
|
129
134
|
def close_client(self):
|
|
@@ -131,6 +136,11 @@ class MaitaiClient:
|
|
|
131
136
|
self._client.close()
|
|
132
137
|
self._client = None
|
|
133
138
|
|
|
139
|
+
async def close_async_client(self):
|
|
140
|
+
if self._async_client:
|
|
141
|
+
await self._async_client.aclose()
|
|
142
|
+
self._async_client = None
|
|
143
|
+
|
|
134
144
|
def __del__(self):
|
|
135
145
|
self.cleanup()
|
|
136
146
|
|
|
@@ -176,6 +186,7 @@ class MaitaiClient:
|
|
|
176
186
|
pass
|
|
177
187
|
|
|
178
188
|
def init_sdk(self, api_key: str, host: str):
|
|
189
|
+
"""Initialize the SDK and warm up connections."""
|
|
179
190
|
url = f"{host}/config/init_sdk"
|
|
180
191
|
headers = {
|
|
181
192
|
"Content-Type": "application/json",
|
|
@@ -183,7 +194,9 @@ class MaitaiClient:
|
|
|
183
194
|
"User-Agent": version,
|
|
184
195
|
}
|
|
185
196
|
|
|
186
|
-
|
|
197
|
+
# Get the shared client to warm up connections
|
|
198
|
+
client = self.get_client()
|
|
199
|
+
response = client.get(url, headers=headers, timeout=15)
|
|
187
200
|
if response.status_code != 200:
|
|
188
201
|
raise Exception(f"Failed to initialize Maitai client: {response.text}")
|
|
189
202
|
return response.json()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|