Fix bug: Agent process message correctly in Telegeram Gorup

This commit is contained in:
Liu Zhicong
2023-10-01 02:09:44 -07:00
parent 55b2701faa
commit 431f0d4ff2
6 changed files with 247 additions and 58 deletions
+21 -4
View File
@@ -8,10 +8,12 @@ from .ai_function import FunctionItem
class AgentMsgType(Enum):
TYPE_MSG = 0
TYPE_INTERNAL_CALL = 1
TYPE_ACTION = 2
TYPE_EVENT = 3
TYPE_SYSTEM = 4
TYPE_GROUPMSG = 1
TYPE_INTERNAL_CALL = 10
TYPE_ACTION = 20
TYPE_EVENT = 30
TYPE_SYSTEM = 40
class AgentMsgStatus(Enum):
RESPONSED = 0
@@ -44,6 +46,9 @@ class AgentMsg:
self.rely_msg_id:str = None # if not none means this is a respone msg
self.session_id:str = None
#forword info
self.create_time = 0
self.done_time = 0
self.topic:str = None # topic is use to find session, not store in db
@@ -111,6 +116,18 @@ class AgentMsg:
resp_msg.topic = self.topic
return resp_msg
def create_group_resp_msg(self,sender_id,resp_body):
resp_msg = AgentMsg(AgentMsgType.TYPE_GROUPMSG)
resp_msg.create_time = time.time()
resp_msg.rely_msg_id = self.msg_id
resp_msg.target = self.target
resp_msg.sender = sender_id
resp_msg.body = resp_body
resp_msg.topic = self.topic
return resp_msg
def set(self,sender:str,target:str,body:str,topic:str=None) -> None:
self.sender = sender