npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

koishi-plugin-tldr3

v0.0.3

Published

让AI总结两条消息之间的所有消息

Readme

koishi-plugin-tldr3

npm

简介

tldr3 是一个 Koishi 插件,旨在帮助用户快速理解群聊中一段较长对话的核心内容。它通过调用 OpenAI-like API 对用户选定范围内的消息进行智能总结。

特性

  • 交互式范围选择: 通过回复起始和结束消息来精确指定需要总结的聊天记录范围,操作直观方便。
  • 数据库持久化存储: 将群聊消息自动存储到 Koishi 配置的数据库中(需要启用 database 服务),确保历史消息(包括发送者当时的昵称)可供总结。
  • 自定义 AI 指导: 通过配置 openaiSystemPrompt,您可以精确控制 AI 总结的风格、侧重点,并可使用 {bot_name} 占位符让 AI 知道自己的名字(优先使用群昵称,具体见配置项说明)。
  • 中途取消: 用户可以在交互过程中随时使用 tldr3 cancel 命令取消当前的总结任务。
  • 调试模式: 内置可选的调试模式,方便开发者或管理员在 Koishi 控制台查看详细的 API 请求内容和内部处理日志,快速定位问题。
  • 自动数据清理: 定期清理数据库中过旧的消息记录,防止数据库无限增长。

使用说明

  1. 启动总结任务: 在需要总结消息的群聊中,发送命令:
    tldr3
  2. 指定总结起点: 机器人会回复提示,要求你【回复】你希望作为总结起点的那条消息,并在你的回复消息中只包含数字 1
    • 找到你想作为起点的那条消息。
    • 使用你的聊天客户端的“回复”功能,回复那条消息。
    • 在回复输入框中,只输入 1 并发送。
    • 提示: 如需中途取消,请发送 tldr3 cancel
  3. 指定总结终点: 机器人确认收到起点后,会再次提示,要求你【回复】你希望作为总结终点的那条消息,并在你的回复消息中只包含数字 2
    • 找到你想作为终点的那条消息。
    • 同样使用“回复”功能,回复那条消息。
    • 在回复输入框中,只输入 2 并发送。
    • 提示:选择起点和终点的顺序不重要,插件会根据消息的实际时间戳来确定范围。如需中途取消,请发送 tldr3 cancel
  4. 等待结果: 机器人收到终点消息后,会提示正在获取记录并进行总结。由于需要查询数据库和调用 AI API,这可能需要一点时间。完成后,机器人会将总结结果发送到群聊中。
  5. 取消任务 (可选): 如果在步骤 2 或 3 的交互过程中想要放弃,可以随时发送 tldr3 cancel 命令来中止当前的总结任务(注意:一旦任务进入处理阶段(即发送“正在获取记录...”提示后),则无法取消)。
  • 如果在交互过程中(步骤 2 或 3),你长时间没有按要求回复(超过配置的 commandTimeout 秒),总结任务会自动取消,机器人会发送一条通知。

配置项

你可以在 Koishi 的配置文件中对 tldr3 进行详细配置:

  • openaiApiKey (string, 必填): 用于调用 OpenAI 服务的 API 密钥。
  • openaiEndpoint (string, 可选, 默认: https://api.openai.com/v1/chat/completions): OpenAI API 的请求地址。如果你使用了代理或第三方兼容接口,请修改这里。
  • openaiModel (string, 可选, 默认: gpt-3.5-turbo): 指定进行总结任务的 OpenAI 模型名称。
  • openaiSystemPrompt (string, 可选): 用于指导 AI 总结的系统提示词 (System Prompt)。
    • 你可以自定义提示词来控制 AI 的总结风格和重点。
    • 支持使用 {bot_name} 占位符。插件在调用 AI 时会将其替换为机器人的昵称,查找顺序如下:
      1. 机器人在当前群组的群昵称
      2. 机器人的全局昵称 (session.bot.user.nick)
      3. 机器人的全局用户名 (session.bot.user.name)
      4. 机器人自身的 ID (session.bot.selfId)
      5. 默认后备名称: "机器人助手"
    • 默认值:你是一个群聊消息总结助手,你的名字是 {bot_name}。以下是来自一个群组的一段聊天记录,格式为 "用户名: 消息内容"。请你清晰、客观地总结这段对话的主要内容、讨论点或重要信息。请忽略无关紧要的闲聊、表情符号和格式标记 ([图片], [表情:xx] 等),专注于核心信息。如果对话中有多方观点,请尽量分别概括。
  • commandTimeout (number, 可选, 默认: 120): 用户从发送 tldr3 命令开始,到完成两次有效回复(发送 "1" 和 "2")的总超时时间(单位:秒)。设置为 0 表示禁用超时。
  • Textlimit (number, 可选, 默认: 60000): 从数据库中提取的、准备发送给 AI 进行总结的原始消息内容总长度的最大限制(字符数)。用于防止请求体过大导致 API 调用失败或费用过高。
  • maxMessageAgeDays (number, 可选, 默认: 7): 插件内置的定时任务会定期删除数据库中时间戳早于这个天数的消息记录。设置为 0 表示禁用自动删除(不推荐,可能导致数据库无限增长)。
  • debugMode (boolean, 可选, 默认: false): 是否启用调试模式。启用后,本插件相关的日志级别会提升至 DEBUG,并在 Koishi 控制台输出更详细的内部处理信息,包括发送给 OpenAI 的完整请求内容 (Payload),方便排查问题。

致谢

本插件在交互设计和功能概念上受到了 tldr 项目的启发,感谢原项目提供的宝贵思路。