maitai-python 1.1.20b3__tar.gz → 1.1.21__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 (50) hide show
  1. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/PKG-INFO +2 -2
  2. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/README.md +1 -1
  3. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_config.py +0 -4
  4. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_context.py +6 -5
  5. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_maitai.py +7 -4
  6. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_maitai_async.py +22 -16
  7. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/version.py +1 -1
  8. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_python.egg-info/PKG-INFO +2 -2
  9. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/__init__.py +0 -0
  10. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_azure.py +0 -0
  11. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_config_listener_thread.py +0 -0
  12. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_evaluator.py +0 -0
  13. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_inference.py +0 -0
  14. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_maitai_client.py +0 -0
  15. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_types.py +0 -0
  16. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/_utils.py +0 -0
  17. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai/tools/__init__.py +0 -0
  18. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/__init__.py +0 -0
  19. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/config/__init__.py +0 -0
  20. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/config/config_service.py +0 -0
  21. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/processes/__init__.py +0 -0
  22. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/processes/io_thread.py +0 -0
  23. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/processes/websocket_listener_thread.py +0 -0
  24. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/utils/__init__.py +0 -0
  25. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/utils/proto_utils.py +0 -0
  26. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_common/utils/types.py +0 -0
  27. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/__init__.py +0 -0
  28. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/application/__init__.py +0 -0
  29. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/backtest/__init__.py +0 -0
  30. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/billing/__init__.py +0 -0
  31. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/chat/__init__.py +0 -0
  32. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/company/__init__.py +0 -0
  33. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/config/__init__.py +0 -0
  34. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/embedding/__init__.py +0 -0
  35. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/event/__init__.py +0 -0
  36. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/inference/__init__.py +0 -0
  37. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/key/__init__.py +0 -0
  38. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/metric/__init__.py +0 -0
  39. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/model/__init__.py +0 -0
  40. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/notification/__init__.py +0 -0
  41. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/rates/__init__.py +0 -0
  42. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/sandbox/__init__.py +0 -0
  43. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/sentinel/__init__.py +0 -0
  44. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_gen/session/__init__.py +0 -0
  45. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_python.egg-info/SOURCES.txt +0 -0
  46. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_python.egg-info/dependency_links.txt +0 -0
  47. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_python.egg-info/requires.txt +0 -0
  48. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/maitai_python.egg-info/top_level.txt +0 -0
  49. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/setup.cfg +0 -0
  50. {maitai_python-1.1.20b3 → maitai_python-1.1.21}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.1.20b3
3
+ Version: 1.1.21
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -46,7 +46,7 @@ response = maitai.chat.completions.create(
46
46
  model="llama3-70b-8192", ## Remove this line to set model in Portal
47
47
  session_id="YOUR_SESSION_ID",
48
48
  intent="CONVERSATION",
49
- application_ref_name="YOUR_APPLICATION_REF_NAME",
49
+ application="YOUR_APPLICATION_NAME",
50
50
  )
51
51
  ```
52
52
 
@@ -27,7 +27,7 @@ response = maitai.chat.completions.create(
27
27
  model="llama3-70b-8192", ## Remove this line to set model in Portal
28
28
  session_id="YOUR_SESSION_ID",
29
29
  intent="CONVERSATION",
30
- application_ref_name="YOUR_APPLICATION_REF_NAME",
30
+ application="YOUR_APPLICATION_NAME",
31
31
  )
32
32
  ```
33
33
 
@@ -18,19 +18,16 @@ from maitai_gen.key import Key, KeyMap
18
18
 
19
19
  def _get_aws_instance_metadata(url, timeout=2):
20
20
  try:
21
- # First, try to get a token for IMDSv2
22
21
  token_url = "http://169.254.169.254/latest/api/token"
23
22
  token_headers = {"X-aws-ec2-metadata-token-ttl-seconds": "21600"}
24
23
  token_response = requests.put(token_url, headers=token_headers, timeout=timeout)
25
24
 
