maitai-python 1.2.14b1__tar.gz → 1.2.15__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.14b1 → maitai_python-1.2.15}/PKG-INFO +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_config.py +23 -24
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_config_listener_thread.py +9 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_maitai.py +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_maitai_async.py +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_maitai_client.py +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/version.py +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/README.md +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_context.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_inference.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_types.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/_utils.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/exceptions.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/application.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/chat.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/config.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/event.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/inference.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/key.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/models/sentinel.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/setup.cfg +0 -0
- {maitai_python-1.2.14b1 → maitai_python-1.2.15}/setup.py +0 -0
|
@@ -13,9 +13,7 @@ from maitai_common.config import config_service
|
|
|
13
13
|
|
|
14
14
|
class Config(MaitaiClient):
|
|
15
15
|
|
|
16
|
-
maitai_ws =
|
|
17
|
-
"MAITAI_WS", "wss://09hidyy627.execute-api.us-west-2.amazonaws.com/production"
|
|
18
|
-
)
|
|
16
|
+
maitai_ws = "wss://09hidyy627.execute-api.us-west-2.amazonaws.com/production"
|
|
19
17
|
config_dir = os.path.expanduser(os.environ.get("MAITAI_CONFIG_DIR", "~/.maitai"))
|
|
20
18
|
refresh_timer = None
|
|
21
19
|
|
|
@@ -55,7 +53,20 @@ class Config(MaitaiClient):
|
|
|
55
53
|
def api_key(self, value):
|
|
56
54
|
self._api_key = value
|
|
57
55
|
|
|
58
|
-
def
|
|
56
|
+
def refresh_applications(self):
|
|
57
|
+
response_json = self.init_sdk(self.api_key, self.maitai_host)
|
|
58
|
+
|
|
59
|
+
applications = [
|
|
60
|
+
Application.model_validate(app_json)
|
|
61
|
+
for app_json in response_json["applications"]
|
|
62
|
+
]
|
|
63
|
+
self._company_id = response_json.get("company_id")
|
|
64
|
+
if not self._company_id:
|
|
65
|
+
raise Exception("Company ID not found in response")
|
|
66
|
+
|
|
67
|
+
self.store_application_metadata(applications)
|
|
68
|
+
|
|
69
|
+
def initialize(self, api_key, retry=0):
|
|
59
70
|
if self.initialized and self.api_key == api_key:
|
|
60
71
|
return
|
|
61
72
|
|
|
@@ -66,21 +77,9 @@ class Config(MaitaiClient):
|
|
|
66
77
|
self.initialized = True
|
|
67
78
|
try:
|
|
68
79
|
# Call init_sdk and process the response
|
|
69
|
-
|
|
70
|
-
api_key, self.maitai_host, use_async=use_async
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
applications = [
|
|
74
|
-
Application.model_validate(app_json)
|
|
75
|
-
for app_json in response_json["applications"]
|
|
76
|
-
]
|
|
77
|
-
self._company_id = response_json.get("company_id")
|
|
78
|
-
if not self._company_id:
|
|
79
|
-
raise Exception("Company ID not found in response")
|
|
80
|
-
|
|
81
|
-
self.store_application_metadata(applications)
|
|
80
|
+
self.refresh_applications()
|
|
82
81
|
self._initialize_websocket()
|
|
83
|
-
self._start_refresh_timer(
|
|
82
|
+
self._start_refresh_timer()
|
|
84
83
|
except Exception as e:
|
|
85
84
|
self.cleanup() # Ensure cleanup on failure
|
|
86
85
|
try:
|
|
@@ -94,27 +93,27 @@ class Config(MaitaiClient):
|
|
|
94
93
|
self.refresh_timer = threading.Timer(
|
|
95
94
|
interval=2**retry,
|
|
96
95
|
function=self.initialize,
|
|
97
|
-
args=(api_key, retry + 1
|
|
96
|
+
args=(api_key, retry + 1),
|
|
98
97
|
)
|
|
99
98
|
self.refresh_timer.daemon = True
|
|
100
99
|
self.refresh_timer.start()
|
|
101
100
|
|
|
102
|
-
def _start_refresh_timer(self
|
|
101
|
+
def _start_refresh_timer(self):
|
|
103
102
|
if self.refresh_timer:
|
|
104
103
|
self.refresh_timer.cancel()
|
|
105
104
|
self.refresh_timer = threading.Timer(
|
|
106
|
-
self.refresh_interval, self._refresh_and_reschedule
|
|
105
|
+
self.refresh_interval, self._refresh_and_reschedule
|
|
107
106
|
)
|
|
108
107
|
self.refresh_timer.daemon = True
|
|
109
108
|
self.refresh_timer.start()
|
|
110
109
|
|
|
111
|
-
def _refresh_and_reschedule(self
|
|
110
|
+
def _refresh_and_reschedule(self):
|
|
112
111
|
try:
|
|
113
|
-
self.refresh_applications(
|
|
112
|
+
self.refresh_applications()
|
|
114
113
|
except Exception as e:
|
|
115
114
|
pass
|
|
116
115
|
finally:
|
|
117
|
-
self._start_refresh_timer(
|
|
116
|
+
self._start_refresh_timer()
|
|
118
117
|
|
|
119
118
|
def get_application_action_config(
|
|
120
119
|
self, application_ref_name: str, action_type: str
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import logging
|
|
3
|
+
import os
|
|
2
4
|
|
|
3
5
|
from maitai.models.application import Application
|
|
4
6
|
from maitai_common.processes.websocket_listener_thread import WebsocketListenerThread
|
|
@@ -16,8 +18,14 @@ class ConfigListenerThread(WebsocketListenerThread):
|
|
|
16
18
|
if application_json:
|
|
17
19
|
try:
|
|
18
20
|
application = Application.model_validate(application_json)
|
|
21
|
+
logging.log("Maitai received configuration change")
|
|
19
22
|
self.config.store_application_metadata([application])
|
|
20
|
-
except:
|
|
23
|
+
except Exception as e:
|
|
24
|
+
if os.environ.get("MAITAI_ENV") == "development":
|
|
25
|
+
logging.error(
|
|
26
|
+
"Error refreshing applications",
|
|
27
|
+
exc_info=e,
|
|
28
|
+
)
|
|
21
29
|
self.config.refresh_applications()
|
|
22
30
|
else:
|
|
23
31
|
self.config.refresh_applications()
|
|
@@ -78,7 +78,7 @@ class Maitai:
|
|
|
78
78
|
if not maitai_api_key:
|
|
79
79
|
maitai_api_key = os.environ.get("MAITAI_API_KEY")
|
|
80
80
|
if maitai_api_key:
|
|
81
|
-
config.initialize(maitai_api_key
|
|
81
|
+
config.initialize(maitai_api_key)
|
|
82
82
|
else:
|
|
83
83
|
raise ValueError(
|
|
84
84
|
"MAITAI_API_KEY has not been set. Either set via environment variable or pass it directly into the client."
|
|
@@ -78,7 +78,7 @@ class MaitaiAsync:
|
|
|
78
78
|
if not maitai_api_key:
|
|
79
79
|
maitai_api_key = os.environ.get("MAITAI_API_KEY")
|
|
80
80
|
if maitai_api_key:
|
|
81
|
-
config.initialize(maitai_api_key
|
|
81
|
+
config.initialize(maitai_api_key)
|
|
82
82
|
else:
|
|
83
83
|
raise ValueError(
|
|
84
84
|
"MAITAI_API_KEY has not been set. Either set via environment variable or pass it directly into the client."
|
|
@@ -173,7 +173,7 @@ class MaitaiClient:
|
|
|
173
173
|
except:
|
|
174
174
|
pass
|
|
175
175
|
|
|
176
|
-
def init_sdk(self, api_key: str, host: str
|
|
176
|
+
def init_sdk(self, api_key: str, host: str):
|
|
177
177
|
url = f"{host}/config/init_sdk"
|
|
178
178
|
headers = {
|
|
179
179
|
"Content-Type": "application/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
|
{maitai_python-1.2.14b1 → maitai_python-1.2.15}/maitai_common/processes/websocket_listener_thread.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|