Skip to content

Commit

Permalink
fix(wechat.py): fix time init (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisonooo authored Jul 21, 2024
1 parent ee60b13 commit 919b46c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ dir = "wkteam"

# 群号和介绍
# 茴香豆相关
[frontend.wechat_wkteam.43925126702]
name = "茴香豆群(大暑)"
introduction = "github https://github.com/InternLM/HuixiangDou 用户体验群"

[frontend.wechat_wkteam.44546611710]
name = "茴香豆群(立夏)"
introduction = "github https://github.com/InternLM/HuixiangDou 用户体验群"
Expand Down
9 changes: 5 additions & 4 deletions huixiangdou/frontend/wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import xml.etree.ElementTree as ET
from datetime import datetime
from multiprocessing import Process

import pdb
import pytoml
import redis
import requests
Expand Down Expand Up @@ -261,7 +261,7 @@ class Talk:
query: str
reply: str = ''
refs: tuple = ()
now: int = time.time()
now: float = field(default_factory=time.time)

def convert_talk_to_dict(talk: Talk):
return {'query': talk.query, 'reply': talk.reply, 'refs': talk.refs, 'now': talk.now}
Expand Down Expand Up @@ -316,15 +316,15 @@ def concat(self):
now = time.time()
for item in self.history:
if abs(now - item.now) > 7200:
# 1小时前,太久的消息就不要了
# 2小时前,太久的消息就不要了
continue

answer = item.reply
if answer is not None and len(answer) > 0:
ret.append(item)
else:
merge_list.append(item.query)

concat_query = '\n'.join(merge_list)
concat_talk = Talk(query=concat_query)
ret.append(concat_talk)
Expand Down Expand Up @@ -767,6 +767,7 @@ def loop(self, worker):
# if user image or link contains question, do not process
continue

logger.debug('before concat {}'.format(user))
user.concat()
logger.debug('after concat {}'.format(user))
assert len(user.history) > 0
Expand Down

0 comments on commit 919b46c

Please sign in to comment.