播放系统文案从随机改为按顺序播放

main
Zhangzhichao@123 3 weeks ago
parent 94654ac0c7
commit a9e4686b8e

@ -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])

@ -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:

Loading…
Cancel
Save