maitai-python 1.2.24__py3-none-any.whl → 1.2.25__py3-none-any.whl

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/_inference.py CHANGED
@@ -322,7 +322,9 @@ class Inference(MaitaiClient):
322
322
  }
323
323
  try:
324
324
  client = self.get_client()
325
- return client.put(url, headers=headers, json=metric.model_dump())
325
+ return client.put(
326
+ url, headers=headers, timeout=10, json=metric.model_dump()
327
+ )
326
328
  except:
327
329
  pass
328
330
 
@@ -338,7 +340,9 @@ class Inference(MaitaiClient):
338
340
  }
339
341
  try:
340
342
  client = await self.get_async_client()
341
- return await client.put(url, headers=headers, json=metric.model_dump())
343
+ return await client.put(
344
+ url, headers=headers, timeout=10, json=metric.model_dump()
345
+ )
342
346
  except:
343
347
  pass
344
348
 
maitai/_maitai.py CHANGED
@@ -699,13 +699,7 @@ class Completions:
699
699
  if chunk.choices and chunk.choices[0].finish_reason:
700
700
  timing.time_request_end = time.time()
701
701
  self.inference.store_request_timing_data(timing)
702
- if chunk.usage:
703
- return
704
- if (
705
- not includes_usage
706
- and chunk.choices
707
- and chunk.choices[0].finish_reason
708
- ):
702
+ if chunk.choices and chunk.choices[0].finish_reason:
709
703
  return
710
704
  except MaitaiConnectionError as e:
