命令别名增强,可以在Web UI中进行设置,优化群聊学习

This commit is contained in:
CMHopeSunshine 2022-11-20 20:04:28 +08:00
parent 512685a707
commit 8ecd2dd2f3
2 changed files with 7 additions and 1 deletions

View File

@ -353,7 +353,7 @@ class LearningChat:
return cmp(len(left_messages) / left_duration, len(right_messages) / right_duration)
popularity: List[Tuple[int, List[ChatMessage]]] = sorted(total_messages.items(),
key=cmp_to_key(group_popularity_cmp))
key=cmp_to_key(group_popularity_cmp), reverse=True)
logger.debug('群聊学习', f'主动发言:群热度排行<m>{">>".join([str(g[0]) for g in popularity])}</m>')
for group_id, messages in popularity:
if len(messages) < 30:

View File

@ -8,6 +8,11 @@ from LittlePaimon.plugins.Learning_Chat.models import ChatMessage, ChatContext,
from LittlePaimon.web.api import BaseApiRouter
from LittlePaimon.web.api.utils import authentication
try:
import jieba_fast as jieba
except ImportError:
import jieba
from .handler import LearningChat
from .config import config_manager
@ -43,6 +48,7 @@ async def post_chat_global_config(data: dict):
count=config_manager.config.learn_max_count)
await ChatAnswer.filter(count__gt=config_manager.config.learn_max_count).update(
count=config_manager.config.learn_max_count)
jieba.load_userdict(config_manager.config.dictionary)
return {
'status': 0,
'msg': '保存成功'