26
25
  if token_response.status_code == 200:
27
- # If we got a token, use it to request the metadata
28
26
  token = token_response.text
29
27
  headers = {"X-aws-ec2-metadata-token": token}
30
28
  else:
31
29
  headers = None
32
30
 
33
- # Make the actual metadata request
34
31
  response = requests.get(url, headers=headers, timeout=timeout)
35
32
  response.raise_for_status()
36
33
  return response.text
@@ -68,7 +65,6 @@ class Config:
68
65
  config_dir = os.path.expanduser(os.environ.get("MAITAI_CONFIG_DIR", "~/.maitai"))
69
66
 
70
67
  def __init__(self):
71
- print("INITIALIZING HOST WITH", self.maitai_host)
72
68
  retry_strategy = Retry(
73
69
  total=3,
74
70
  backoff_factor=1
@@ -4,14 +4,15 @@ import requests
4
4
  from betterproto import Casing
5
5
 
6
6
  from maitai._config import config
7
- from maitai._utils import __version__ as version, required_args
7
+ from maitai._utils import __version__ as version
8
+ from maitai._utils import required_args
8
9
  from maitai_gen.application import ApplicationContext
9
10
 
10
11
 
11
12
  class ContextManager:
12
- @required_args(["application_ref_name", "reference", "context_body"],
13
- ["application_ref_name", "reference", "file_path"])
14
- def update(self, *, application_ref_name: str, reference: str, context_body: str = '', file_path: str = ''):
13
+ @required_args(["application", "reference", "context_body"],
14
+ ["application", "reference", "file_path"])
15
+ def update(self, *, application: str, reference: str, context_body: str = '', file_path: str = ''):
15
16
  if not reference:
16
17
  raise ValueError("Reference is required")
17
18
  if context_body and file_path:
@@ -37,7 +38,7 @@ class ContextManager:
37
38
  'x-client-version': version,
38
39
  }
39
40
  response = requests.put(url, headers=headers, data=json.dumps({
40
- 'application_ref_name': application_ref_name,
41
+ 'application_ref_name': application,
41
42
  'context': context.to_pydict(casing=Casing.SNAKE),
42
43
  }))
43
44
 
@@ -97,11 +97,11 @@ class Completions:
97
97
  self._client = client
98
98
  self._client_params = client_params or ClientParams()
99
99
 
