@@ -25,8 +25,7 @@ | |||||
"summary": { | "summary": { | ||||
"enabled": true, # 文档总结和对话功能开关 | "enabled": true, # 文档总结和对话功能开关 | ||||
"group_enabled": true, # 是否支持群聊开启 | "group_enabled": true, # 是否支持群聊开启 | ||||
"max_summary_words": 50000, # 文章的最大字数,超过字数则直接忽略 | |||||
"max_file_size": 15000 # 文件的大小限制,单位KB,超过该大小直接忽略 | |||||
"max_file_size": 10000 # 文件的大小限制,单位KB,默认为10M,超过该大小直接忽略 | |||||
} | } | ||||
} | } | ||||
``` | ``` | ||||
@@ -85,7 +84,7 @@ | |||||
注意事项: | 注意事项: | ||||
1. 使用 `$mj open` 和 `$mj close` 指令可以快速打开和关闭绘图功能 | 1. 使用 `$mj open` 和 `$mj close` 指令可以快速打开和关闭绘图功能 | ||||
2. 海外环境部署请将 `img_proxy` 设置为 `False` | |||||
2. 海外环境部署请将 `img_proxy` 设置为 `false` | |||||
3. 开启 `use_image_create_prefix` 配置后可直接复用全局画图触发词,以"画"开头便可以生成图片。 | 3. 开启 `use_image_create_prefix` 配置后可直接复用全局画图触发词,以"画"开头便可以生成图片。 | ||||
4. 提示词内容中包含敏感词或者参数格式错误可能导致绘画失败,生成失败不消耗积分 | 4. 提示词内容中包含敏感词或者参数格式错误可能导致绘画失败,生成失败不消耗积分 | ||||
5. 若未收到图片可能有两种可能,一种是收到了图片但微信发送失败,可以在后台日志查看有没有获取到图片url,一般原因是受到了wx限制,可以稍后重试或更换账号尝试;另一种情况是图片提示词存在疑似违规,mj不会直接提示错误但会在画图后删掉原图导致程序无法获取,这种情况不消耗积分。 | 5. 若未收到图片可能有两种可能,一种是收到了图片但微信发送失败,可以在后台日志查看有没有获取到图片url,一般原因是受到了wx限制,可以稍后重试或更换账号尝试;另一种情况是图片提示词存在疑似违规,mj不会直接提示错误但会在画图后删掉原图导致程序无法获取,这种情况不消耗积分。 | ||||
@@ -104,6 +103,6 @@ | |||||
#### 限制 | #### 限制 | ||||
1. 文件目前 支持 `txt`, `docx`, `pdf`, `md`, `csv`格式,文件大小由 `max_file_size` 限制,最大不超过15M,文件字数由 `max_summary_words` 配置限制,最多可支持百万字的文件。但不建议上传字数过多的文件,一是token消耗过大,二是摘要很难覆盖到全部内容,但可以通过多轮对话来了解细节。 | |||||
1. 文件目前 支持 `txt`, `docx`, `pdf`, `md`, `csv`格式,文件大小由 `max_file_size` 限制,最大不超过15M,文件字数最多可支持百万字的文件。但不建议上传字数过多的文件,一是token消耗过大,二是摘要很难覆盖到全部内容,但可以通过多轮对话来了解细节。 | |||||
2. 分享链接 目前仅支持 公众号文章,后续会支持更多文章类型及视频链接等 | 2. 分享链接 目前仅支持 公众号文章,后续会支持更多文章类型及视频链接等 | ||||
3. 总结及对话的 费用与 LinkAI 3.5-4K 模型的计费方式相同,按文档内容的tokens进行计算 | 3. 总结及对话的 费用与 LinkAI 3.5-4K 模型的计费方式相同,按文档内容的tokens进行计算 |
@@ -14,7 +14,6 @@ | |||||
"summary": { | "summary": { | ||||
"enabled": true, | "enabled": true, | ||||
"group_enabled": true, | "group_enabled": true, | ||||
"max_summary_words": 50000, | |||||
"max_file_size": 15000 | "max_file_size": 15000 | ||||
} | } | ||||
} | } |
@@ -61,7 +61,8 @@ class LinkAI(Plugin): | |||||
_set_reply_text(res.get("summary") + "\n\n💬 发送 \"开启对话\" 可以开启与文件内容的对话", e_context, level=ReplyType.TEXT) | _set_reply_text(res.get("summary") + "\n\n💬 发送 \"开启对话\" 可以开启与文件内容的对话", e_context, level=ReplyType.TEXT) | ||||
return | return | ||||
if context.type == ContextType.SHARING and self._is_summary_open(context): | |||||
if (context.type == ContextType.SHARING and self._is_summary_open(context)) or \ | |||||
(context.type == ContextType.TEXT and LinkSummary().check_url(context.content)): | |||||
if not LinkSummary().check_url(context.content): | if not LinkSummary().check_url(context.content): | ||||
return | return | ||||
_send_info(e_context, "正在为你加速生成摘要,请稍后") | _send_info(e_context, "正在为你加速生成摘要,请稍后") | ||||
@@ -65,13 +65,9 @@ class LinkSummary: | |||||
def check_file(self, file_path: str, sum_config: dict) -> bool: | def check_file(self, file_path: str, sum_config: dict) -> bool: | ||||
file_size = os.path.getsize(file_path) // 1000 | file_size = os.path.getsize(file_path) // 1000 | ||||
with open(file_path, 'r') as f: | |||||
content = f.read() | |||||
word_count = len(content) | |||||
if (sum_config.get("max_file_size") and file_size > sum_config.get("max_file_size")) or file_size > 15000\ | |||||
or (sum_config.get("max_summary_words") and word_count > sum_config.get("max_summary_words")): | |||||
logger.warn(f"[LinkSum] file size exceeds limit, No processing, file_size={file_size}KB, word_count={word_count}") | |||||
if (sum_config.get("max_file_size") and file_size > sum_config.get("max_file_size")) or file_size > 15000: | |||||
logger.warn(f"[LinkSum] file size exceeds limit, No processing, file_size={file_size}KB") | |||||
return True | return True | ||||
suffix = file_path.split(".")[-1] | suffix = file_path.split(".")[-1] | ||||
@@ -83,9 +79,11 @@ class LinkSummary: | |||||
return True | return True | ||||
def check_url(self, url: str): | def check_url(self, url: str): | ||||
support_list = ["mp.weixin.qq.com"] | |||||
if not url: | |||||
return False | |||||
support_list = ["http://mp.weixin.qq.com", "https://mp.weixin.qq.com"] | |||||
for support_url in support_list: | for support_url in support_list: | ||||
if support_url in url: | |||||
if url.strip().startswith(support_url): | |||||
return True | return True | ||||
logger.warn("[LinkSum] unsupported url") | logger.warn("[LinkSum] unsupported url") | ||||
return False | return False |