-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 初版 WechatBot ,聊天数据统计、定时聊天总结、用户调用总结、聊天权限管理功能 #2
Conversation
同时修改了原本代码的一处注释错误
…t/doc-optimize Doc: 修改 README 文档
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我草草看了一下代码,你可以参考其中给出的一些意见进行修改。
之后你如果有空可以看一下相关的代码规范优化你的代码。
""" | ||
conf:字典包含初始的配置信息 | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以考虑参考 Google 的规范 进行注释。
""" | ||
conf:字典包含初始的配置信息 | ||
|
||
""" | ||
def __init__(self, conf: dict) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对于 dict 的具体结构,你可以试着用 TypedDict
进行定义:
from typing import TypedDict, Optional
class ConfDict(TypedDict):
key: Optional[str]
api: Optional[str]
def __init__(self, conf: ConfDict) -> None:
self.key = conf.get("key")
self.api = conf.get("api")
base/func_chatgpt.py
Outdated
@@ -110,7 +125,55 @@ def get_summary2(self, messages,roomid): | |||
self.LOG.error(f"本次生成总结时出错:{str(e)}") | |||
return "本次无法生成总结。" | |||
|
|||
|
|||
def get_summary_of_partly(self, summaries, roomid): | |||
"""根据微信群聊消息列表生成总结,由一名经验丰富的大学物理教授执行。""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
存在奇奇怪怪的内容
base/func_chatgptt.py
Outdated
@@ -114,6 +117,46 @@ def get_summary2(self, messages,roomid): | |||
self.LOG.error(f"本次生成总结时出错:{str(e)}") | |||
return "本次无法生成总结。" | |||
|
|||
def get_summary_of_partly(self, summaries, roomid): | |||
"""根据微信群聊消息列表生成总结,由一名经验丰富的大学物理教授执行。""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,好奇怪
将 roomid, summary 和 ts 插入到 'summary' 表中,其中 date 由 ts 计算得出。 | ||
""" | ||
# 连接到数据库 | ||
conn = sqlite3.connect(db_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是一个普遍存在的问题:
对于数据库相关的处理代码你没有放在 try except 中,于是错误的抛出会被上层的捕捉,当错误消息本身没有说明清除时。在日志中难以体现错误发生在哪里。
上面的 store_message
中的:
model_name = get_gptmodel_name()
token = num_tokens_from_string(msg.get('content'), model_name)
就是因为这个问题,在用户的模型存在问题时会抛出让人难以定位的消息。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我尝试部署你这版wechatbot时发现的问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
由于github review 只能在变动的更改上评论,所以我就在这里说了:
store_message
这个函数存在问题:
def store_message(msg):
"""将消息存储到数据库的 'messages' 表中"""
conn = sqlite3.connect(db_path)
c = conn.cursor()
model_name = get_gptmodel_name()
token = num_tokens_from_string(msg.get('content'), model_name)
msg_data = (
msg.get('id'),
msg.get('type'),
msg.get('sender'),
msg.get('roomid'),
msg.get('content'),
msg.get('thumb'),
msg.get('extra'),
msg.get('sign'),
msg.get('ts'),
msg.get('xml'),
int(msg.get('is_self', False)),
int(msg.get('is_group', True)),
token
)
token = num_tokens_from_string(msg.get('content'), model_name)
只能对 gpt 系的模型生效。因此 moonshot
之类的模型会因为模型名不匹配出问题。
该版本的机器人具有以下功能: