From a9e4686b8e8122eaefd18e3b4744d6e4fe9f1425 Mon Sep 17 00:00:00 2001 From: "Zhangzhichao@123" Date: Wed, 20 Aug 2025 10:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E7=B3=BB=E7=BB=9F=E6=96=87?= =?UTF-8?q?=E6=A1=88=E4=BB=8E=E9=9A=8F=E6=9C=BA=E6=94=B9=E4=B8=BA=E6=8C=89?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.py | 2 +- liveMan.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/helper.py b/helper.py index 85aa55f..645e3ba 100644 --- a/helper.py +++ b/helper.py @@ -124,7 +124,7 @@ class LiveChatConfig: def system_messages(self) -> list: results = [] cursor = self.conn.cursor() - cursor.execute('select message from system_message') + cursor.execute('select message from system_message order by id') rows = cursor.fetchall() for message in rows: results.append(message[0]) diff --git a/liveMan.py b/liveMan.py index 307f328..45be89b 100644 --- a/liveMan.py +++ b/liveMan.py @@ -316,6 +316,7 @@ class DouyinLiveWebReply: self.backend_token = '' self.live_chat_config = LiveChatConfig() self.punctuation = ",.!;:,。!?:;" + self.system_message_index = 0 def _llm(self, prompt, stream=False): payload = { @@ -457,7 +458,10 @@ class DouyinLiveWebReply: # 用户交互队列为空,输出系统文案 # time.sleep(1) system_messages = self.live_chat_config.system_messages - reply_message = system_messages[random.randint(0, len(system_messages) - 1)] + reply_message = system_messages[self.system_message_index] + self.system_message_index += 1 + if self.system_message_index >= len(system_messages): + self.system_message_index = 0 llm_prompt = self.live_chat_config.refine_system_message_prompt.format(content=reply_message) reply_messages = self._llm(llm_prompt, True) for reply_message in reply_messages: @@ -471,7 +475,10 @@ class DouyinLiveWebReply: logger.error(traceback.format_exc()) time.sleep(5) system_messages = self.live_chat_config.system_messages - reply_message = system_messages[random.randint(0, len(system_messages) - 1)] + reply_message = system_messages[self.system_message_index] + self.system_message_index += 1 + if self.system_message_index >= len(system_messages): + self.system_message_index = 0 llm_prompt = self.live_chat_config.refine_system_message_prompt.format(content=reply_message) reply_messages = self._llm(llm_prompt, True) for reply_message in reply_messages: