mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 13:26:30 +00:00
Errors sending to UI
notifying client of AI model conversion
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
import msgpack
|
||||
|
||||
cdef class RemoteCommand:
|
||||
def __init__(self, CommandType command_type, bytes data):
|
||||
def __init__(self, CommandType command_type, bytes data, str message=None):
|
||||
self.command_type = command_type
|
||||
self.data = data
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
command_type_names = {
|
||||
10: "LOGIN",
|
||||
20: "LOAD",
|
||||
25: "DATA_BYTES",
|
||||
30: "INFERENCE",
|
||||
35: "INFERENCE_DATA",
|
||||
40: "STOP_INFERENCE",
|
||||
80: "AI_AVAILABILITY_CHECK",
|
||||
85: "AI_AVAILABILITY_RESULT",
|
||||
90: "ERROR",
|
||||
100: "EXIT"
|
||||
}
|
||||
data_str = f'{len(self.data)} bytes' if self.data else ''
|
||||
@@ -19,10 +25,11 @@ cdef class RemoteCommand:
|
||||
@staticmethod
|
||||
cdef from_msgpack(bytes data):
|
||||
unpacked = msgpack.unpackb(data, strict_map_key=False)
|
||||
return RemoteCommand(unpacked.get("CommandType"), unpacked.get("Data"))
|
||||
return RemoteCommand(unpacked.get("CommandType"), unpacked.get("Data"), unpacked.get("Message"))
|
||||
|
||||
cdef bytes serialize(self):
|
||||
return msgpack.packb({
|
||||
"CommandType": self.command_type,
|
||||
"Data": self.data
|
||||
"Data": self.data,
|
||||
"Message": self.message
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user