100
- @required_args(["action_type", "application_ref_name", "messages"],
100
+ @required_args(["intent", "application", "messages"],
101
101
  ["intent", "application_ref_name", "messages"],
102
- ["action_type", "application_ref_name", "messages", "model"],
102
+ ["intent", "application", "messages", "model"],
103
103
  ["intent", "application_ref_name", "messages", "model"],
104
- ["action_type", "application_ref_name", "messages", "model", "stream"],
104
+ ["intent", "application", "messages", "model", "stream"],
105
105
  ["intent", "application_ref_name", "messages", "model", "stream"])
106
106
  def create(
107
107
  self,
@@ -112,7 +112,8 @@ class Completions:
112
112
  reference_id: Union[str, int, None] = None,
113
113
  intent: str = None,
114
114
  action_type: str = None, # DEPRECATED
115
- application_ref_name: str = None,
115
+ application_ref_name: str = None, # DEPRECATED
116
+ application: str = None,
116
117
  callback: Optional[EvaluateCallback] = None,
117
118
  server_side_inference: bool = None,
118
119
  evaluation_enabled: bool = None,
@@ -172,6 +173,8 @@ class Completions:
172
173
  session_id = str(uuid.uuid4())
173
174
  if not intent and action_type:
174
175
  intent = action_type
176
+ if not application_ref_name and application:
177
+ application_ref_name = application
175
178
  maitai_config = config.get_application_action_config(application_ref_name, intent)
176
179
  if server_side_inference is None:
177
180
  server_side_inference = maitai_config.inference_location == InferenceLocations.SERVER
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import time
2
3
  import uuid
3
4
  import warnings
@@ -61,18 +62,20 @@ class MaitaiAsync:
61
62
  config.auth_keys.groq_api_key.key_value = groq_api_key
62
63
  if anthropic_api_key:
63
64
  config.auth_keys.anthropic_api_key.key_value = anthropic_api_key
64
- self._client = openai.AsyncClient(
65
- api_key=api_key or openai_api_key,
66
- organization=organization,
67
- project=project,
68
- base_url=base_url,
69
- timeout=timeout,
70
- max_retries=max_retries,
71
- default_headers=default_headers,
72
- default_query=default_query,
73
- http_client=http_client,
74
- _strict_response_validation=_strict_response_validation,
75
- )
65
+ self._client = None
66
+ if api_key or openai_api_key or os.environ.get("OPENAI_API_KEY"):
67
+ self._client = openai.AsyncClient(
68
+ api_key=api_key or openai_api_key or os.environ.get("OPENAI_API_KEY"),
69
+ organization=organization,
70
+ project=project,
71
+ base_url=base_url,
72
+ timeout=timeout,
73
+ max_retries=max_retries,
74
+ default_headers=default_headers,
75
+ default_query=default_query,
76
+ http_client=http_client,
77
+ _strict_response_validation=_strict_response_validation,
78
+ )
76
79
 
77
80
  client_params = None
78
81
  if base_url or default_headers or default_query:
@@ -94,11 +97,11 @@ class AsyncCompletions:
94
97
  self._client = client
95
98
  self._client_params = client_params or ClientParams()
96
99
 
97
- @required_args(["action_type", "application_ref_name", "messages"],
100
+ @required_args(["intent", "application", "messages"],
98
101
  ["intent", "application_ref_name", "messages"],
99
- ["action_type", "application_ref_name", "messages", "model"],
102
+ ["intent", "application", "messages", "model"],
100
103
  ["intent", "application_ref_name", "messages", "model"],
101
- ["action_type", "application_ref_name", "messages", "model", "stream"],
104
+ ["intent", "application", "messages", "model", "stream"],
102
105
  ["intent", "application_ref_name", "messages", "model", "stream"])
103
106
  async def create(
104
107
  self,
@@ -109,7 +112,8 @@ class AsyncCompletions:
109
112
  reference_id: Union[str, int, None] = None,
110
113
  intent: str = None,
111
114
  action_type: str = None, # DEPRECATED
112
- application_ref_name: str = None,
115
+ application_ref_name: str = None, # DEPRECATED
116
+ application: str = None,
113
117
  callback: Optional[EvaluateCallback] = None,
114
118
  server_side_inference: bool = None,
115
119
  evaluation_enabled: bool = None,
@@ -167,6 +171,8 @@ class AsyncCompletions:
167
171
  session_id = str(uuid.uuid4())
168
172
  if action_type and not intent:
169
173
  intent = action_type
174
+ if not application_ref_name and application:
175
+ application_ref_name = application
170
176
  maitai_config = config.get_application_action_config(application_ref_name, intent)
171
177
  if server_side_inference is None:
172
178
  server_side_inference = maitai_config.inference_location == InferenceLocations.SERVER
@@ -1,3 +1,3 @@
1
- version = "1.1.20b3"
1
+ version = "1.1.21"
2
2
  if __name__ == "__main__":
3
3
  print(version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maitai-python
3
- Version: 1.1.20b3
3
+ Version: 1.1.21
4
4
  Summary: Maitai SDK for Python
5
5
  Home-page: https://docs.trymaitai.ai
6
6
  Author: Maitai
@@ -46,7 +46,7 @@ response = maitai.chat.completions.create(
46
46
  model="llama3-70b-8192", ## Remove this line to set model in Portal
47
47
  session_id="YOUR_SESSION_ID",
48
48
  intent="CONVERSATION",
49
- application_ref_name="YOUR_APPLICATION_REF_NAME",
49
+ application="YOUR_APPLICATION_NAME",
50
50
  )
51
51
  ```
52
52