Skip to content

PVPGOOD/Shirobot.Plugin.ImageGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shirobot.Plugin.ImageGen

Shirobot.Plugin.ImageGen 基于 Shirobot 的图片生成插件项目。

功能

  • 使用 #gen <提示词> 生成图片
  • 支持同一条消息带图进行图生图
  • 支持回复含图片的消息后发送 #gen <提示词> 进行图生图
  • 支持群消息 reaction 显示任务进度
  • 生成完成后回复原消息并发送完整图片
  • #gen 消息被撤回时取消本地等待和后续发送

如何部署开发环境

推荐目录结构:

  • ./RiderProjects/Shirobot.Plugin.ImageGen
  • ./RiderProjects/Shirobot

如果你的本地仓库布局不同,还需要修改 csproj 里的这些属性:

  • HostProjectRoot
  • HostExe
  • HostPluginDir
  • ProjectReference Include="C:\Users\JustMe\RiderProjects\ShiroBot\ShiroBot.SDK\ShiroBot.SDK.csproj"

其中:

  • HostExe 需要指向你本机实际使用的 ShiroBot.exe
  • HostPluginDir 需要指向你本机实际使用的插件输出目录,通常是 ShiroBot.exe 所在目录下的 plugins\Shirobot.Plugin.ImageGen\

开发流程:

  1. 打开项目 Shirobot.Plugin.ImageGen/Shirobot.Plugin.ImageGen.csproj
  2. 修改插件代码或 Assets/config.toml
  3. 执行 dotnet build
  4. Debug 构建后插件会自动复制到 ShiroBot 的插件目录
  5. 启动 ShiroBot.exe 进行调试

如果 ShiroBot.exe 正在运行,构建后的复制步骤可能会因为 DLL 被占用而失败。这种情况下先停止宿主,再重新构建。

配置

默认配置文件:

Shirobot.Plugin.ImageGen/Assets/config.toml

主要配置:

enabled = true
api_base_url = "http://127.0.0.1:3000"
api_key = "chatgpt2api"
model = "gpt-image-2"
size = ""
request_timeout_seconds = 180
task_poll_interval_seconds = 2
max_prompt_length = 2000
enable_image_edits = true

说明:

  • api_base_url 指向 chatgpt2api-main 后端地址
  • api_key 会以 Authorization: Bearer <api_key> 发送
  • model 默认使用 gpt-image-2
  • size 可选,例如 1:116:99:164:33:4
  • enable_image_edits 控制是否启用图生图

使用方式

文生图:

#gen 一只坐在窗边看雨的白猫,电影感光影

同一条消息带图进行图生图:

#gen 把这张图改成赛博朋克夜景风格

回复含图片消息进行图生图:

#gen 保持人物姿势,改成日系动画风格

API 流程

插件对接 chatgpt2api-main 的图片任务接口:

  • 文生图:POST /api/image-tasks/generations
  • 图生图:POST /api/image-tasks/edits
  • 轮询任务:GET /api/image-tasks?ids=<client_task_id>

后端返回图片 URL 时,插件会先下载图片并转换为 base64://...,再发送给 ShiroBot,避免平台无法访问本地 URL。

运行方式

运行本项目需要使用 Shirobot

下载 Shirobot 后,将本项目构建产物放到其 plugins/Shirobot.Plugin.ImageGen/ 目录下即可加载。

License

This project is licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages