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-virtual-pet

v1.0.7

Published

虚拟宠物插件,具有记忆功能,可以监听群聊并智能回复

Downloads

94

Readme

Koishi 虚拟宠物插件

一个具有智能记忆功能的虚拟宠物插件,可以监听群聊并智能回复。

功能特性

🤖 智能回复: 使用便宜的AI分析消息,贵的AI生成高质量回复 🧠 记忆系统: 短期记忆100条消息,自动总结重要信息 🎭 个性设定: 可自定义宠物名称和性格 ⚙️ 灵活配置: 支持指定群组,可调节回复概率 📊 状态监控: 提供命令查看宠物状态和记忆情况

安装方法

  1. 将插件文件夹放入 Koishi 的插件目录
  2. 在 Koishi 配置中启用插件
  3. 配置 AI API 信息(见配置说明)

配置说明

AI 配置

插件支持配置两种AI服务:

  • 便宜AI: 用于分析是否需要回复消息
  • 贵AI: 用于生成高质量的回复内容

支持 OpenAI 兼容的 API 格式。

配置示例

# 便宜的AI配置
cheapAi:
  enabled: true
  apiUrl: "https://api.openai.com/v1"
  apiKey: "your-cheap-ai-api-key"
  model: "gpt-3.5-turbo"

# 贵的AI配置
expensiveAi:
  enabled: true
  apiUrl: "https://api.openai.com/v1"
  apiKey: "your-expensive-ai-api-key"
  model: "gpt-4"

# 记忆配置
memory:
  maxMessages: 100        # 短期记忆最大消息数
  summaryInterval: 100    # 每多少条消息总结一次

# 宠物配置
pet:
  name: "小宠物"
  personality: "你是一个可爱、友善的虚拟宠物..."
  responseRate: 0.3       # 回复概率 (0-1)

# 群组配置
groups: []                # 空数组表示全部群组

使用命令

查看宠物状态

/pet.status

查看当前群组的记忆统计、摘要和最近话题。

清除记忆

/pet.clear

清除当前群组的所有记忆数据。

手动总结记忆

/pet.summarize

手动触发记忆总结,不需要等待达到总结间隔。

工作原理

  1. 消息监听: 插件监听群聊中的所有消息
  2. 记忆存储: 将消息存储到短期记忆中(最多100条)
  3. 智能判断: 使用便宜AI分析是否需要回复
  4. 生成回复: 使用贵AI生成符合宠物性格的回复
  5. 记忆总结: 每100条消息自动总结,保留重要信息

注意事项

  • 确保 API 密钥正确且有足够的配额
  • 建议合理设置回复概率,避免过于频繁
  • 记忆数据存储在内存中,重启后会丢失
  • 可以通过数据库扩展实现持久化存储

故障排除

常见问题

Q: 宠物不回复消息 A: 检查以下配置:

  • AI API 配置是否正确
  • 网络连接是否正常
  • 回复概率是否设置过低

Q: API 调用失败 A: 检查以下项目:

  • API 地址是否正确
  • 密钥是否有效
  • 模型名称是否正确

Q: 记忆功能异常 A: 尝试使用 /pet.clear 命令清除记忆后重新开始

开发说明

项目结构

virtual-pet/
├── src/
│   ├── index.ts          # 插件主文件
│   └── services/
│       ├── ai.ts         # AI服务
│       └── memory.ts     # 记忆服务
├── package.json
├── tsconfig.json
├── config.example.yml
└── README.md

扩展开发

插件采用模块化设计,可以轻松扩展:

  • AI服务: 支持添加更多AI提供商
  • 记忆服务: 可扩展持久化存储
  • 命令系统: 可添加更多管理命令

许可证

MIT License

安全说明

关于npm audit警告和安全问题的详细信息,请查看 SECURITY.md

故障排除

如果虚拟宠物不说话或遇到其他问题,请查看 故障排除指南

贡献

欢迎提交 Issue 和 Pull Request!