711
705
  if "gpt" not in retry_args.get("model", "") and "gpt" in (
maitai/_maitai_async.py CHANGED
@@ -702,13 +702,7 @@ class AsyncCompletions:
702
702
  asyncio.create_task(
703
703
  self.inference_client.send_request_timing_data_async(timing)
704
704
  )
705
- if chunk.usage:
706
- return
707
- if (
708
- not includes_usage
709
- and chunk.choices
710
- and chunk.choices[0].finish_reason
711
- ):
705
+ if chunk.choices and chunk.choices[0].finish_reason:
712
706
  return
713
707
  except MaitaiConnectionError as e:
714
708
  if "gpt" not in retry_args.get("model", "") and "gpt" in (
maitai/_maitai_client.py CHANGED
@@ -43,30 +43,6 @@ def _get_aws_instance_metadata(url, timeout=2):
43
43
  return None
44
44
 
45
45
 
46
- def _get_gcp_instance_metadata(url, timeout=2):
47
- try:
48
- headers = {"Metadata-Flavor": "Google"}
49
- with httpx.Client() as client:
50
- response = client.get(url, headers=headers, timeout=timeout)
51
- response.raise_for_status()
52
- return response.text
53
- except Exception:
54
- return None
55
-
56
-
57
- def _get_azure_instance_metadata(timeout=2):
58
- try:
59
- headers = {"Metadata": "true"}
60
- url = "http://169.254.169.254/metadata/instance/compute?api-version=2021-02-01"
61
- with httpx.Client() as client:
62
- response = client.get(url, headers=headers, timeout=timeout)
63
- response.raise_for_status()
64
- data = response.json()
65
- return data.get("location")
66
- except Exception:
67
- return None
68
-
69
-
70
46
  def _determine_maitai_host():
71
47
  if maitai_host := os.environ.get("MAITAI_HOST"):
72
48
  return maitai_host.rstrip("/")
@@ -79,21 +55,6 @@ def _determine_maitai_host():
79
55
  ):
80
56
  return "https://api.aws.us-west-2.trymaitai.ai"
81
57
 
82
- gcp_zone = _get_gcp_instance_metadata(
83
- "http://metadata.google.internal/computeMetadata/v1/instance/zone"
84
- )
85
- if gcp_zone:
86
- if "us-west1" in gcp_zone:
87
- return "https://api.gcp.us-west1.trymaitai.ai"
88
- # elif "us-central1" in gcp_zone:
89
- # return "https://api.gcp.us-central1.trymaitai.ai"
90
- elif "us-south1" in gcp_zone:
91
- return "https://api.gcp.us-south1.trymaitai.ai"
92
-
93
- azure_region = _get_azure_instance_metadata()
94
- if azure_region == "westus2":
95
- return "https://api.azure.westus2.trymaitai.ai"
96
-
97
58
  return "https://api.trymaitai.ai"
98
59
 
99
60
 
@@ -109,7 +70,7 @@ class MaitaiClient:
109
70
  if self._client is None:
110
71
  self._client = httpx.Client(
111
72
  **CLIENT_SETTINGS,
112
- transport=httpx.HTTPTransport(retries=DEFAULT_MAX_RETRIES),
73
+ transport=httpx.HTTPTransport(retries=DEFAULT_MAX_RETRIES, http2=True),
113
74
  )
114
75
  return self._client
115
76
 
@@ -117,7 +78,9 @@ class MaitaiClient:
117
78
  if self._async_client is None:
118
79
  self._async_client = httpx.AsyncClient(
119
80
  **CLIENT_SETTINGS,
120
- transport=httpx.AsyncHTTPTransport(retries=DEFAULT_MAX_RETRIES),
81
+ transport=httpx.AsyncHTTPTransport(
82
+ retries=DEFAULT_MAX_RETRIES, http2=True
83
+ ),
121
84
  )
122
85
  return self._async_client
123
86
 
@@ -1,6 +1,6 @@
1
1
  import os
2
2
 
3
- if os.environ.get("MAITAI_ENV") in ["prod", "staging", "development"]:
3
+ if os.environ.get("MAITAI_ENV") in ["prod", "staging", "development", "test"]:
4
4
  from maitai_models.config import Config, InferenceLocations
5
5
  else:
6
6
  from maitai.models.config import Config, InferenceLocations
maitai_common/version.py CHANGED
@@ -1,3 +1,3 @@
1
- version = "1.2.24"
1
+ version = "1.2.25"
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.24
3
+ Version: 1.2.25
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -3,10 +3,10 @@ maitai/_config.py,sha256=9p5lrzctWAA8GRvaRXrigQH18H286MupuIwe1kvU_3A,7712
3
3
  maitai/_config_listener.py,sha256=FhjV84Pugy5h0mlbCSaanKZ4aVpINaEKzMNQmdZhRj4,5140
4
4
  maitai/_context.py,sha256=qyxCww-02qvLpJ7dRG_eOkZI2UaCOgLtqkASlb7QbZU,2470
5
5
  maitai/_evaluator.py,sha256=JDcb6xFjUHE28VyGrHxgwD4LVdeDuuOioQd9ZMmOXkI,11363
6
- maitai/_inference.py,sha256=fcapXkBYv1BLmJQ9vRl8p5tFwnM1ojVRz2X7TZLukPY,12735
7
- maitai/_maitai.py,sha256=DsOu4Gvd6SxOvIOaNBsQ6pSqSAN1eNQx9HQyK-49yA4,30549
8
- maitai/_maitai_async.py,sha256=5tbdSX9PEAtWu4FWCD7rhruPhQ6LOeEcIc_7RGwzRK0,30793
9
- maitai/_maitai_client.py,sha256=NmsOYdk2VpDQPuyAZACo7V387ZkEwZZPkpubr3BVs5Q,6392
6
+ maitai/_inference.py,sha256=yBdzVv0LLf38xJsaoKqR-_uLTescKAjGLR3VQR854Yg,12819
7
+ maitai/_maitai.py,sha256=AW5tsuKYCtcUosuz1bryQiin_sN21VsRoKFW09U_v_Y,30363
8
+ maitai/_maitai_async.py,sha256=b7rrzl537S7vQ8xd_6ShMNyAlMECtUEcgVOPvADMvNA,30607
9
+ maitai/_maitai_client.py,sha256=qQeFh1S8UE9QPzVZOnPutIDQ4hkvYXv6TvevNJlRnfI,5087
10
10
  maitai/_pydantic.py,sha256=8clflOhR7-6AeLFBzmsYO0aaQSAkp8KMuxsrYwPthaA,5683
11
11
  maitai/_types.py,sha256=UL3CMIZ0bc1I6vyGcGxCusxVl-OHsTGUFY8oIBckyEs,5875
12
12
  maitai/_utils.py,sha256=SVZU4l2XfXX1aQb33MfDkYa6x7wSQCdwtiaMnjb9mfQ,11557
@@ -22,10 +22,10 @@ maitai/models/metric.py,sha256=iL1FqaJ-3ii5pgY4cGZKp0nuQVG1XnBggopazQhGN_E,451
22
22
  maitai/models/sentinel.py,sha256=D1qPhV6GQDRq-JkDtm_lwSXDWFQ1kUjuCw5H6fUvsFg,1802
23
23
  maitai/tools/__init__.py,sha256=Fo7tOLJNFbFtVN9LI8fpFUPk95lcq97Pp1TP5-2NU3s,4086
24
24
  maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- maitai_common/version.py,sha256=eRCOTHD2z0HULhhORWPA5i_5MaDGaDiDf6rAMc0UJP8,65
25
+ maitai_common/version.py,sha256=FT3760JQDyHoFmCtylz3lvkWL0gBMtmYUc5VEKYjQgs,65
26
26
  maitai_common/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- maitai_common/config/config_service.py,sha256=CRUz-LYyGxCaDqqkqaJ6CyhpTKr11NKux104oU__NBg,1110
28
- maitai_python-1.2.24.dist-info/METADATA,sha256=egTs34YJ7M4sDeYvl-3qImHQ4eDSU5Rmaa7_eiHjOF4,1682
29
- maitai_python-1.2.24.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
30
- maitai_python-1.2.24.dist-info/top_level.txt,sha256=3uBDd_HUkDZhdPkUjbHJpoKMT3YoYszkUeOLIxgjzUo,21
31
- maitai_python-1.2.24.dist-info/RECORD,,
27
+ maitai_common/config/config_service.py,sha256=XXGIfpuFBIWXFCXsei8hSn43JBIduWIEJ0lExny9Q3A,1118
28
+ maitai_python-1.2.25.dist-info/METADATA,sha256=rY-77h0WFLBN-ihGVp1JAcOe47dH5NCre9SlX73Q7aM,1682
29
+ maitai_python-1.2.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ maitai_python-1.2.25.dist-info/top_level.txt,sha256=3uBDd_HUkDZhdPkUjbHJpoKMT3YoYszkUeOLIxgjzUo,21
31
+ maitai_python-1.2.25.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5