maitai-python 1.2.8b2__tar.gz → 1.2.9__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.8b2 → maitai_python-1.2.9}/PKG-INFO +1 -1
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_config_listener_thread.py +1 -1
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/application.py +2 -2
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/chat.py +17 -17
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/config.py +1 -1
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/processes/websocket_listener_thread.py +24 -21
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/version.py +1 -1
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/README.md +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_config.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_context.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_evaluator.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_inference.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_maitai.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_maitai_async.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_pydantic.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_types.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/_utils.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/event.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/inference.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/key.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/models/metric.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/setup.cfg +0 -0
- {maitai_python-1.2.8b2 → maitai_python-1.2.9}/setup.py +0 -0
|
@@ -6,7 +6,7 @@ from maitai_common.processes.websocket_listener_thread import WebsocketListenerT
|
|
|
6
6
|
|
|
7
7
|
class ConfigListenerThread(WebsocketListenerThread):
|
|
8
8
|
def __init__(self, config, path, type, key=None):
|
|
9
|
-
super(ConfigListenerThread, self).__init__(path, type, key)
|
|
9
|
+
super(ConfigListenerThread, self).__init__(path, type, key, interval=600)
|
|
10
10
|
self.config = config
|
|
11
11
|
|
|
12
12
|
def on_message(self, ws, message):
|
|
@@ -20,7 +20,7 @@ class ApplicationAction(BaseModel):
|
|
|
20
20
|
application_id: int
|
|
21
21
|
meta: Optional[Config] = None
|
|
22
22
|
last_activity: Optional[int] = 0
|
|
23
|
-
notifications_enabled: bool
|
|
23
|
+
notifications_enabled: bool = False
|
|
24
24
|
prompt: Optional[str] = None
|
|
25
25
|
request_count: Optional[int] = 0
|
|
26
26
|
|
|
@@ -46,6 +46,6 @@ class ApplicationContext(BaseModel):
|
|
|
46
46
|
application_id: Optional[int] = None
|
|
47
47
|
context_body: Optional[str] = None
|
|
48
48
|
context_path: Optional[str] = None
|
|
49
|
-
context_type: Optional[str] =
|
|
49
|
+
context_type: Optional[str] = "TEXT"
|
|
50
50
|
reference: Optional[str] = None
|
|
51
51
|
description: Optional[str] = None
|
|
@@ -86,15 +86,7 @@ class ResponseFormat(BaseModel):
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
class StreamOptions(BaseModel):
|
|
89
|
-
include_usage: bool
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class ChatMessage(BaseModel):
|
|
93
|
-
role: str
|
|
94
|
-
content: Optional[str] = ""
|
|
95
|
-
name: Optional[str] = None
|
|
96
|
-
tool_calls: Optional[List["ToolCall"]] = Field(default_factory=list)
|
|
97
|
-
tool_call_id: Optional[str] = None
|
|
89
|
+
include_usage: bool = False
|
|
98
90
|
|
|
99
91
|
|
|
100
92
|
class ToolCallFunction(BaseModel):
|
|
@@ -109,6 +101,14 @@ class ToolCall(BaseModel):
|
|
|
109
101
|
index: Optional[int] = None
|
|
110
102
|
|
|
111
103
|
|
|
104
|
+
class ChatMessage(BaseModel):
|
|
105
|
+
role: str
|
|
106
|
+
content: Optional[str] = ""
|
|
107
|
+
name: Optional[str] = None
|
|
108
|
+
tool_calls: Optional[List[ToolCall]] = None
|
|
109
|
+
tool_call_id: Optional[str] = None
|
|
110
|
+
|
|
111
|
+
|
|
112
112
|
class ToolChoice(BaseModel):
|
|
113
113
|
type: str
|
|
114
114
|
function: Optional[Function] = None
|
|
@@ -118,9 +118,9 @@ class ChatCompletionParams(BaseModel):
|
|
|
118
118
|
messages: List[ChatMessage]
|
|
119
119
|
model: str
|
|
120
120
|
max_tokens: Optional[int] = None
|
|
121
|
-
response_format: Optional[ResponseFormat] =
|
|
122
|
-
temperature: Optional[float] =
|
|
123
|
-
top_p: Optional[float] =
|
|
121
|
+
response_format: Optional[ResponseFormat] = None
|
|
122
|
+
temperature: Optional[float] = None
|
|
123
|
+
top_p: Optional[float] = None
|
|
124
124
|
stop: Optional[Union[str, List[str]]] = None
|
|
125
125
|
logprobs: Optional[bool] = False
|
|
126
126
|
top_logprobs: Optional[int] = None
|
|
@@ -129,8 +129,8 @@ class ChatCompletionParams(BaseModel):
|
|
|
129
129
|
stream: Optional[bool] = False
|
|
130
130
|
stream_options: Optional[StreamOptions] = None
|
|
131
131
|
logit_bias: Optional[Dict[str, float]] = None
|
|
132
|
-
presence_penalty: Optional[float] =
|
|
133
|
-
frequency_penalty: Optional[float] =
|
|
132
|
+
presence_penalty: Optional[float] = None
|
|
133
|
+
frequency_penalty: Optional[float] = None
|
|
134
134
|
user: Optional[str] = None
|
|
135
135
|
tools: Optional[List[Tool]] = []
|
|
136
136
|
tool_choice: Optional[Union[ToolChoice, str]] = None
|
|
@@ -177,7 +177,7 @@ class ChatCompletionMessage(BaseModel):
|
|
|
177
177
|
role: str
|
|
178
178
|
content: Optional[str] = ""
|
|
179
179
|
function_call: Optional[FunctionCall] = None
|
|
180
|
-
tool_calls: Optional[List[ToolCall]] =
|
|
180
|
+
tool_calls: Optional[List[ToolCall]] = None
|
|
181
181
|
refusal: Optional[str] = None
|
|
182
182
|
|
|
183
183
|
|
|
@@ -255,7 +255,7 @@ class EvaluateResponse(BaseModel):
|
|
|
255
255
|
|
|
256
256
|
|
|
257
257
|
class ChatCompletionResponse(BaseModel):
|
|
258
|
-
id: Optional[str] = None
|
|
258
|
+
id: Optional[Union[int, str]] = None
|
|
259
259
|
object: str = "chat.completion"
|
|
260
260
|
created: int = 0
|
|
261
261
|
model: str = None
|
|
@@ -292,7 +292,7 @@ class Turn(BaseModel):
|
|
|
292
292
|
class ChoiceDelta(BaseModel):
|
|
293
293
|
content: Optional[str] = ""
|
|
294
294
|
role: Optional[str] = None
|
|
295
|
-
tool_calls: Optional[List[ToolCall]] =
|
|
295
|
+
tool_calls: Optional[List[ToolCall]] = None
|
|
296
296
|
function_call: Optional[FunctionCall] = None
|
|
297
297
|
refusal: Optional[str] = None
|
|
298
298
|
|
{maitai_python-1.2.8b2 → maitai_python-1.2.9}/maitai_common/processes/websocket_listener_thread.py
RENAMED
|
@@ -10,8 +10,8 @@ logging.getLogger("websocket").setLevel(logging.FATAL)
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class WebsocketListenerThread(IOThread):
|
|
13
|
-
def __init__(self, path, type, key=None):
|
|
14
|
-
super(WebsocketListenerThread, self).__init__(interval=
|
|
13
|
+
def __init__(self, path, type, key=None, interval=60):
|
|
14
|
+
super(WebsocketListenerThread, self).__init__(interval=interval)
|
|
15
15
|
self.child_name = f"{self.__class__.__name__}"
|
|
16
16
|
self.messages = []
|
|
17
17
|
self.ws_url = f"{path}?type={type}"
|
|
@@ -49,7 +49,8 @@ class WebsocketListenerThread(IOThread):
|
|
|
49
49
|
self.messages.append(message)
|
|
50
50
|
|
|
51
51
|
def on_close(self, ws, _, __):
|
|
52
|
-
self.
|
|
52
|
+
if self.run_thread and not self.closing_ws:
|
|
53
|
+
self.connect_to_websocket()
|
|
53
54
|
|
|
54
55
|
def on_open(self, ws):
|
|
55
56
|
self.connection_established_event.set() # Set the event when connection is open
|
|
@@ -82,21 +83,23 @@ class WebsocketListenerThread(IOThread):
|
|
|
82
83
|
|
|
83
84
|
def process(self):
|
|
84
85
|
if self.run_thread:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
# Check if websocket is connected and functioning
|
|
87
|
+
if not self.ws or not self.ws.sock or not self.ws.sock.connected:
|
|
88
|
+
old_ws = self.ws
|
|
89
|
+
# Temporarily override the on_close to prevent reconnection
|
|
90
|
+
old_on_close = old_ws.on_close
|
|
91
|
+
old_ws.on_close = lambda *args, **kwargs: None
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
# Try to establish a new connection
|
|
95
|
+
self.connect_to_websocket()
|
|
96
|
+
# Wait for the on_open callback to set the event
|
|
97
|
+
self.connection_established_event.wait()
|
|
98
|
+
# If successful, close the old connection
|
|
99
|
+
old_ws.close()
|
|
100
|
+
except Exception as e:
|
|
101
|
+
# If new connection fails, keep the old connection
|
|
102
|
+
old_ws.on_close = old_on_close
|
|
103
|
+
self.ws = old_ws
|
|
104
|
+
|
|
105
|
+
super(WebsocketListenerThread, self).process()
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|