maitai-python 1.2.24__tar.gz → 1.2.25__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.24 → maitai_python-1.2.25}/PKG-INFO +1 -1
  2. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_inference.py +6 -2
  3. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_maitai.py +1 -7
  4. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_maitai_async.py +1 -7
  5. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_maitai_client.py +4 -41
  6. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_common/config/config_service.py +1 -1
  7. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_common/version.py +1 -1
  8. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_python.egg-info/PKG-INFO +1 -1
  9. {maitai_python-1.2.24 → maitai_python-1.2.25}/README.md +0 -0
  10. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/__init__.py +0 -0
  11. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_config.py +0 -0
  12. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_config_listener.py +0 -0
  13. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_context.py +0 -0
  14. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_evaluator.py +0 -0
  15. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_pydantic.py +0 -0
  16. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_types.py +0 -0
  17. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/_utils.py +0 -0
  18. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/exceptions.py +0 -0
  19. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/__init__.py +0 -0
  20. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/application.py +0 -0
  21. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/chat.py +0 -0
  22. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/config.py +0 -0
  23. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/event.py +0 -0
  24. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/inference.py +0 -0
  25. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/key.py +0 -0
  26. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/metric.py +0 -0
  27. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/models/sentinel.py +0 -0
  28. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai/tools/__init__.py +0 -0
  29. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_common/__init__.py +0 -0
  30. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_common/config/__init__.py +0 -0
  31. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_python.egg-info/SOURCES.txt +0 -0
  32. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_python.egg-info/dependency_links.txt +0 -0
  33. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_python.egg-info/requires.txt +0 -0
  34. {maitai_python-1.2.24 → maitai_python-1.2.25}/maitai_python.egg-info/top_level.txt +0 -0
  35. {maitai_python-1.2.24 → maitai_python-1.2.25}/setup.cfg +0 -0
  36. {maitai_python-1.2.24 → maitai_python-1.2.25}/setup.py +0 -0
@@ -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
@@ -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
 
@@ -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 (
@@ -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 (
@@ -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
@@ -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
File without changes
File without changes
File without changes