maitai-python 1.2.20b0__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.
Files changed (36) hide show
  1. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/PKG-INFO +1 -1
  2. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_maitai_async.py +1 -0
  3. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_maitai_client.py +31 -18
  4. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_common/version.py +1 -1
  5. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_python.egg-info/PKG-INFO +1 -1
  6. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/README.md +0 -0
  7. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/__init__.py +0 -0
  8. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_config.py +0 -0
  9. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_config_listener.py +0 -0
  10. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_context.py +0 -0
  11. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_evaluator.py +0 -0
  12. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_inference.py +0 -0
  13. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_maitai.py +0 -0
  14. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_pydantic.py +0 -0
  15. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_types.py +0 -0
  16. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/_utils.py +0 -0
  17. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/exceptions.py +0 -0
  18. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/__init__.py +0 -0
  19. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/application.py +0 -0
  20. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/chat.py +0 -0
  21. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/config.py +0 -0
  22. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/event.py +0 -0
  23. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/inference.py +0 -0
  24. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/key.py +0 -0
  25. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/metric.py +0 -0
  26. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/models/sentinel.py +0 -0
  27. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai/tools/__init__.py +0 -0
  28. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_common/__init__.py +0 -0
  29. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_common/config/__init__.py +0 -0
  30. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_common/config/config_service.py +0 -0
  31. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_python.egg-info/SOURCES.txt +0 -0
  32. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_python.egg-info/dependency_links.txt +0 -0
  33. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_python.egg-info/requires.txt +0 -0
  34. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/maitai_python.egg-info/top_level.txt +0 -0
  35. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/setup.cfg +0 -0
  36. {maitai_python-1.2.20b0 → maitai_python-1.2.22}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maitai-python
3
- Version: 1.2.20b0
3
+ Version: 1.2.22
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -136,6 +136,7 @@ class MaitaiAsync:
136
136
  else:
137
137
  config.auth_keys.gemini_api_key.key_value = gemini_api_key
138
138
  self._client = None
139
+ azure_params = None
139
140
  if azure_api_key:
140
141
  azure_params = AzureParams(
141
142
  endpoint=azure_endpoint,
@@ -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:
@@ -79,7 +94,7 @@ def _determine_maitai_host():
79
94
  if azure_region == "westus2":
80
95
  return "https://api.azure.westus2.trymaitai.ai"
81
96
 
82
- return "https://api.global.trymaitai.ai"
97
+ return "https://api.trymaitai.ai"
83
98
 
84
99
 
85
100
  class MaitaiClient:
@@ -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
- http2=True,
97
- limits=httpx.Limits(
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
- http2=True,
110
- limits=httpx.Limits(
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 as e:
127
+ except Exception:
123
128
  pass
124
129
  try:
125
130
  self.close_client()
126
- except Exception as e:
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
- response = httpx.get(url, headers=headers, timeout=15)
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()
@@ -1,3 +1,3 @@
1
- version = "1.2.20b0"
1
+ version = "1.2.22"
2
2
  if __name__ == "__main__":
3
3
  print(version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maitai-python
3
- Version: 1.2.20b0
3
+ Version: 1.2.22
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai