maitai-python 1.2.10b0__tar.gz → 1.2.12__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.10b0 → maitai_python-1.2.12}/PKG-INFO +1 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_maitai.py +3 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/application.py +1 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/chat.py +9 -5
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/inference.py +1 -1
- maitai_python-1.2.12/maitai/models/sentinel.py +67 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/tools/__init__.py +4 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/config/config_service.py +1 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/processes/io_thread.py +6 -2
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/version.py +1 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_python.egg-info/SOURCES.txt +1 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/README.md +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/__init__.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_config.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_context.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_inference.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_maitai_async.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_types.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/_utils.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/config.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/event.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/key.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/setup.cfg +0 -0
- {maitai_python-1.2.10b0 → maitai_python-1.2.12}/setup.py +0 -0
|
@@ -439,6 +439,9 @@ class Completions:
|
|
|
439
439
|
"type": "json_schema",
|
|
440
440
|
"json_schema": type_to_response_format_param(response_format),
|
|
441
441
|
}
|
|
442
|
+
if isinstance(tools, Tools):
|
|
443
|
+
tools = tools.get_tool_definitions()
|
|
444
|
+
|
|
442
445
|
response = self._client.chat.completions.create(
|
|
443
446
|
messages=messages,
|
|
444
447
|
model=model,
|
|
@@ -5,8 +5,8 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
5
5
|
|
|
6
6
|
from pydantic import BaseModel, ConfigDict, Field
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
8
|
+
from maitai.models import application as application_types
|
|
9
|
+
from maitai.models import config, key, metric, sentinel
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class EvaluationProvider(Enum):
|
|
@@ -39,6 +39,7 @@ class ChatCompletionAuth(BaseModel):
|
|
|
39
39
|
azure_api_key: Optional[str] = ""
|
|
40
40
|
sambanova_api_key: Optional[str] = ""
|
|
41
41
|
|
|
42
|
+
|
|
42
43
|
class Property(BaseModel):
|
|
43
44
|
type: Union[str, List[str]] = ""
|
|
44
45
|
description: Optional[str] = None
|
|
@@ -143,9 +144,11 @@ class ChatCompletionParams(BaseModel):
|
|
|
143
144
|
class ChatCompletionRequest(BaseModel):
|
|
144
145
|
params: ChatCompletionParams = None
|
|
145
146
|
application_ref_name: str = None
|
|
147
|
+
application_id: Optional[int] = None
|
|
146
148
|
session_id: str = None
|
|
147
149
|
reference_id: Optional[Union[str, int]] = None
|
|
148
150
|
action_type: str = None
|
|
151
|
+
application_action_id: Optional[int] = None
|
|
149
152
|
company_id: Optional[int] = None
|
|
150
153
|
apply_corrections: Optional[bool] = False
|
|
151
154
|
id: Optional[int] = None
|
|
@@ -160,13 +163,14 @@ class ChatCompletionRequest(BaseModel):
|
|
|
160
163
|
context_retrieval_enabled: Optional[bool] = False
|
|
161
164
|
context_query: Optional[str] = None
|
|
162
165
|
context: Optional[str] = None
|
|
163
|
-
return_request: Optional[bool] = False
|
|
166
|
+
return_request: Optional[bool] = Field(default=False)
|
|
164
167
|
fallback_model: Optional[str] = None
|
|
165
168
|
user_id: Optional[str] = None
|
|
166
169
|
assistant: Optional[bool] = False
|
|
167
170
|
client_params: Optional[ClientParams] = None
|
|
168
171
|
metadata: Optional[Dict[str, Any]] = None
|
|
169
|
-
safe_mode: Optional[bool] = False
|
|
172
|
+
safe_mode: Optional[bool] = Field(default=False)
|
|
173
|
+
preserve_model_alias: Optional[bool] = False
|
|
170
174
|
fallback_config: Optional[config.FallbackConfig] = None
|
|
171
175
|
|
|
172
176
|
|
|
@@ -314,7 +318,7 @@ class ChatCompletionChunk(BaseModel):
|
|
|
314
318
|
created: int = 0
|
|
315
319
|
model: str = ""
|
|
316
320
|
object: str = ""
|
|
317
|
-
system_fingerprint: str = ""
|
|
321
|
+
system_fingerprint: Optional[str] = ""
|
|
318
322
|
usage: Optional[ChatCompletionUsage] = None
|
|
319
323
|
evaluate_response: Optional[EvaluateResponse] = None
|
|
320
324
|
correction_applied: bool = False
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# codegen: frontend, sdk
|
|
2
|
+
from enum import IntEnum
|
|
3
|
+
from typing import Any, Dict, List, Optional, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SeverityLevel(IntEnum):
|
|
9
|
+
UNRECOGNIZED = 0
|
|
10
|
+
INFO = 1
|
|
11
|
+
WARN = 2
|
|
12
|
+
ERROR = 3
|
|
13
|
+
FATAL = 4
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class SentinelExample(BaseModel):
|
|
17
|
+
example_type: str
|
|
18
|
+
example_body: str
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DirectiveBody(BaseModel):
|
|
22
|
+
main: Optional[str] = None
|
|
23
|
+
override: Optional[str] = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SentinelDirective(BaseModel):
|
|
27
|
+
id: Optional[int] = -1
|
|
28
|
+
sentinel_id: Optional[int] = None
|
|
29
|
+
date_created: Optional[Union[int, float]] = 0
|
|
30
|
+
directive_body: DirectiveBody
|
|
31
|
+
examples: List[SentinelExample] = Field(default_factory=list)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class SentinelQa(BaseModel):
|
|
35
|
+
question: str
|
|
36
|
+
answer: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Sentinel(BaseModel):
|
|
40
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
41
|
+
|
|
42
|
+
id: Optional[int] = -1
|
|
43
|
+
application_id: Optional[int] = None
|
|
44
|
+
sentinel_name: str
|
|
45
|
+
date_created: Optional[Union[int, float]] = 0
|
|
46
|
+
sentinel_directive: Optional[SentinelDirective] = None
|
|
47
|
+
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
|
+
sentinel_generation_id: Optional[int] = None
|
|
52
|
+
qa: List[SentinelQa] = Field(default_factory=list)
|
|
53
|
+
intent_group_id: Optional[int] = None
|
|
54
|
+
sentinel_type: Optional[str] = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class SentinelGeneration(BaseModel):
|
|
58
|
+
id: Optional[int] = -1
|
|
59
|
+
date_created: Optional[Union[int, float]] = 0
|
|
60
|
+
company_id: int = 0
|
|
61
|
+
application_id: Optional[int] = None
|
|
62
|
+
application_action_id: Optional[int] = None
|
|
63
|
+
base_prompt: str
|
|
64
|
+
meta: Dict[str, Any] = Field(default_factory=dict)
|
|
65
|
+
generation_successful: bool = False
|
|
66
|
+
intent_group_id: Optional[int] = None
|
|
67
|
+
sentinel_type: Optional[str] = None
|
|
@@ -24,7 +24,10 @@ class Tools:
|
|
|
24
24
|
if tool_call.function.name not in self.available_functions:
|
|
25
25
|
raise TypeError(f"Function {tool_call.function.name} is not defined")
|
|
26
26
|
function_to_call = self.available_functions[tool_call.function.name]
|
|
27
|
-
|
|
27
|
+
try:
|
|
28
|
+
function_args = json.loads(tool_call.function.arguments)
|
|
29
|
+
except json.JSONDecodeError:
|
|
30
|
+
function_args = {}
|
|
28
31
|
function_args.update(override_args)
|
|
29
32
|
function_response = function_to_call(**function_args)
|
|
30
33
|
return function_response
|
|
@@ -27,14 +27,15 @@ class IOThread(Thread):
|
|
|
27
27
|
async def main_loop(self):
|
|
28
28
|
await asyncio.sleep(self.interval)
|
|
29
29
|
while self.run_thread:
|
|
30
|
-
await self.
|
|
30
|
+
await self.process_loop()
|
|
31
31
|
|
|
32
|
-
async def
|
|
32
|
+
async def process_loop(self):
|
|
33
33
|
if self.run_thread:
|
|
34
34
|
self.last_loop_start = time.time()
|
|
35
35
|
self.is_running = True
|
|
36
36
|
try:
|
|
37
37
|
self.process()
|
|
38
|
+
await self.process_async()
|
|
38
39
|
except Exception as e:
|
|
39
40
|
self.print(
|
|
40
41
|
e,
|
|
@@ -62,6 +63,9 @@ class IOThread(Thread):
|
|
|
62
63
|
def process(self):
|
|
63
64
|
return None
|
|
64
65
|
|
|
66
|
+
async def process_async(self):
|
|
67
|
+
return None
|
|
68
|
+
|
|
65
69
|
def initialize(self):
|
|
66
70
|
self.initialized = True
|
|
67
71
|
|
|
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.10b0 → maitai_python-1.2.12}/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
|