maitai-python 1.2.17b0__tar.gz → 1.2.18__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.17b0 → maitai_python-1.2.18}/PKG-INFO +1 -1
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_config_listener.py +30 -19
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_maitai.py +3 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_maitai_async.py +5 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_utils.py +2 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/chat.py +3 -2
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/config.py +1 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/sentinel.py +5 -4
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_common/version.py +1 -1
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/README.md +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/__init__.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_config.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_context.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_inference.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/_types.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/exceptions.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/application.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/event.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/inference.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/key.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/setup.cfg +0 -0
- {maitai_python-1.2.17b0 → maitai_python-1.2.18}/setup.py +0 -0
|
@@ -7,6 +7,8 @@ import websocket
|
|
|
7
7
|
|
|
8
8
|
from maitai.models.application import Application
|
|
9
9
|
|
|
10
|
+
logging.getLogger("websocket").setLevel(logging.FATAL)
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
class ConfigListener:
|
|
12
14
|
def __init__(self, config, path, type, key=None):
|
|
@@ -18,17 +20,18 @@ class ConfigListener:
|
|
|
18
20
|
self.ws = None
|
|
19
21
|
self.ws_thread = None
|
|
20
22
|
self.running = False
|
|
23
|
+
self.logger = logging.getLogger("maitai")
|
|
21
24
|
|
|
22
25
|
def on_message(self, ws, message):
|
|
23
26
|
event = json.loads(message)
|
|
24
27
|
if event.get("event_type") == "APPLICATION_CONFIG_CHANGE":
|
|
25
|
-
application_json = event.get("event_data")
|
|
28
|
+
application_json = json.loads(event.get("event_data"))
|
|
26
29
|
if application_json:
|
|
27
30
|
try:
|
|
28
|
-
application = Application.model_validate(
|
|
29
|
-
|
|
31
|
+
application = Application.model_validate(application_json)
|
|
32
|
+
self.logger.info(
|
|
33
|
+
"Maitai config listener: received configuration change"
|
|
30
34
|
)
|
|
31
|
-
logging.log("Maitai received configuration change")
|
|
32
35
|
self.config.store_application_metadata([application])
|
|
33
36
|
except Exception as e:
|
|
34
37
|
if os.environ.get("MAITAI_ENV") in [
|
|
@@ -36,8 +39,8 @@ class ConfigListener:
|
|
|
36
39
|
"staging",
|
|
37
40
|
"prod",
|
|
38
41
|
]:
|
|
39
|
-
|
|
40
|
-
"
|
|
42
|
+
self.logger.error(
|
|
43
|
+
"Maitai config listener: error refreshing applications",
|
|
41
44
|
exc_info=e,
|
|
42
45
|
)
|
|
43
46
|
self.config.refresh_applications()
|
|
@@ -46,21 +49,21 @@ class ConfigListener:
|
|
|
46
49
|
|
|
47
50
|
def on_error(self, ws, error):
|
|
48
51
|
if not isinstance(error, (AttributeError, ConnectionError)):
|
|
49
|
-
|
|
52
|
+
self.logger.error("Maitai config listener: websocket error", exc_info=error)
|
|
50
53
|
|
|
51
54
|
def on_close(self, ws, close_status_code, close_msg):
|
|
52
|
-
|
|
53
|
-
f"Maitai config websocket connection closed: {close_status_code} {close_msg}"
|
|
55
|
+
self.logger.info(
|
|
56
|
+
f"Maitai config listener: websocket connection closed: {close_status_code} {close_msg}"
|
|
54
57
|
)
|
|
55
58
|
|
|
56
59
|
def on_open(self, ws):
|
|
57
|
-
|
|
60
|
+
self.logger.info("Maitai config listener: websocket connection established")
|
|
58
61
|
|
|
59
62
|
def _websocket_thread(self):
|
|
60
63
|
"""Run the websocket client in a thread with automatic reconnection."""
|
|
61
64
|
retry_count = 0
|
|
62
65
|
max_retries = 10
|
|
63
|
-
reconnect_delay =
|
|
66
|
+
reconnect_delay = 0.1 # Start with 100ms
|
|
64
67
|
|
|
65
68
|
while self.running and retry_count < max_retries:
|
|
66
69
|
try:
|
|
@@ -79,17 +82,23 @@ class ConfigListener:
|
|
|
79
82
|
# If we get here, connection closed - retry with backoff if still running
|
|
80
83
|
if self.running:
|
|
81
84
|
retry_count += 1
|
|
82
|
-
# Exponential backoff with max of
|
|
83
|
-
retry_delay = min(reconnect_delay * (2**retry_count),
|
|
84
|
-
|
|
85
|
+
# Exponential backoff with max of 2 seconds
|
|
86
|
+
retry_delay = min(reconnect_delay * (2**retry_count), 2)
|
|
87
|
+
self.logger.info(
|
|
88
|
+
f"Maitai config listener: websocket reconnecting in {retry_delay} seconds..."
|
|
89
|
+
)
|
|
85
90
|
threading.Event().wait(retry_delay)
|
|
86
91
|
except Exception as e:
|
|
87
|
-
|
|
92
|
+
self.logger.error(
|
|
93
|
+
"Maitai config listener error in websocket thread", exc_info=e
|
|
94
|
+
)
|
|
88
95
|
if self.running:
|
|
89
96
|
retry_count += 1
|
|
90
|
-
# Exponential backoff with max of
|
|
91
|
-
retry_delay = min(reconnect_delay * (2**retry_count),
|
|
92
|
-
|
|
97
|
+
# Exponential backoff with max of 2 seconds
|
|
98
|
+
retry_delay = min(reconnect_delay * (2**retry_count), 2)
|
|
99
|
+
self.logger.info(
|
|
100
|
+
f"Maitai config listener: websocket reconnecting in {retry_delay} seconds..."
|
|
101
|
+
)
|
|
93
102
|
threading.Event().wait(retry_delay)
|
|
94
103
|
|
|
95
104
|
def _reconnect(self):
|
|
@@ -128,7 +137,9 @@ class ConfigListener:
|
|
|
128
137
|
try:
|
|
129
138
|
self.ws.close()
|
|
130
139
|
except Exception as e:
|
|
131
|
-
|
|
140
|
+
self.logger.debug(
|
|
141
|
+
"Maitai config listener: error closing websocket", exc_info=e
|
|
142
|
+
)
|
|
132
143
|
|
|
133
144
|
# Wait for the thread to finish
|
|
134
145
|
if self.ws_thread and self.ws_thread.is_alive():
|
|
@@ -240,6 +240,7 @@ class Completions:
|
|
|
240
240
|
max_completion_tokens: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
241
241
|
n: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
242
242
|
presence_penalty: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
243
|
+
reasoning_effort: Optional[str] = openai.NOT_GIVEN,
|
|
243
244
|
response_format: Union[
|
|
244
245
|
openai_chat_types.completion_create_params.ResponseFormat, openai.NotGiven
|
|
245
246
|
] = openai.NOT_GIVEN,
|
|
@@ -379,6 +380,7 @@ class Completions:
|
|
|
379
380
|
user=user,
|
|
380
381
|
parallel_tool_calls=parallel_tool_calls,
|
|
381
382
|
extra_headers=extra_headers,
|
|
383
|
+
reasoning_effort=reasoning_effort,
|
|
382
384
|
)
|
|
383
385
|
if server_side_inference:
|
|
384
386
|
response_timeout = None
|
|
@@ -484,6 +486,7 @@ class Completions:
|
|
|
484
486
|
max_tokens=max_tokens,
|
|
485
487
|
n=n,
|
|
486
488
|
presence_penalty=presence_penalty,
|
|
489
|
+
reasoning_effort=reasoning_effort,
|
|
487
490
|
response_format=response_format,
|
|
488
491
|
seed=seed,
|
|
489
492
|
stop=stop,
|
|
@@ -221,6 +221,7 @@ class AsyncCompletions:
|
|
|
221
221
|
metadata: dict = {},
|
|
222
222
|
safe_mode: bool = None,
|
|
223
223
|
fallback_config: FallbackConfig = None,
|
|
224
|
+
return_request: bool = False,
|
|
224
225
|
# OpenAI Arguments
|
|
225
226
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
226
227
|
model: Union[str, openai_types.ChatModel, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -238,6 +239,7 @@ class AsyncCompletions:
|
|
|
238
239
|
max_completion_tokens: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
239
240
|
n: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
240
241
|
presence_penalty: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
242
|
+
reasoning_effort: Optional[str] = openai.NOT_GIVEN,
|
|
241
243
|
response_format: Union[
|
|
242
244
|
openai_chat_types.completion_create_params.ResponseFormat, openai.NotGiven
|
|
243
245
|
] = openai.NOT_GIVEN,
|
|
@@ -377,6 +379,7 @@ class AsyncCompletions:
|
|
|
377
379
|
user=user,
|
|
378
380
|
parallel_tool_calls=parallel_tool_calls,
|
|
379
381
|
extra_headers=extra_headers,
|
|
382
|
+
reasoning_effort=reasoning_effort,
|
|
380
383
|
)
|
|
381
384
|
if server_side_inference:
|
|
382
385
|
response_timeout = None
|
|
@@ -399,6 +402,7 @@ class AsyncCompletions:
|
|
|
399
402
|
"auth_keys": config.auth_keys.model_dump(),
|
|
400
403
|
"metadata": metadata,
|
|
401
404
|
"safe_mode": safe_mode,
|
|
405
|
+
"return_request": return_request,
|
|
402
406
|
}
|
|
403
407
|
|
|
404
408
|
if self._client_params is not None:
|
|
@@ -478,6 +482,7 @@ class AsyncCompletions:
|
|
|
478
482
|
max_tokens=max_tokens,
|
|
479
483
|
n=n,
|
|
480
484
|
presence_penalty=presence_penalty,
|
|
485
|
+
reasoning_effort=reasoning_effort,
|
|
481
486
|
response_format=response_format,
|
|
482
487
|
seed=seed,
|
|
483
488
|
stop=stop,
|
|
@@ -176,6 +176,7 @@ def get_chat_completion_params(
|
|
|
176
176
|
top_p: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
177
177
|
user: Union[str, openai.NotGiven] = openai.NOT_GIVEN,
|
|
178
178
|
parallel_tool_calls: Union[bool, openai.NotGiven] = openai.NOT_GIVEN,
|
|
179
|
+
reasoning_effort: Optional[str] = openai.NOT_GIVEN,
|
|
179
180
|
extra_headers: Optional[Dict[str, str]] = None,
|
|
180
181
|
) -> Dict[str, Any]:
|
|
181
182
|
params = {
|
|
@@ -203,6 +204,7 @@ def get_chat_completion_params(
|
|
|
203
204
|
"user": user,
|
|
204
205
|
"tool_choice": tool_choice,
|
|
205
206
|
"parallel_tool_calls": parallel_tool_calls,
|
|
207
|
+
"reasoning_effort": reasoning_effort,
|
|
206
208
|
"extra_headers": extra_headers,
|
|
207
209
|
}
|
|
208
210
|
|
|
@@ -145,10 +145,11 @@ class ChatCompletionParams(BaseModel):
|
|
|
145
145
|
class ChatCompletionRequest(BaseModel):
|
|
146
146
|
params: ChatCompletionParams = None
|
|
147
147
|
application_ref_name: str = None
|
|
148
|
-
application_id: Optional[int] = None
|
|
149
148
|
session_id: str = None
|
|
150
|
-
reference_id: Optional[Union[str, int]] = None
|
|
151
149
|
action_type: str = None
|
|
150
|
+
|
|
151
|
+
application_id: Optional[int] = None
|
|
152
|
+
reference_id: Optional[Union[str, int]] = None
|
|
152
153
|
application_action_id: Optional[int] = None
|
|
153
154
|
company_id: Optional[int] = None
|
|
154
155
|
apply_corrections: Optional[bool] = False
|
|
@@ -25,6 +25,7 @@ class Config(BaseModel):
|
|
|
25
25
|
inference_location: InferenceLocations = InferenceLocations.SERVER
|
|
26
26
|
evaluation_enabled: bool = True
|
|
27
27
|
apply_corrections: bool = False
|
|
28
|
+
# model: str = "gpt-o1"
|
|
28
29
|
model: str = "gpt-4o"
|
|
29
30
|
temperature: float = 1
|
|
30
31
|
streaming: bool = False
|
|
@@ -38,6 +38,11 @@ class SentinelQa(BaseModel):
|
|
|
38
38
|
|
|
39
39
|
class Sentinel(BaseModel):
|
|
40
40
|
model_config = ConfigDict(use_enum_values=True)
|
|
41
|
+
sentinel_name: str
|
|
42
|
+
action_types: List[str] = None
|
|
43
|
+
severity: Union[SeverityLevel, int]
|
|
44
|
+
meta: Dict[str, Any] = Field(default_factory=dict)
|
|
45
|
+
qa: List[SentinelQa] = Field(default_factory=list)
|
|
41
46
|
|
|
42
47
|
id: Optional[int] = -1
|
|
43
48
|
application_id: Optional[int] = None
|
|
@@ -45,11 +50,7 @@ class Sentinel(BaseModel):
|
|
|
45
50
|
date_created: Optional[float] = 0
|
|
46
51
|
sentinel_directive: Optional[SentinelDirective] = None
|
|
47
52
|
state: Optional[str] = None
|
|
48
|
-
action_types: List[str] = None
|
|
49
|
-
severity: Union[SeverityLevel, int]
|
|
50
|
-
meta: Dict[str, Any] = Field(default_factory=dict)
|
|
51
53
|
sentinel_generation_id: Optional[int] = None
|
|
52
|
-
qa: List[SentinelQa] = Field(default_factory=list)
|
|
53
54
|
intent_group_id: Optional[int] = None
|
|
54
55
|
sentinel_type: Optional[str] = None
|
|
55
56
|
|
|
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
|
|
File without changes
|
|
File without changes
|