Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6839b4aad | ||
|
|
c3e003a572 | ||
|
|
be6a01a06e | ||
|
|
767efdccbb | ||
|
|
bf989ca3f2 |
@@ -15,18 +15,17 @@
|
|||||||
- **文章/页面级开关** — 在文章编辑器中直接控制是否启用 AI 回复,文章默认开启,页面默认关闭
|
- **文章/页面级开关** — 在文章编辑器中直接控制是否启用 AI 回复,文章默认开启,页面默认关闭
|
||||||
- **评论者黑名单** — 支持按名称、邮箱和正则表达式屏蔽指定评论者,可从评论列表选择
|
- **评论者黑名单** — 支持按名称、邮箱和正则表达式屏蔽指定评论者,可从评论列表选择
|
||||||
- **手动触发** — 在评论管理页面对历史评论手动触发 AI 回复
|
- **手动触发** — 在评论管理页面对历史评论手动触发 AI 回复
|
||||||
- **安全审核** — AI 生成的内容经过安全审核,不合规内容自动拒绝
|
- **两阶段安全审核** — 安全检查 + 质量评分(1-5 分映射到 0-100 分),不合规内容自动拒绝
|
||||||
- **Prompt 模板** — 支持自定义 Prompt 模板,提供多种模板变量(文章标题、发布日期、评论数等)
|
- **Prompt 模板** — 支持自定义 Prompt 模板,提供多种模板变量(文章标题、发布日期、评论数、对话历史等)
|
||||||
- **Prompt 预设** — 内置友好型、专业型、幽默型、简洁型预设风格,可多选组合
|
- **Prompt 预设** — 内置友好型、专业型、幽默型、简洁型预设风格,可多选组合
|
||||||
- **仪表盘统计** — 显示回复数、情感分布、每日回复趋势等图表,支持时间范围切换
|
|
||||||
- **插件健康检查** — 实时检测 AI Foundation 连接状态和模型可用性
|
- **插件健康检查** — 实时检测 AI Foundation 连接状态和模型可用性
|
||||||
- **日志筛选** — 按状态、情感筛选,关键词搜索
|
- **日志筛选** — 按状态、情感筛选,关键词搜索
|
||||||
- **数据清理** — 自动清理超过指定天数的旧记录
|
- **数据清理** — 自动清理超过指定天数的旧记录
|
||||||
- **AI Foundation 集成** — 必须安装 Halo AI Foundation 插件,使用其提供的 AI 模型能力
|
- **AI Foundation 集成** — 通过 Halo 官方推荐的 `ExtensionGetter` 获取 AI 服务,需安装 AI Foundation 插件
|
||||||
|
|
||||||
## 前置要求
|
## 前置要求
|
||||||
|
|
||||||
- Halo 2.23+
|
- Halo 2.25+
|
||||||
- AI Foundation 插件(必须)
|
- AI Foundation 插件(必须)
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
@@ -37,6 +36,10 @@
|
|||||||
4. 选择下载的 `.jar` 文件上传
|
4. 选择下载的 `.jar` 文件上传
|
||||||
5. 安装完成后启用插件
|
5. 安装完成后启用插件
|
||||||
|
|
||||||
|
::: tip
|
||||||
|
安装本插件后,应用市场会推荐安装 AI Foundation 插件(本插件的必要依赖)。
|
||||||
|
:::
|
||||||
|
|
||||||
## 从源码构建
|
## 从源码构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -66,6 +69,64 @@ pnpm dev
|
|||||||
|
|
||||||
完整文档请访问 [AI回评文档站](https://nxxy335.top/comment-ai-autopilot)
|
完整文档请访问 [AI回评文档站](https://nxxy335.top/comment-ai-autopilot)
|
||||||
|
|
||||||
|
## 更新日志
|
||||||
|
|
||||||
|
### v1.0.0-beta.2
|
||||||
|
|
||||||
|
**改进**
|
||||||
|
|
||||||
|
- 通过 Halo 官方推荐的 `ExtensionGetter` 获取 AI Foundation 的 `AiModelService`,替换原先的跨 ClassLoader 反射调用方式
|
||||||
|
- 在 `plugin.yaml` 中声明可选插件依赖 `ai-foundation?: "*"`,建立正确的插件依赖关系
|
||||||
|
- 新增 `store.halo.run/recommended-apps` 注解,安装后可在应用市场推荐安装 AI Foundation 插件
|
||||||
|
- 情感分析和内容审核改用 AI Foundation 结构化输出(`OutputSpec.choice`),分类更可靠
|
||||||
|
- AI 调用改用 `GenerateTextRequest` 并设置 `maxRetries=2`,由 SDK 自动重试瞬时错误
|
||||||
|
- AI 对话续接时自动获取之前的回复历史并注入到 Prompt 中,AI 能更好地理解对话上下文
|
||||||
|
- 优化 AI 自审核评分机制:改为两阶段评估(安全检查 + 质量评分 1-5 分),评分映射到 0-100 分,替代原先的二值评分
|
||||||
|
- 精简仪表盘:移除情感分布、近7日回复趋势、平均审核评分三个卡片,快捷操作精简为回复日志、插件设置、刷新数据
|
||||||
|
- 重做设置页面:基本设置、AI角色设置、模型设置、Prompt设置、数据清理各为独立页面,通过标签栏切换
|
||||||
|
- 优化设置页面布局:按钮统一排版并添加图标,侧边栏新增"未保存"状态指示器
|
||||||
|
- 优化日志页面:评分增加等级标签(优秀/良好/一般/较差),筛选下拉框修复文本与箭头重叠
|
||||||
|
- 优化 AI Foundation 状态提示宽度,与内容区宽度一致
|
||||||
|
- 优化插件文档:修复版本要求、变量名、链接等错误
|
||||||
|
|
||||||
|
**Bug 修复**
|
||||||
|
|
||||||
|
- 修复 RateLimitService 清理线程在插件停止时未关闭导致线程泄漏
|
||||||
|
- 修复内容审核提示词要求"重新生成"但代码未使用重新生成内容的问题
|
||||||
|
- 修复设置页面按钮图标和文字未在同一行显示的问题
|
||||||
|
- 修复设置页面标签栏无法点击切换的问题
|
||||||
|
- 修复设置页面配置区域布局错误的问题
|
||||||
|
|
||||||
|
### v1.0.0-beta.1
|
||||||
|
|
||||||
|
**新功能**
|
||||||
|
|
||||||
|
- 草稿模式:关闭"自动发布"后,AI 回复将保存为草稿,需站长审核后才发布
|
||||||
|
- 多 AI 角色支持:支持配置多个 AI 虚拟角色,每个角色有独立的提示词、头像和模型
|
||||||
|
- 提示词预设:内置多种回复风格预设(专业型、幽默型、简洁型等),可自由组合
|
||||||
|
- 对话历史查看:支持查看 AI 回复的完整对话上下文
|
||||||
|
|
||||||
|
**Bug 修复**
|
||||||
|
|
||||||
|
- 修复草稿模式下审批失败("AI回复已存在,无法重复发布")的问题
|
||||||
|
- 修复批量审批时同样的去重检查冲突问题
|
||||||
|
- 修复 AI Foundation 不可用的问题(`PluginManager` 无法通过 Spring 依赖注入获取)
|
||||||
|
- 修复 `DefaultSpringPlugin` 包级私有类反射访问权限问题
|
||||||
|
- 修复 CI 构建失败(`gradlew` 缺少执行权限)
|
||||||
|
|
||||||
|
**改进**
|
||||||
|
|
||||||
|
- 审批逻辑优化:先查找已有 Reply 扩展再决定创建或更新
|
||||||
|
- 移除不必要的 `AiFoundationConfiguration` 配置类
|
||||||
|
- 前端 UI 优化:移除编辑功能、简化角色排序逻辑、清理无用代码
|
||||||
|
|
||||||
|
### v0.0.3
|
||||||
|
|
||||||
|
- 增强插件可靠性与可用性
|
||||||
|
- 多 AI 角色支持
|
||||||
|
- 草稿模式初步实现
|
||||||
|
- 文档全面更新
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
[GPL-3.0](./LICENSE) © 暖心向阳335
|
[GPL-3.0](https://github.com/sunny-335/plugin-comment-ai-autopilot/blob/main/LICENSE) © 暖心向阳335
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'top.nxxy335.commentaiautopilot'
|
group 'top.nxxy335.commentaiautopilot'
|
||||||
version '1.0.0-beta.1'
|
version '1.0.0-beta.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# 更新日志
|
||||||
|
|
||||||
|
## v1.0.0-beta.2
|
||||||
|
|
||||||
|
> 2026-06-17
|
||||||
|
|
||||||
|
### 改进
|
||||||
|
|
||||||
|
- **改用 ExtensionGetter 集成 AI Foundation**:通过 Halo 官方推荐的 `ExtensionGetter.getEnabledExtension(AiModelService.class)` 获取 AI 服务,替换原先的跨 ClassLoader 反射调用方式([Issue #1](https://github.com/sunny-335/plugin-comment-ai-autopilot/issues/1))
|
||||||
|
- **声明插件依赖**:在 `plugin.yaml` 中声明可选插件依赖 `ai-foundation?: "*"`,建立正确的插件依赖关系,插件在未安装 AI Foundation 时仍可正常加载
|
||||||
|
- **应用市场推荐**:新增 `store.halo.run/recommended-apps` 注解,安装本插件后可在应用市场推荐安装 AI Foundation 插件
|
||||||
|
- **使用结构化输出**:情感分析和内容审核改用 AI Foundation 的 `OutputSpec.choice` 结构化输出,替换原先的字符串匹配解析,分类更可靠
|
||||||
|
- **使用 GenerateTextRequest**:AI 调用改用 `GenerateTextRequest` 并设置 `maxRetries=2`,由 SDK 自动重试瞬时错误
|
||||||
|
- **多轮对话上下文**:AI 对话续接时自动获取之前的回复历史并注入到 Prompt 中,AI 能更好地理解对话上下文
|
||||||
|
- **优化 AI 自审核评分机制**:审核改为两阶段评估(安全检查 + 质量评分 1-5 分),评分映射到 0-100 分(0/30/50/70/85/100),替代原先的二值评分(0/100),评分更有区分度
|
||||||
|
- **精简仪表盘**:移除情感分布、近7日回复趋势、平均审核评分三个卡片,快捷操作精简为回复日志、插件设置、刷新数据
|
||||||
|
- **重做设置页面**:基本设置、AI角色设置、模型设置、Prompt设置、数据清理各为独立页面,通过标签栏切换
|
||||||
|
- **优化设置页面布局**:按钮统一排版并添加图标,侧边栏保存卡片高亮显示,新增"未保存"状态指示器
|
||||||
|
- **优化日志页面**:评分增加等级标签(优秀/良好/一般/较差),筛选下拉框修复文本与箭头重叠
|
||||||
|
- **优化 AI Foundation 状态提示宽度**:状态提示与内容区宽度一致
|
||||||
|
- **优化插件文档**:修复版本要求(2.23→2.25)、变量名(`{{conversation}}`→`{{conversation_history}}`)、GitHub 链接(`nxxy335`→`sunny-335`)、Cravatar 链接(`cravatar.cn`→`cn.cravatar.com`)等错误,补充缺失的配置项文档
|
||||||
|
|
||||||
|
### Bug 修复
|
||||||
|
|
||||||
|
- **修复自动发布后日志显示未发布**:`generateAndPublish` 中 `Mono<Void>` 的 empty 信号触发 `switchIfEmpty` 导致 `publishReply` 被调用两次,第二次覆盖 `published=false`
|
||||||
|
- **修复 RateLimitService 线程泄漏**:清理线程未在插件停止时关闭,实现 `DisposableBean` 正确释放资源
|
||||||
|
- **修复 ReviewService 提示词不匹配**:审核提示词要求"重新生成"但代码未使用重新生成的内容,移除误导性指令
|
||||||
|
- **修复设置页面按钮图标文字对齐**:通过 `:deep(.btn-content)` 设置 inline-flex 布局,图标和文字并排显示
|
||||||
|
- **修复设置页面标签栏无法点击切换**:替换不工作的 VTabbar 组件为自定义按钮实现
|
||||||
|
- **修复设置页面配置区域布局错误**:将标签栏移出 grid 容器,避免挤占配置区域宽度
|
||||||
|
- **修复日志页面筛选下拉框文本与箭头重叠**:将 `px-3` 改为 `pl-3 pr-8` 为下拉箭头预留空间
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v1.0.0-beta.1
|
||||||
|
|
||||||
|
> 2026-06-05
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
|
||||||
|
- **自动回复**:监听新评论,自动调用 AI 生成回复
|
||||||
|
- **多语言适配**:根据评论语言自动用对应语言回复
|
||||||
|
- **情感分析**:分析评论情感倾向,根据情感调整回复语气
|
||||||
|
- **草稿模式**:关闭"自动发布"后,AI 回复将保存为草稿,需站长审核后才发布
|
||||||
|
- **多 AI 角色支持**:支持配置多个 AI 虚拟角色,每个角色有独立的提示词、头像和模型
|
||||||
|
- **提示词预设**:内置多种回复风格预设(专业型、幽默型、简洁型等),可自由组合
|
||||||
|
- **文章/页面级开关**:在文章编辑器中直接控制是否启用 AI 回复
|
||||||
|
- **评论者黑名单**:屏蔽指定评论者,不触发 AI 回复
|
||||||
|
- **安全审核**:AI 生成的内容经过安全审核,不合规内容自动拒绝
|
||||||
|
- **Prompt 模板**:支持自定义 Prompt 模板,提供多种模板变量
|
||||||
|
- **仪表盘统计**:显示回复数等统计信息
|
||||||
|
- **日志筛选搜索**:按状态、情感筛选,关键词搜索
|
||||||
|
- **数据清理**:自动清理超过指定天数的旧记录
|
||||||
|
- **AI Foundation 集成**:使用 AI Foundation 插件提供的 AI 模型能力
|
||||||
|
- **对话历史查看**:支持查看 AI 回复的完整对话上下文
|
||||||
|
|
||||||
|
### Bug 修复
|
||||||
|
|
||||||
|
- 修复草稿模式下审批失败("AI回复已存在,无法重复发布")的问题
|
||||||
|
- 修复批量审批时同样的去重检查冲突问题
|
||||||
|
- 修复 AI Foundation 不可用的问题(`PluginManager` 无法通过 Spring 依赖注入获取)
|
||||||
|
- 修复 `DefaultSpringPlugin` 包级私有类反射访问权限问题
|
||||||
|
- 修复 CI 构建失败(`gradlew` 缺少执行权限)
|
||||||
|
|
||||||
|
### 改进
|
||||||
|
|
||||||
|
- 审批逻辑优化:先查找已有 Reply 扩展再决定创建或更新
|
||||||
|
- 移除不必要的 `AiFoundationConfiguration` 配置类
|
||||||
|
- 前端 UI 优化:移除编辑功能、简化角色排序逻辑、清理无用代码
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
|--------|------|--------|
|
|--------|------|--------|
|
||||||
| 自动回复 | 是否启用自动回复功能 | 开启 |
|
| 自动回复 | 是否启用自动回复功能 | 开启 |
|
||||||
| 自动发布 | AI回复是否自动发布,关闭则存为草稿 | 开启 |
|
| 自动发布 | AI回复是否自动发布,关闭则存为草稿 | 开启 |
|
||||||
|
| 最大对话轮次 | 同一评论线程中AI最多自动回复的轮次 | 8 |
|
||||||
|
| 速率限制 | 每分钟最大AI回复数量 | 10 |
|
||||||
| 最大重试次数 | AI生成失败时的最大重试次数 | 3 |
|
| 最大重试次数 | AI生成失败时的最大重试次数 | 3 |
|
||||||
|
|
||||||
## 重试机制
|
## 重试机制
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
1. 确认在插件设置中填写了AI角色邮箱
|
1. 确认在插件设置中填写了AI角色邮箱
|
||||||
2. 邮箱需要在 [Gravatar](https://gravatar.com) 上注册并设置头像
|
2. 邮箱需要在 [Gravatar](https://gravatar.com) 上注册并设置头像
|
||||||
3. 插件使用 [Cravatar](https://cravatar.cn) 作为Gravatar镜像服务
|
3. 插件使用 [Cravatar](https://cn.cravatar.com) 作为Gravatar镜像服务
|
||||||
|
|
||||||
## 评论没有触发AI回复?
|
## 评论没有触发AI回复?
|
||||||
|
|
||||||
|
|||||||
+11
-3
@@ -32,9 +32,17 @@
|
|||||||
|
|
||||||
1. 进入插件设置页面
|
1. 进入插件设置页面
|
||||||
2. 在 **基本设置** 中找到 **评论者黑名单**
|
2. 在 **基本设置** 中找到 **评论者黑名单**
|
||||||
3. 输入评论者的显示名称或邮箱,多个用逗号分隔
|
3. 输入评论者的显示名称、邮箱或正则表达式,多个用逗号分隔
|
||||||
4. 保存设置
|
4. 保存设置
|
||||||
|
|
||||||
|
### 支持的格式
|
||||||
|
|
||||||
|
| 格式 | 示例 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 名称 | `张三` | 匹配评论者的显示名称 |
|
||||||
|
| 邮箱 | `spam@example.com` | 匹配评论者邮箱(不区分大小写) |
|
||||||
|
| 正则表达式 | `regex:^spam.*` | 以 `regex:` 开头,按正则匹配 |
|
||||||
|
|
||||||
### 从评论列表选择
|
### 从评论列表选择
|
||||||
|
|
||||||
1. 在黑名单输入框旁点击 **添加评论者** 按钮
|
1. 在黑名单输入框旁点击 **添加评论者** 按钮
|
||||||
@@ -45,7 +53,7 @@
|
|||||||
### 示例
|
### 示例
|
||||||
|
|
||||||
```
|
```
|
||||||
张三,spam@example.com,李四
|
张三, spam@example.com, 李四, regex:^spam.*
|
||||||
```
|
```
|
||||||
|
|
||||||
黑名单中的评论者发布评论时,插件会同时匹配显示名称和邮箱地址(不区分大小写),匹配成功则跳过AI回复。
|
黑名单中的评论者发布评论时,插件会同时匹配显示名称和邮箱地址(不区分大小写),正则表达式则按模式匹配,匹配成功则跳过AI回复。
|
||||||
|
|||||||
@@ -2,24 +2,28 @@
|
|||||||
|
|
||||||
## 前置要求
|
## 前置要求
|
||||||
|
|
||||||
- Halo 2.23+
|
- Halo 2.25+
|
||||||
- AI Foundation 插件(必须) — 本插件依赖 AI Foundation 提供的AI模型能力,请先安装并配置 AI Foundation
|
- AI Foundation 插件(必须) — 本插件通过 `ExtensionGetter` 调用 AI Foundation 提供的 `AiModelService` 扩展点,请先安装并配置 AI Foundation
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
### 方式一:从 Release 下载
|
### 方式一:从 Release 下载
|
||||||
|
|
||||||
1. 前往 [GitHub Releases](https://github.com/nxxy335/plugin-comment-ai-autopilot/releases) 下载最新的 `.jar` 文件
|
1. 前往 [GitHub Releases](https://github.com/sunny-335/plugin-comment-ai-autopilot/releases) 下载最新的 `.jar` 文件
|
||||||
2. 登录 Halo 管理后台
|
2. 登录 Halo 管理后台
|
||||||
3. 进入 **插件** → **已安装** → 点击右上角 **安装** 按钮
|
3. 进入 **插件** → **已安装** → 点击右上角 **安装** 按钮
|
||||||
4. 选择下载的 `.jar` 文件上传
|
4. 选择下载的 `.jar` 文件上传
|
||||||
5. 安装完成后启用插件
|
5. 安装完成后启用插件
|
||||||
|
|
||||||
|
::: tip 推荐安装
|
||||||
|
安装本插件后,应用市场会推荐安装 AI Foundation 插件(本插件的必要依赖)。
|
||||||
|
:::
|
||||||
|
|
||||||
### 方式二:从源码构建
|
### 方式二:从源码构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 克隆仓库
|
# 克隆仓库
|
||||||
git clone https://github.com/nxxy335/plugin-comment-ai-autopilot.git
|
git clone https://github.com/sunny-335/plugin-comment-ai-autopilot.git
|
||||||
cd plugin-comment-ai-autopilot
|
cd plugin-comment-ai-autopilot
|
||||||
|
|
||||||
# 构建
|
# 构建
|
||||||
|
|||||||
@@ -5,20 +5,22 @@ AI回评(Comment AI Autopilot)是一个 Halo 博客系统的插件,能够
|
|||||||
## 核心功能
|
## 核心功能
|
||||||
|
|
||||||
- **自动回复** — 监听新评论,自动调用AI生成回复,支持多轮对话上下文
|
- **自动回复** — 监听新评论,自动调用AI生成回复,支持多轮对话上下文
|
||||||
|
- **多 AI 角色** — 支持创建多个 AI 角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可为不同文章指定不同角色
|
||||||
- **多语言适配** — 根据评论语言自动用对应语言回复
|
- **多语言适配** — 根据评论语言自动用对应语言回复
|
||||||
- **情感分析** — 分析评论情感倾向(正面/中性/负面),根据情感调整回复语气
|
- **情感分析** — 分析评论情感倾向(正面/中性/负面),根据情感调整回复语气
|
||||||
- **草稿模式** — AI回复先存为草稿,管理员审核后再发布
|
- **草稿模式** — AI回复先存为草稿,管理员审核后再发布
|
||||||
- **失败重试** — AI生成失败时自动重试,指数退避策略
|
- **失败重试** — AI生成失败时自动重试,指数退避策略
|
||||||
- **批量操作** — 草稿模式下支持批量通过/拒绝/删除
|
- **批量操作** — 草稿模式下支持批量通过/拒绝/删除
|
||||||
- **文章/页面级开关** — 在文章编辑器中直接控制是否启用AI回复,文章默认开启,页面默认关闭
|
- **文章/页面级开关** — 在文章编辑器中直接控制是否启用AI回复,文章默认开启,页面默认关闭
|
||||||
- **评论者黑名单** — 屏蔽指定评论者,不触发AI回复
|
- **评论者黑名单** — 屏蔽指定评论者,不触发AI回复,支持名称、邮箱和正则表达式
|
||||||
- **手动触发** — 在评论管理页面对历史评论手动触发AI回复
|
- **手动触发** — 在评论管理页面对历史评论手动触发AI回复
|
||||||
- **AI角色** — 自定义AI回复者的昵称、人格提示词和Gravatar头像
|
- **安全审核** — AI生成的内容经过两阶段安全审核(安全检查 + 质量评分),不合规内容自动拒绝
|
||||||
- **安全审核** — AI生成的内容经过安全审核,不合规内容自动拒绝
|
- **Prompt 预设** — 内置友好型、专业型、幽默型、简洁型预设风格,可多选组合
|
||||||
- **仪表盘统计** — 显示回复数、情感分布、每日回复趋势等图表
|
- **对话轮次限制** — 同一评论线程中限制 AI 最多回复轮次,防止无限对话
|
||||||
|
- **速率限制** — 每分钟最大 AI 回复数量,防止批量评论消耗过多额度
|
||||||
- **日志筛选搜索** — 按状态、情感筛选,关键词搜索
|
- **日志筛选搜索** — 按状态、情感筛选,关键词搜索
|
||||||
- **数据清理** — 自动清理超过指定天数的旧记录
|
- **数据清理** — 自动清理超过指定天数的旧记录
|
||||||
- **AI Foundation 集成** — 必须安装 Halo AI Foundation 插件,使用其提供的AI模型能力
|
- **AI Foundation 集成** — 通过 Halo 官方推荐的 `ExtensionGetter` 获取 AI 服务,需安装 AI Foundation 插件
|
||||||
|
|
||||||
## 工作流程
|
## 工作流程
|
||||||
|
|
||||||
@@ -33,17 +35,17 @@ AI回评(Comment AI Autopilot)是一个 Halo 博客系统的插件,能够
|
|||||||
3. **情感分析** — 调用AI分析评论情感倾向
|
3. **情感分析** — 调用AI分析评论情感倾向
|
||||||
4. **构建Prompt** — 结合AI角色人格、情感提示、文章内容、评论上下文构建Prompt
|
4. **构建Prompt** — 结合AI角色人格、情感提示、文章内容、评论上下文构建Prompt
|
||||||
5. **AI生成** — 调用AI模型生成回复内容
|
5. **AI生成** — 调用AI模型生成回复内容
|
||||||
6. **安全审核** — 对生成内容进行安全审核
|
6. **安全审核** — 对生成内容进行两阶段审核(安全检查 + 质量评分 1-5 分映射到 0-100)
|
||||||
7. **发布/草稿** — 根据设置自动发布或存为草稿等待审核
|
7. **发布/草稿** — 根据设置自动发布或存为草稿等待审核
|
||||||
8. **重试** — 如果AI生成失败,系统会自动重试(最多 maxRetryCount 次),每次重试间隔递增
|
8. **重试** — 如果AI生成失败,系统会自动重试(最多 maxRetryCount 次),每次重试间隔递增
|
||||||
|
|
||||||
## 前置要求
|
## 前置要求
|
||||||
|
|
||||||
- Halo 2.23+
|
- Halo 2.25+
|
||||||
- AI Foundation 插件(必须) — 本插件依赖 AI Foundation 提供的AI模型能力
|
- AI Foundation 插件(必须) — 本插件通过 `ExtensionGetter` 调用 AI Foundation 提供的 `AiModelService` 扩展点
|
||||||
|
|
||||||
## 技术栈
|
## 技术栈
|
||||||
|
|
||||||
- **后端**:Java + Spring WebFlux + Reactive
|
- **后端**:Java + Spring WebFlux + Reactive
|
||||||
- **前端**:Vue 3 + @halo-dev/components
|
- **前端**:Vue 3 + @halo-dev/components
|
||||||
- **AI**:支持 AI Foundation 插件集成
|
- **AI**:通过 AI Foundation 插件集成
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ AI回复者的显示名称,默认为「小回」。修改后新回复将使用
|
|||||||
填写邮箱后,AI回复者的头像将通过 Gravatar 服务自动生成:
|
填写邮箱后,AI回复者的头像将通过 Gravatar 服务自动生成:
|
||||||
|
|
||||||
1. 插件根据邮箱生成 SHA-256 哈希
|
1. 插件根据邮箱生成 SHA-256 哈希
|
||||||
2. 构造 Gravatar URL:`https://cn.cravatar.com/avatar/{hash}`
|
2. 构造 Gravatar URL:`https://cn.cravatar.com/avatar/{hash}`(使用 [Cravatar](https://cn.cravatar.com) 镜像服务)
|
||||||
3. 头像URL存储在评论的 `owner.annotations["avatar"]` 中
|
3. 头像URL存储在评论的 `owner.annotations["avatar"]` 中
|
||||||
|
|
||||||
::: warning
|
::: warning
|
||||||
|
|||||||
+28
-24
@@ -9,6 +9,8 @@ Prompt模板控制AI生成回复时的完整提示词结构。
|
|||||||
|
|
||||||
{{safety_prompt}}
|
{{safety_prompt}}
|
||||||
|
|
||||||
|
【语言要求】请用评论所使用的语言回复。如果评论是英文,请用英文回复;如果是中文,请用中文回复;如果是日文,请用日文回复;以此类推。
|
||||||
|
|
||||||
请回复以下评论。注意:
|
请回复以下评论。注意:
|
||||||
- 回复长度应与评论长度匹配,简短问候简短回复
|
- 回复长度应与评论长度匹配,简短问候简短回复
|
||||||
- 不要复述或总结文章内容
|
- 不要复述或总结文章内容
|
||||||
@@ -21,6 +23,7 @@ Prompt模板控制AI生成回复时的完整提示词结构。
|
|||||||
文章(仅供理解上下文,不要复述):
|
文章(仅供理解上下文,不要复述):
|
||||||
{{article}}
|
{{article}}
|
||||||
|
|
||||||
|
{{conversation_history}}
|
||||||
评论:
|
评论:
|
||||||
{{comment}}
|
{{comment}}
|
||||||
```
|
```
|
||||||
@@ -29,23 +32,26 @@ Prompt模板控制AI生成回复时的完整提示词结构。
|
|||||||
|
|
||||||
| 变量 | 说明 | 注入时机 |
|
| 变量 | 说明 | 注入时机 |
|
||||||
|------|------|---------|
|
|------|------|---------|
|
||||||
| `{{persona_prompt}}` | AI角色人格提示词 | 始终注入 |
|
| `{{persona_prompt}}` | AI角色人格提示词(含已启用的预设) | 始终注入 |
|
||||||
| `{{safety_prompt}}` | 安全规范提示词 | 始终注入 |
|
| `{{safety_prompt}}` | 安全规范提示词 | 始终注入 |
|
||||||
| `{{sentiment_prompt}}` | 情感语气提示词 | 情感分析后自动注入,不在模板中显式使用 |
|
|
||||||
| `{{post_title}}` | 文章标题 | 始终注入 |
|
| `{{post_title}}` | 文章标题 | 始终注入 |
|
||||||
| `{{post_date}}` | 文章发布日期(如 2024-01-15) | 始终注入 |
|
| `{{post_date}}` | 文章发布日期(如 2024-01-15) | 始终注入 |
|
||||||
| `{{comment_count}}` | 该文章的评论数 | 始终注入 |
|
| `{{comment_count}}` | 该文章的评论数 | 始终注入 |
|
||||||
| `{{article}}` | 文章/页面内容(含标题) | 始终注入 |
|
| `{{article}}` | 文章/页面内容(含标题) | 始终注入 |
|
||||||
|
| `{{conversation_history}}` | 对话历史上下文 | 多轮对话时注入 |
|
||||||
| `{{comment}}` | 评论内容(含评论者名称) | 始终注入 |
|
| `{{comment}}` | 评论内容(含评论者名称) | 始终注入 |
|
||||||
| `{{conversation}}` | 对话上下文 | 多轮对话时注入 |
|
|
||||||
|
::: warning 变量名注意
|
||||||
|
对话上下文变量是 `{{conversation_history}}`(不是 `{{conversation}}`)。如果模板中使用了错误的变量名,该变量不会被替换。
|
||||||
|
:::
|
||||||
|
|
||||||
## 情感提示
|
## 情感提示
|
||||||
|
|
||||||
情感提示由插件根据情感分析结果自动注入到Prompt中,不需要在模板中手动添加:
|
情感提示由插件根据情感分析结果自动追加到 Prompt 末尾,不需要在模板中手动添加:
|
||||||
|
|
||||||
- **正面** → "评论者情绪积极友好,请用热情友好的语气回复,表达感谢和共鸣。"
|
- **正面** → 追加"评论者情绪正面积极,请用热情友好的语气回复,可以表达感谢和共鸣。"
|
||||||
- **负面** → "评论者情绪偏消极或不满,请用理性温和的语气回复,避免激化矛盾,适当表示理解。"
|
- **负面** → 追加"评论者情绪偏负面,请用理性温和的语气回复,避免激化矛盾,展现理解和包容。"
|
||||||
- **中性** → 不注入额外提示
|
- **中性** → 不追加额外提示
|
||||||
|
|
||||||
## 安全提示
|
## 安全提示
|
||||||
|
|
||||||
@@ -56,6 +62,17 @@ Prompt模板控制AI生成回复时的完整提示词结构。
|
|||||||
- 不生成虚假信息
|
- 不生成虚假信息
|
||||||
- 回复内容与评论相关
|
- 回复内容与评论相关
|
||||||
|
|
||||||
|
## 预设风格
|
||||||
|
|
||||||
|
在 Prompt 设置页面可以多选启用预设风格,启用后预设提示词会自动合并到 `{{persona_prompt}}` 之后:
|
||||||
|
|
||||||
|
| 预设 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| 友好型 | 热情友好,多用感叹号和表情符号,口语化表达 |
|
||||||
|
| 专业型 | 专业严谨,正式语言风格,有逻辑性 |
|
||||||
|
| 幽默型 | 适当加入幽默元素,轻松诙谐但不过度 |
|
||||||
|
| 简洁型 | 非常简洁,一两句话即可,不展开讨论 |
|
||||||
|
|
||||||
## 自定义建议
|
## 自定义建议
|
||||||
|
|
||||||
自定义Prompt模板时,建议:
|
自定义Prompt模板时,建议:
|
||||||
@@ -63,20 +80,7 @@ Prompt模板控制AI生成回复时的完整提示词结构。
|
|||||||
1. 保留 `{{persona_prompt}}` 和 `{{safety_prompt}}` 变量
|
1. 保留 `{{persona_prompt}}` 和 `{{safety_prompt}}` 变量
|
||||||
2. 保留 `{{article}}` 和 `{{comment}}` 变量
|
2. 保留 `{{article}}` 和 `{{comment}}` 变量
|
||||||
3. 利用 `{{post_title}}`、`{{post_date}}`、`{{comment_count}}` 提供更丰富的上下文
|
3. 利用 `{{post_title}}`、`{{post_date}}`、`{{comment_count}}` 提供更丰富的上下文
|
||||||
4. 在变量之间添加清晰的分隔和指令
|
4. 保留 `{{conversation_history}}` 以支持多轮对话上下文
|
||||||
5. 避免让AI复述文章内容
|
5. 在变量之间添加清晰的分隔和指令
|
||||||
6. 控制回复长度和风格
|
6. 避免让AI复述文章内容
|
||||||
|
7. 控制回复长度和风格
|
||||||
## 变量使用示例
|
|
||||||
|
|
||||||
### 根据评论数调整回复风格
|
|
||||||
|
|
||||||
```
|
|
||||||
{{comment_count}}条评论说明这篇文章{{#if comment_count > 10}}很受欢迎{{/if}}。
|
|
||||||
```
|
|
||||||
|
|
||||||
### 利用发布日期
|
|
||||||
|
|
||||||
```
|
|
||||||
这篇文章发布于{{post_date}},回复时请考虑时效性。
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
## 工作原理
|
## 工作原理
|
||||||
|
|
||||||
1. 评论通过过滤检查后,调用AI对评论内容进行情感分析
|
1. 评论通过过滤检查后,调用AI对评论内容进行情感分析
|
||||||
2. AI返回情感分类结果(POSITIVE / NEUTRAL / NEGATIVE)
|
2. AI 使用结构化输出(`OutputSpec.choice`)返回情感分类结果(POSITIVE / NEUTRAL / NEGATIVE)
|
||||||
3. 如果情感分析失败(如AI不可用),默认降级为 NEUTRAL
|
3. 如果情感分析失败(如AI不可用),默认降级为 NEUTRAL
|
||||||
4. 情感结果传入 PromptBuilder,在生成Prompt时注入对应的语气提示
|
4. 情感结果传入 PromptBuilder,在生成Prompt时追加对应的语气提示
|
||||||
5. 情感结果同时记录在 `AiCommentReply` 的 `sentiment` 字段中
|
5. 情感结果同时记录在 `AiCommentReply` 的 `sentiment` 字段中
|
||||||
|
|
||||||
## 日志展示
|
## 日志展示
|
||||||
|
|||||||
+60
-15
@@ -1,30 +1,50 @@
|
|||||||
# 插件设置
|
# 插件设置
|
||||||
|
|
||||||
插件设置页面位于 **AI回评** → **插件设置**,包含以下配置组:
|
插件设置页面位于 **AI回评** → **插件设置**,通过标签栏切换以下五个配置页面:
|
||||||
|
|
||||||
|
- 基本设置
|
||||||
|
- AI角色设置
|
||||||
|
- 模型设置
|
||||||
|
- Prompt设置
|
||||||
|
- 数据清理
|
||||||
|
|
||||||
## 基本设置
|
## 基本设置
|
||||||
|
|
||||||
| 配置项 | 说明 | 默认值 |
|
| 配置项 | 说明 | 默认值 |
|
||||||
|--------|------|--------|
|
|--------|------|--------|
|
||||||
| 自动回复 | 是否启用自动回复功能 | 开启 |
|
| 自动回复 | 是否启用自动回复功能 | 开启 |
|
||||||
| 自动发布 | AI回复是否自动发布 | 开启 |
|
| 自动发布 | AI回复是否自动发布,关闭则存为草稿 | 开启 |
|
||||||
|
| 最大对话轮次 | 同一评论线程中AI最多自动回复的轮次 | 8 |
|
||||||
|
| 速率限制 | 每分钟最大AI回复数量,防止批量评论消耗过多额度 | 10 |
|
||||||
| 最大重试次数 | AI生成失败时的最大重试次数 | 3 |
|
| 最大重试次数 | AI生成失败时的最大重试次数 | 3 |
|
||||||
| 评论者黑名单 | 不触发AI回复的评论者显示名称或邮箱,逗号分隔 | 空 |
|
| 评论者黑名单 | 不触发AI回复的评论者,支持名称、邮箱和正则表达式(`regex:` 开头),逗号分隔 | 空 |
|
||||||
|
|
||||||
|
::: tip 评论者黑名单
|
||||||
|
黑名单支持三种格式:
|
||||||
|
- **名称**:如 `张三`
|
||||||
|
- **邮箱**:如 `spam@example.com`(不区分大小写)
|
||||||
|
- **正则表达式**:以 `regex:` 开头,如 `regex:^spam.*`
|
||||||
|
|
||||||
|
点击"添加评论者"按钮可从已有评论列表中选择评论者自动添加到黑名单。
|
||||||
|
:::
|
||||||
|
|
||||||
## AI角色设置
|
## AI角色设置
|
||||||
|
|
||||||
|
AI角色定义了回复评论的虚拟身份。支持创建多个角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可指定一个为默认角色。
|
||||||
|
|
||||||
| 配置项 | 说明 | 默认值 |
|
| 配置项 | 说明 | 默认值 |
|
||||||
|--------|------|--------|
|
|--------|------|--------|
|
||||||
| AI角色昵称 | AI回复者的显示名称 | 小回 |
|
| 角色昵称 | AI回复者的显示名称 | 小回 |
|
||||||
| AI角色人格提示词 | 定义AI角色的人格和回复风格 | 见下方 |
|
| 人格提示词 | 定义AI角色的人格和回复风格 | 见下方 |
|
||||||
| AI角色邮箱 | 用于Gravatar头像服务展示头像 | 空 |
|
| 邮箱 | 用于 Gravatar 头像服务展示头像 | 空 |
|
||||||
|
| 设为默认 | 将该角色设为默认角色 | 第一个角色默认 |
|
||||||
|
|
||||||
默认人格提示词:
|
默认人格提示词:
|
||||||
|
|
||||||
> 你是「小回」,一个友善的评论者。你的回复简洁自然,像朋友聊天一样。简短的评论就简短回复,有深度的讨论才展开回应。不要长篇大论,不要复述文章内容。
|
> 你是「小回」,一个友善的评论者。你的回复简洁自然,像朋友聊天一样。简短的评论就简短回复,有深度的讨论才展开回应。不要长篇大论,不要复述文章内容。
|
||||||
|
|
||||||
::: tip Gravatar头像
|
::: tip Gravatar头像
|
||||||
填写邮箱后,AI回复者的头像将通过 [Gravatar](https://gravatar.com) 服务自动生成。如果不填写邮箱,将使用默认头像。
|
填写邮箱后,AI回复者的头像将通过 [Gravatar](https://gravatar.com) 服务自动生成,使用 [Cravatar](https://cn.cravatar.com) 镜像。如果不填写邮箱,将使用默认头像。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## 模型设置
|
## 模型设置
|
||||||
@@ -42,17 +62,38 @@
|
|||||||
| 配置项 | 说明 | 默认值 |
|
| 配置项 | 说明 | 默认值 |
|
||||||
|--------|------|--------|
|
|--------|------|--------|
|
||||||
| 自定义Prompt模板 | AI生成回复时使用的Prompt模板 | 见下方 |
|
| 自定义Prompt模板 | AI生成回复时使用的Prompt模板 | 见下方 |
|
||||||
|
| 启用预设 | 选择要启用的Prompt预设风格(可多选) | 空 |
|
||||||
|
|
||||||
|
### 预设风格
|
||||||
|
|
||||||
|
| 预设 | 说明 |
|
||||||
|
|------|------|
|
||||||
|
| 友好型 | 热情友好,多用感叹号和表情符号,口语化表达 |
|
||||||
|
| 专业型 | 专业严谨,正式语言风格,有逻辑性 |
|
||||||
|
| 幽默型 | 适当加入幽默元素,轻松诙谐但不过度 |
|
||||||
|
| 简洁型 | 非常简洁,一两句话即可,不展开讨论 |
|
||||||
|
|
||||||
|
预设提示词会自动合并到角色人格提示词之后。
|
||||||
|
|
||||||
### 模板变量
|
### 模板变量
|
||||||
|
|
||||||
| 变量 | 说明 |
|
| 变量 | 说明 | 注入时机 |
|
||||||
|------|------|
|
|------|------|---------|
|
||||||
| `{{persona_prompt}}` | AI角色人格提示词 |
|
| `{{persona_prompt}}` | AI角色人格提示词(含已启用的预设) | 始终注入 |
|
||||||
| `{{safety_prompt}}` | 安全规范提示词 |
|
| `{{safety_prompt}}` | 安全规范提示词 | 始终注入 |
|
||||||
| `{{sentiment_prompt}}` | 情感语气提示词(自动注入) |
|
| `{{post_title}}` | 文章标题 | 始终注入 |
|
||||||
| `{{article}}` | 文章内容 |
|
| `{{post_date}}` | 文章发布日期(如 2024-01-15) | 始终注入 |
|
||||||
| `{{comment}}` | 评论内容 |
|
| `{{comment_count}}` | 该文章的评论数 | 始终注入 |
|
||||||
| `{{conversation}}` | 对话上下文(多轮对话时) |
|
| `{{article}}` | 文章/页面内容(含标题) | 始终注入 |
|
||||||
|
| `{{conversation_history}}` | 对话历史上下文 | 多轮对话时注入 |
|
||||||
|
| `{{comment}}` | 评论内容(含评论者名称) | 始终注入 |
|
||||||
|
|
||||||
|
::: tip 情感提示
|
||||||
|
情感提示由插件根据情感分析结果自动追加到 Prompt 末尾,不需要在模板中手动添加:
|
||||||
|
- **正面** → 追加热情友好的语气提示
|
||||||
|
- **负面** → 追加理性温和的语气提示
|
||||||
|
- **中性** → 不追加额外提示
|
||||||
|
:::
|
||||||
|
|
||||||
## 数据清理
|
## 数据清理
|
||||||
|
|
||||||
@@ -64,3 +105,7 @@
|
|||||||
::: tip
|
::: tip
|
||||||
你也可以在数据清理页面点击"立即清理"按钮手动触发清理操作。
|
你也可以在数据清理页面点击"立即清理"按钮手动触发清理操作。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
::: warning
|
||||||
|
清理操作仅删除 `AiCommentReply` 记录(插件内部的日志记录),不会删除已发布的 Halo Reply 评论。
|
||||||
|
:::
|
||||||
|
|||||||
+4
-84
@@ -216,100 +216,25 @@ public class CommentAiAutopilotEndpoint implements CustomEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Mono<ServerResponse> getStats(ServerRequest request) {
|
private Mono<ServerResponse> getStats(ServerRequest request) {
|
||||||
String range = request.queryParam("range").orElse("7");
|
|
||||||
|
|
||||||
return client.listAll(AiCommentReply.class, ListOptions.builder().build(), Sort.unsorted())
|
return client.listAll(AiCommentReply.class, ListOptions.builder().build(), Sort.unsorted())
|
||||||
.collectList()
|
.collectList()
|
||||||
.map(allReplies -> {
|
.map(replies -> {
|
||||||
// 根据 range 计算截止时间
|
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
|
||||||
LocalDate today = LocalDate.now(zoneId);
|
|
||||||
Instant cutoffInstant;
|
|
||||||
int trendDays;
|
|
||||||
|
|
||||||
if ("all".equals(range)) {
|
|
||||||
cutoffInstant = null; // 不做时间过滤
|
|
||||||
trendDays = 30; // "all" 时趋势也展示最近30天
|
|
||||||
} else {
|
|
||||||
int days = Integer.parseInt(range);
|
|
||||||
cutoffInstant = today.minusDays(days).atStartOfDay(zoneId).toInstant();
|
|
||||||
trendDays = days;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据 range 过滤记录
|
|
||||||
List<AiCommentReply> replies;
|
|
||||||
if (cutoffInstant != null) {
|
|
||||||
replies = allReplies.stream()
|
|
||||||
.filter(r -> {
|
|
||||||
Instant ts = r.getMetadata().getCreationTimestamp();
|
|
||||||
return ts != null && !ts.isBefore(cutoffInstant);
|
|
||||||
})
|
|
||||||
.toList();
|
|
||||||
} else {
|
|
||||||
replies = allReplies;
|
|
||||||
}
|
|
||||||
|
|
||||||
long total = replies.size();
|
long total = replies.size();
|
||||||
long passCount = replies.stream()
|
long passCount = replies.stream()
|
||||||
.filter(r -> "PASS".equals(r.getSpec().getStatus())).count();
|
.filter(r -> "PASS".equals(r.getSpec().getStatus())).count();
|
||||||
long failCount = replies.stream()
|
long failCount = replies.stream()
|
||||||
.filter(r -> "FAIL".equals(r.getSpec().getStatus())).count();
|
.filter(r -> "FAIL".equals(r.getSpec().getStatus())).count();
|
||||||
double avgScore = replies.stream()
|
|
||||||
.filter(r -> r.getSpec().getScore() != null && r.getSpec().getScore() > 0)
|
|
||||||
.mapToInt(r -> r.getSpec().getScore())
|
|
||||||
.average().orElse(0.0);
|
|
||||||
|
|
||||||
long reviewingCount = replies.stream()
|
long reviewingCount = replies.stream()
|
||||||
.filter(r -> "PASS".equals(r.getSpec().getStatus())
|
.filter(r -> "PASS".equals(r.getSpec().getStatus())
|
||||||
&& !Boolean.TRUE.equals(r.getSpec().getPublished()))
|
&& !Boolean.TRUE.equals(r.getSpec().getPublished()))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
Map<String, Long> sentimentDistribution = new HashMap<>();
|
return new StatsResponse(total, passCount, failCount, reviewingCount);
|
||||||
sentimentDistribution.put("POSITIVE", 0L);
|
|
||||||
sentimentDistribution.put("NEUTRAL", 0L);
|
|
||||||
sentimentDistribution.put("NEGATIVE", 0L);
|
|
||||||
sentimentDistribution.put("UNKNOWN", 0L);
|
|
||||||
for (var r : replies) {
|
|
||||||
String sentiment = r.getSpec().getSentiment();
|
|
||||||
if (sentiment == null || sentiment.isBlank()) {
|
|
||||||
sentimentDistribution.merge("UNKNOWN", 1L, Long::sum);
|
|
||||||
} else {
|
|
||||||
sentimentDistribution.merge(sentiment, 1L, Long::sum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算 dailyTrend
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
||||||
Map<LocalDate, Long> dailyMap = new HashMap<>();
|
|
||||||
for (int i = 0; i < trendDays; i++) {
|
|
||||||
dailyMap.put(today.minusDays(i), 0L);
|
|
||||||
}
|
|
||||||
for (var r : replies) {
|
|
||||||
Instant timestamp = r.getMetadata().getCreationTimestamp();
|
|
||||||
if (timestamp != null) {
|
|
||||||
try {
|
|
||||||
LocalDate date = timestamp.atZone(zoneId).toLocalDate();
|
|
||||||
if (dailyMap.containsKey(date)) {
|
|
||||||
dailyMap.merge(date, 1L, Long::sum);
|
|
||||||
}
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<DailyCount> dailyTrend = new ArrayList<>();
|
|
||||||
for (int i = 0; i < trendDays; i++) {
|
|
||||||
LocalDate date = today.minusDays(i);
|
|
||||||
dailyTrend.add(new DailyCount(date.format(formatter), dailyMap.get(date)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new StatsResponse(total, passCount, failCount, avgScore,
|
|
||||||
reviewingCount, sentimentDistribution, dailyTrend);
|
|
||||||
})
|
})
|
||||||
.onErrorResume(e -> {
|
.onErrorResume(e -> {
|
||||||
log.warn("Failed to fetch stats: {}", e.getMessage());
|
log.warn("Failed to fetch stats: {}", e.getMessage());
|
||||||
return Mono.just(new StatsResponse(0, 0, 0, 0.0, 0L,
|
return Mono.just(new StatsResponse(0, 0, 0, 0));
|
||||||
Map.of("POSITIVE", 0L, "NEUTRAL", 0L, "NEGATIVE", 0L, "UNKNOWN", 0L),
|
|
||||||
List.of()));
|
|
||||||
})
|
})
|
||||||
.flatMap(stats -> ServerResponse.ok().bodyValue(stats));
|
.flatMap(stats -> ServerResponse.ok().bodyValue(stats));
|
||||||
}
|
}
|
||||||
@@ -346,16 +271,11 @@ public class CommentAiAutopilotEndpoint implements CustomEndpoint {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public record DailyCount(String date, long count) {}
|
|
||||||
|
|
||||||
public record StatsResponse(
|
public record StatsResponse(
|
||||||
long total,
|
long total,
|
||||||
long passCount,
|
long passCount,
|
||||||
long failCount,
|
long failCount,
|
||||||
double avgScore,
|
long reviewingCount
|
||||||
long reviewingCount,
|
|
||||||
Map<String, Long> sentimentDistribution,
|
|
||||||
List<DailyCount> dailyTrend
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public record PersonaResponse(
|
public record PersonaResponse(
|
||||||
|
|||||||
@@ -1,85 +1,58 @@
|
|||||||
package top.nxxy335.commentaiautopilot.service;
|
package top.nxxy335.commentaiautopilot.service;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import run.halo.app.core.extension.Plugin;
|
import run.halo.aifoundation.AiModelService;
|
||||||
import run.halo.app.extension.ReactiveExtensionClient;
|
import run.halo.aifoundation.chat.GenerateTextRequest;
|
||||||
|
import run.halo.aifoundation.chat.GenerateTextResult;
|
||||||
|
import run.halo.aifoundation.schema.OutputSpec;
|
||||||
|
import run.halo.app.plugin.extensionpoint.ExtensionGetter;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AI Foundation client that uses runtime class loading and reflection
|
* AI Foundation client that uses Halo's {@link ExtensionGetter} to obtain the
|
||||||
* to call the AI Foundation plugin's AiModelService.
|
* {@link AiModelService} extension provided by the ai-foundation plugin.
|
||||||
* <p>
|
* <p>
|
||||||
* This approach avoids classloader identity issues by loading AiModelService
|
* This is the recommended way to integrate with AI Foundation, see
|
||||||
* from ai-foundation's own classloader, so that Spring's getBeansOfType()
|
* <a href="https://github.com/halo-dev/plugin-ai-foundation/blob/main/dev/dev.md">dev guide</a>.
|
||||||
* can correctly match the implementation bean.
|
|
||||||
* <p>
|
* <p>
|
||||||
* No @ConditionalOnClass or pluginDependencies needed.
|
* Requires the following declaration in plugin.yaml:
|
||||||
* Always registered as a bean; availability is checked at runtime.
|
* <pre>
|
||||||
|
* spec:
|
||||||
|
* pluginDependencies:
|
||||||
|
* ai-foundation?: "*"
|
||||||
|
* </pre>
|
||||||
|
* The dependency is optional, so the plugin still loads when AI Foundation is
|
||||||
|
* not installed; availability is checked at runtime and all calls return empty
|
||||||
|
* in that case.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AiFoundationClient {
|
public class AiFoundationClient {
|
||||||
|
|
||||||
private static final String AI_FOUNDATION_PLUGIN_NAME = "ai-foundation";
|
private final ExtensionGetter extensionGetter;
|
||||||
private static final String AI_MODEL_SERVICE_CLASS = "run.halo.aifoundation.AiModelService";
|
|
||||||
|
|
||||||
private final ReactiveExtensionClient client;
|
public AiFoundationClient(ExtensionGetter extensionGetter) {
|
||||||
private final ApplicationContext applicationContext;
|
this.extensionGetter = extensionGetter;
|
||||||
|
|
||||||
public AiFoundationClient(ReactiveExtensionClient client, ApplicationContext applicationContext) {
|
|
||||||
this.client = client;
|
|
||||||
this.applicationContext = applicationContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call AI Foundation to generate a chat response using the specified model.
|
* Call AI Foundation to generate a chat response using the specified model.
|
||||||
|
* Uses {@link GenerateTextRequest} with {@code maxRetries=2} so that
|
||||||
|
* transient model errors are retried by the SDK.
|
||||||
*
|
*
|
||||||
* @param prompt the prompt text
|
* @param prompt the prompt text
|
||||||
* @param modelName the AiModel metadata.name, null or blank to use default model
|
* @param modelName the AiModel metadata.name, null or blank to use default model
|
||||||
* @return the generated text, or empty if AI Foundation is unavailable
|
* @return the generated text, or empty if AI Foundation is unavailable
|
||||||
*/
|
*/
|
||||||
public Mono<String> chat(String prompt, String modelName) {
|
public Mono<String> chat(String prompt, String modelName) {
|
||||||
return isAiFoundationEnabled()
|
return aiModelService()
|
||||||
.flatMap(enabled -> {
|
.flatMap(service -> service.languageModel(modelName != null ? modelName : "")
|
||||||
if (!enabled) {
|
.flatMap(model -> model.generateText(
|
||||||
log.warn("AI Foundation plugin is not installed or not enabled, skipping AI reply");
|
GenerateTextRequest.builder().prompt(prompt).maxRetries(2).build()))
|
||||||
return Mono.empty();
|
.map(GenerateTextResult::getText))
|
||||||
}
|
|
||||||
return doChat(prompt, modelName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if AI Foundation is available: plugin installed, enabled, and AiModelService bean found.
|
|
||||||
*/
|
|
||||||
public Mono<Boolean> isAvailable() {
|
|
||||||
return isAiFoundationEnabled()
|
|
||||||
.flatMap(enabled -> {
|
|
||||||
if (!enabled) return Mono.just(false);
|
|
||||||
return findAiModelService().hasElement();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<Boolean> isAiFoundationEnabled() {
|
|
||||||
return client.fetch(Plugin.class, AI_FOUNDATION_PLUGIN_NAME)
|
|
||||||
.map(plugin -> plugin.getSpec().getEnabled())
|
|
||||||
.defaultIfEmpty(false)
|
|
||||||
.onErrorResume(e -> {
|
|
||||||
log.debug("Failed to check AI Foundation plugin status: {}", e.getMessage());
|
|
||||||
return Mono.just(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<String> doChat(String prompt, String modelName) {
|
|
||||||
return findAiModelService()
|
|
||||||
.flatMap(service -> invokeLanguageModel(service, modelName)
|
|
||||||
.flatMap(model -> invokeGenerateText(model, prompt))
|
|
||||||
)
|
|
||||||
.doOnError(e -> log.error("AI Foundation call failed: {}", e.getMessage()))
|
.doOnError(e -> log.error("AI Foundation call failed: {}", e.getMessage()))
|
||||||
.onErrorResume(e -> {
|
.onErrorResume(e -> {
|
||||||
log.warn("AI Foundation not available: {}", e.getMessage());
|
log.warn("AI Foundation not available: {}", e.getMessage());
|
||||||
@@ -88,132 +61,68 @@ public class AiFoundationClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PluginManager via the pluginWrapper bean registered in our plugin context.
|
* Call AI Foundation to classify text into one of the given choices using
|
||||||
* Halo's DefaultPluginApplicationContextFactory registers pluginWrapper as a singleton:
|
* structured output ({@link OutputSpec#choice(List)}).
|
||||||
* beanFactory.registerSingleton("pluginWrapper", pluginWrapper);
|
* <p>
|
||||||
* Then PluginWrapper.getPluginManager() gives us the PluginManager instance.
|
* This is the recommended way to do classification per the dev guide,
|
||||||
|
* as it is more reliable than prompt parsing.
|
||||||
|
*
|
||||||
|
* @param systemPrompt system prompt describing the task
|
||||||
|
* @param userPrompt the user input to classify
|
||||||
|
* @param choices the allowed classification values
|
||||||
|
* @param modelName the AiModel metadata.name, null or blank to use default model
|
||||||
|
* @return the selected choice string, or empty if AI Foundation is unavailable
|
||||||
*/
|
*/
|
||||||
private Object findPluginManager() {
|
public Mono<String> classify(String systemPrompt, String userPrompt,
|
||||||
try {
|
List<String> choices, String modelName) {
|
||||||
Object pluginWrapper = applicationContext.getBean("pluginWrapper");
|
return aiModelService()
|
||||||
Method getPluginManagerMethod = pluginWrapper.getClass().getMethod("getPluginManager");
|
.flatMap(service -> service.languageModel(modelName != null ? modelName : "")
|
||||||
getPluginManagerMethod.setAccessible(true);
|
.flatMap(model -> model.generateText(
|
||||||
Object pm = getPluginManagerMethod.invoke(pluginWrapper);
|
GenerateTextRequest.builder()
|
||||||
if (pm != null) {
|
.system(systemPrompt)
|
||||||
log.info("Found PluginManager via pluginWrapper bean: {}", pm.getClass().getName());
|
.prompt(userPrompt)
|
||||||
}
|
.output(OutputSpec.choice(choices))
|
||||||
return pm;
|
.maxRetries(2)
|
||||||
} catch (NoSuchMethodException e) {
|
.build()))
|
||||||
log.warn("pluginWrapper does not have getPluginManager() method: {}", e.getMessage());
|
.map(result -> {
|
||||||
} catch (Exception e) {
|
Object output = result.getOutput();
|
||||||
log.warn("Failed to get PluginManager via pluginWrapper: {}", e.getMessage());
|
return output != null ? String.valueOf(output).trim() : "";
|
||||||
}
|
}))
|
||||||
log.warn("PluginManager not found");
|
.doOnError(e -> log.error("AI Foundation classify failed: {}", e.getMessage()))
|
||||||
return null;
|
.onErrorResume(e -> {
|
||||||
}
|
log.warn("AI Foundation not available: {}", e.getMessage());
|
||||||
|
return Mono.empty();
|
||||||
/**
|
|
||||||
* Find the AiModelService bean from ai-foundation's PluginApplicationContext.
|
|
||||||
* Uses PluginManager.getPlugin() to get the plugin wrapper, then reflection
|
|
||||||
* to get the plugin's ApplicationContext.
|
|
||||||
*/
|
|
||||||
private Mono<Object> findAiModelService() {
|
|
||||||
return Mono.fromCallable(() -> {
|
|
||||||
Object pm = findPluginManager();
|
|
||||||
if (pm == null) return null;
|
|
||||||
|
|
||||||
// Call pm.getPlugin("ai-foundation") via reflection
|
|
||||||
Method getPluginMethod = pm.getClass().getMethod("getPlugin", String.class);
|
|
||||||
getPluginMethod.setAccessible(true);
|
|
||||||
Object pluginWrapper = getPluginMethod.invoke(pm, AI_FOUNDATION_PLUGIN_NAME);
|
|
||||||
if (pluginWrapper == null) {
|
|
||||||
log.debug("ai-foundation plugin not found in PluginManager");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call pluginWrapper.getPlugin() to get the plugin instance
|
|
||||||
Method getPluginInstanceMethod = pluginWrapper.getClass().getMethod("getPlugin");
|
|
||||||
getPluginInstanceMethod.setAccessible(true);
|
|
||||||
Object pluginInstance = getPluginInstanceMethod.invoke(pluginWrapper);
|
|
||||||
if (pluginInstance == null) {
|
|
||||||
log.debug("ai-foundation plugin instance is null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the plugin's ApplicationContext via reflection on SpringPlugin
|
|
||||||
// DefaultSpringPlugin is package-private, so we need setAccessible
|
|
||||||
Method getCtxMethod = pluginInstance.getClass().getMethod("getApplicationContext");
|
|
||||||
getCtxMethod.setAccessible(true);
|
|
||||||
ApplicationContext pluginAppContext = (ApplicationContext) getCtxMethod.invoke(pluginInstance);
|
|
||||||
|
|
||||||
// Get the plugin classloader
|
|
||||||
Method getClassLoaderMethod = pluginWrapper.getClass().getMethod("getPluginClassLoader");
|
|
||||||
getClassLoaderMethod.setAccessible(true);
|
|
||||||
ClassLoader pluginClassLoader = (ClassLoader) getClassLoaderMethod.invoke(pluginWrapper);
|
|
||||||
|
|
||||||
// Load AiModelService from ai-foundation's classloader
|
|
||||||
Class<?> aiModelServiceClass = pluginClassLoader.loadClass(AI_MODEL_SERVICE_CLASS);
|
|
||||||
|
|
||||||
// Find the AiModelService bean in ai-foundation's ApplicationContext
|
|
||||||
Map<String, ?> beans = pluginAppContext.getBeansOfType(aiModelServiceClass);
|
|
||||||
if (beans.isEmpty()) {
|
|
||||||
log.debug("AiModelService bean not found in ai-foundation's ApplicationContext");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Found AiModelService bean in ai-foundation's ApplicationContext");
|
|
||||||
Object result = beans.values().iterator().next();
|
|
||||||
return (Object) result;
|
|
||||||
}).doOnError(e -> log.error("Failed to find AiModelService: {}", e.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call service.languageModel(modelName) or service.languageModel() via reflection.
|
|
||||||
* Returns Mono<LanguageModel> from ai-foundation's classloader.
|
|
||||||
*/
|
|
||||||
private Mono<Object> invokeLanguageModel(Object service, String modelName) {
|
|
||||||
return Mono.fromCallable(() -> {
|
|
||||||
Method method;
|
|
||||||
if (modelName != null && !modelName.isBlank()) {
|
|
||||||
method = service.getClass().getMethod("languageModel", String.class);
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(service, modelName);
|
|
||||||
} else {
|
|
||||||
method = service.getClass().getMethod("languageModel");
|
|
||||||
method.setAccessible(true);
|
|
||||||
return method.invoke(service);
|
|
||||||
}
|
|
||||||
}).flatMap(result -> {
|
|
||||||
if (result instanceof Mono<?> mono) return mono;
|
|
||||||
return Mono.justOrEmpty(result);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call model.generateText(prompt) via reflection, then extract text from result.
|
* Check if AI Foundation is available: plugin installed and an
|
||||||
* Returns the generated text string.
|
* AiModelService extension is enabled.
|
||||||
*/
|
*/
|
||||||
private Mono<String> invokeGenerateText(Object model, String prompt) {
|
public Mono<Boolean> isAvailable() {
|
||||||
return Mono.fromCallable(() -> {
|
return aiModelService().hasElement()
|
||||||
Method method = model.getClass().getMethod("generateText", String.class);
|
.onErrorResume(e -> {
|
||||||
method.setAccessible(true);
|
log.debug("AI Foundation not available: {}", e.getMessage());
|
||||||
return method.invoke(model, prompt);
|
return Mono.just(false);
|
||||||
}).flatMap(result -> {
|
|
||||||
if (result instanceof Mono<?> mono) {
|
|
||||||
return mono.map(this::extractText);
|
|
||||||
}
|
|
||||||
return Mono.justOrEmpty(extractText(result));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractText(Object result) {
|
/**
|
||||||
if (result == null) return null;
|
* Obtain the enabled AiModelService extension via ExtensionGetter.
|
||||||
|
* <p>
|
||||||
|
* Wrapped in {@link Mono#defer} with a {@link NoClassDefFoundError} guard so
|
||||||
|
* that the plugin still works when the optional ai-foundation dependency is
|
||||||
|
* not installed (the AiModelService API class is then absent from the
|
||||||
|
* classloader).
|
||||||
|
*/
|
||||||
|
private Mono<AiModelService> aiModelService() {
|
||||||
|
return Mono.defer(() -> {
|
||||||
try {
|
try {
|
||||||
Method getText = result.getClass().getMethod("getText");
|
return extensionGetter.getEnabledExtension(AiModelService.class);
|
||||||
getText.setAccessible(true);
|
} catch (NoClassDefFoundError e) {
|
||||||
return (String) getText.invoke(result);
|
log.debug("AI Foundation API not on classpath: {}", e.getMessage());
|
||||||
} catch (Exception e) {
|
return Mono.empty();
|
||||||
throw new RuntimeException("Failed to call getText() on GenerateTextResult: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,12 +231,13 @@ public class AiReplyOrchestrator {
|
|||||||
}
|
}
|
||||||
return publishReply(context, aiReply, replyRecord, reviewResult.score(), personaName);
|
return publishReply(context, aiReply, replyRecord, reviewResult.score(), personaName);
|
||||||
})
|
})
|
||||||
.switchIfEmpty(
|
|
||||||
publishReply(context, aiReply, replyRecord, 100, personaName)
|
|
||||||
)
|
|
||||||
.onErrorResume(e -> {
|
.onErrorResume(e -> {
|
||||||
log.warn("[Orchestrator] Review error, auto-passing: {}", e.getMessage());
|
// review() already handles errors internally (returns PASS),
|
||||||
return publishReply(context, aiReply, replyRecord, 100, personaName);
|
// so this only fires for errors from publishReply/updateRecord.
|
||||||
|
// Do NOT re-call publishReply to avoid double-publish / overwriting published=false.
|
||||||
|
log.error("[Orchestrator] Error during review/publish for {}: {}",
|
||||||
|
context.commentId(), e.getMessage(), e);
|
||||||
|
return Mono.empty();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,55 @@ public class ContextExtractor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch previous replies in the comment thread to provide conversation history.
|
||||||
|
* Only includes replies created before the triggering reply.
|
||||||
|
*/
|
||||||
|
private Mono<String> fetchConversationHistory(String commentName, String triggerReplyName) {
|
||||||
|
if (triggerReplyName == null || triggerReplyName.isBlank()) {
|
||||||
|
return Mono.just("");
|
||||||
|
}
|
||||||
|
return client.fetch(Reply.class, triggerReplyName)
|
||||||
|
.flatMap(triggerReply -> {
|
||||||
|
var triggerTime = triggerReply.getMetadata().getCreationTimestamp();
|
||||||
|
return client.list(Reply.class,
|
||||||
|
reply -> {
|
||||||
|
if (!commentName.equals(reply.getSpec().getCommentName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (triggerReplyName.equals(reply.getMetadata().getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Only include replies created before the trigger reply
|
||||||
|
var replyTime = reply.getMetadata().getCreationTimestamp();
|
||||||
|
return replyTime != null && triggerTime != null
|
||||||
|
&& !replyTime.isAfter(triggerTime);
|
||||||
|
},
|
||||||
|
null)
|
||||||
|
.collectList()
|
||||||
|
.map(replies -> {
|
||||||
|
if (replies.isEmpty()) return "";
|
||||||
|
// Sort by creation time
|
||||||
|
replies.sort(java.util.Comparator.comparing(
|
||||||
|
r -> r.getMetadata().getCreationTimestamp()));
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
for (var r : replies) {
|
||||||
|
var owner = r.getSpec().getOwner();
|
||||||
|
String name = (owner != null && owner.getDisplayName() != null)
|
||||||
|
? owner.getDisplayName() : "匿名用户";
|
||||||
|
boolean isAi = owner != null && owner.getAnnotations() != null
|
||||||
|
&& "true".equals(owner.getAnnotations().get("comment-ai-autopilot.nxxy335.top/is-ai"));
|
||||||
|
String role = isAi ? "AI" : "用户";
|
||||||
|
String content = extractReplyContent(r);
|
||||||
|
sb.append(role).append("(").append(name).append("): ")
|
||||||
|
.append(content).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.defaultIfEmpty("");
|
||||||
|
}
|
||||||
|
|
||||||
private Mono<CommentContext> buildContext(Comment comment, boolean isAiConversation) {
|
private Mono<CommentContext> buildContext(Comment comment, boolean isAiConversation) {
|
||||||
var commentContent = extractCommentContent(comment);
|
var commentContent = extractCommentContent(comment);
|
||||||
var commentOwner = extractCommentOwner(comment);
|
var commentOwner = extractCommentOwner(comment);
|
||||||
@@ -63,7 +112,8 @@ public class ContextExtractor {
|
|||||||
null,
|
null,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
formatPostDate(post),
|
formatPostDate(post),
|
||||||
commentCount
|
commentCount,
|
||||||
|
""
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -78,7 +128,8 @@ public class ContextExtractor {
|
|||||||
null,
|
null,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
"",
|
"",
|
||||||
0
|
0,
|
||||||
|
""
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +144,8 @@ public class ContextExtractor {
|
|||||||
null,
|
null,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
"",
|
"",
|
||||||
0
|
0,
|
||||||
|
""
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,54 +153,67 @@ public class ContextExtractor {
|
|||||||
var replyContent = extractReplyContent(reply);
|
var replyContent = extractReplyContent(reply);
|
||||||
var replyOwner = extractReplyOwner(reply);
|
var replyOwner = extractReplyOwner(reply);
|
||||||
var subjectRef = comment.getSpec().getSubjectRef();
|
var subjectRef = comment.getSpec().getSubjectRef();
|
||||||
|
var commentName = comment.getMetadata().getName();
|
||||||
|
var replyName = reply.getMetadata().getName();
|
||||||
|
|
||||||
|
// Fetch conversation history for AI conversations
|
||||||
|
Mono<String> historyMono = isAiConversation
|
||||||
|
? fetchConversationHistory(commentName, replyName)
|
||||||
|
: Mono.just("");
|
||||||
|
|
||||||
if (subjectRef != null && "Post".equals(subjectRef.getKind())) {
|
if (subjectRef != null && "Post".equals(subjectRef.getKind())) {
|
||||||
String postName = subjectRef.getName();
|
String postName = subjectRef.getName();
|
||||||
return client.fetch(Post.class, postName)
|
return client.fetch(Post.class, postName)
|
||||||
.flatMap(post -> getPostContent(postName)
|
.flatMap(post -> getPostContent(postName)
|
||||||
.flatMap(content -> getCommentCount(comment.getMetadata().getName())
|
.flatMap(content -> getCommentCount(commentName)
|
||||||
.map(commentCount -> new CommentContext(
|
.flatMap(commentCount -> historyMono
|
||||||
comment.getMetadata().getName(),
|
.map(history -> new CommentContext(
|
||||||
|
commentName,
|
||||||
postName,
|
postName,
|
||||||
post.getSpec().getSlug(),
|
post.getSpec().getSlug(),
|
||||||
replyContent,
|
replyContent,
|
||||||
replyOwner,
|
replyOwner,
|
||||||
post.getSpec().getTitle(),
|
post.getSpec().getTitle(),
|
||||||
content,
|
content,
|
||||||
reply.getMetadata().getName(),
|
replyName,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
formatPostDate(post),
|
formatPostDate(post),
|
||||||
commentCount
|
commentCount,
|
||||||
|
history
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
.defaultIfEmpty(new CommentContext(
|
.defaultIfEmpty(new CommentContext(
|
||||||
comment.getMetadata().getName(),
|
commentName,
|
||||||
postName,
|
postName,
|
||||||
"",
|
"",
|
||||||
replyContent,
|
replyContent,
|
||||||
replyOwner,
|
replyOwner,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
reply.getMetadata().getName(),
|
replyName,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
"",
|
"",
|
||||||
0
|
0,
|
||||||
|
""
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Mono.just(new CommentContext(
|
return historyMono
|
||||||
comment.getMetadata().getName(),
|
.map(history -> new CommentContext(
|
||||||
|
commentName,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
replyContent,
|
replyContent,
|
||||||
replyOwner,
|
replyOwner,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
reply.getMetadata().getName(),
|
replyName,
|
||||||
isAiConversation,
|
isAiConversation,
|
||||||
"",
|
"",
|
||||||
0
|
0,
|
||||||
|
history
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,6 +310,7 @@ public class ContextExtractor {
|
|||||||
String replyTo,
|
String replyTo,
|
||||||
boolean isAiConversation,
|
boolean isAiConversation,
|
||||||
String postDate,
|
String postDate,
|
||||||
int commentCount
|
int commentCount,
|
||||||
|
String conversationHistory
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class PromptBuilder {
|
|||||||
文章(仅供理解上下文,不要复述):
|
文章(仅供理解上下文,不要复述):
|
||||||
{{article}}
|
{{article}}
|
||||||
|
|
||||||
|
{{conversation_history}}
|
||||||
评论:
|
评论:
|
||||||
{{comment}}
|
{{comment}}
|
||||||
""";
|
""";
|
||||||
@@ -103,6 +104,7 @@ public class PromptBuilder {
|
|||||||
.replace("{{post_date}}", context.postDate() != null ? context.postDate() : "")
|
.replace("{{post_date}}", context.postDate() != null ? context.postDate() : "")
|
||||||
.replace("{{comment_count}}", String.valueOf(context.commentCount()))
|
.replace("{{comment_count}}", String.valueOf(context.commentCount()))
|
||||||
.replace("{{article}}", context.postTitle() + "\n" + context.postContent())
|
.replace("{{article}}", context.postTitle() + "\n" + context.postContent())
|
||||||
|
.replace("{{conversation_history}}", formatConversationHistory(context))
|
||||||
.replace("{{comment}}", context.commentOwner() + ": " + context.commentContent());
|
.replace("{{comment}}", context.commentOwner() + ": " + context.commentContent());
|
||||||
|
|
||||||
return prompt;
|
return prompt;
|
||||||
@@ -133,6 +135,7 @@ public class PromptBuilder {
|
|||||||
.replace("{{post_date}}", context.postDate() != null ? context.postDate() : "")
|
.replace("{{post_date}}", context.postDate() != null ? context.postDate() : "")
|
||||||
.replace("{{comment_count}}", String.valueOf(context.commentCount()))
|
.replace("{{comment_count}}", String.valueOf(context.commentCount()))
|
||||||
.replace("{{article}}", context.postTitle() + "\n" + context.postContent())
|
.replace("{{article}}", context.postTitle() + "\n" + context.postContent())
|
||||||
|
.replace("{{conversation_history}}", formatConversationHistory(context))
|
||||||
.replace("{{comment}}", context.commentOwner() + ": " + context.commentContent());
|
.replace("{{comment}}", context.commentOwner() + ": " + context.commentContent());
|
||||||
|
|
||||||
if (sentiment == null || "NEUTRAL".equals(sentiment)) {
|
if (sentiment == null || "NEUTRAL".equals(sentiment)) {
|
||||||
@@ -147,6 +150,18 @@ public class PromptBuilder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format conversation history for inclusion in the prompt.
|
||||||
|
* Returns empty string if no history is available.
|
||||||
|
*/
|
||||||
|
private String formatConversationHistory(ContextExtractor.CommentContext context) {
|
||||||
|
String history = context.conversationHistory();
|
||||||
|
if (history == null || history.isBlank()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "对话历史(供理解上下文):\n" + history + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
private Mono<String> getPromptTemplate() {
|
private Mono<String> getPromptTemplate() {
|
||||||
return client.fetch(ConfigMap.class, CONFIG_MAP_NAME)
|
return client.fetch(ConfigMap.class, CONFIG_MAP_NAME)
|
||||||
.mapNotNull(cm -> {
|
.mapNotNull(cm -> {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package top.nxxy335.commentaiautopilot.service;
|
package top.nxxy335.commentaiautopilot.service;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -8,15 +9,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class RateLimitService {
|
public class RateLimitService implements DisposableBean {
|
||||||
private final ConcurrentHashMap<Long, AtomicInteger> windowMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, AtomicInteger> windowMap = new ConcurrentHashMap<>();
|
||||||
|
private final Thread cleanupThread;
|
||||||
|
private volatile boolean running = true;
|
||||||
|
|
||||||
public RateLimitService() {
|
public RateLimitService() {
|
||||||
// 每5分钟清理过期窗口,防止内存泄漏
|
// 每5分钟清理过期窗口,防止内存泄漏
|
||||||
Thread cleanupThread = new Thread(() -> {
|
cleanupThread = new Thread(() -> {
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (running && !Thread.currentThread().isInterrupted()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5 * 60 * 1000);
|
Thread.sleep(5 * 60 * 1000);
|
||||||
|
if (!running) break;
|
||||||
cleanup();
|
cleanup();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
@@ -55,4 +59,13 @@ public class RateLimitService {
|
|||||||
log.debug("[RateLimit] Cleaned up {} expired windows", removed);
|
log.debug("[RateLimit] Cleaned up {} expired windows", removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
running = false;
|
||||||
|
if (cleanupThread != null) {
|
||||||
|
cleanupThread.interrupt();
|
||||||
|
}
|
||||||
|
log.info("[RateLimit] Cleanup thread stopped");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ReviewService {
|
public class ReviewService {
|
||||||
@@ -14,58 +16,135 @@ public class ReviewService {
|
|||||||
this.aiFoundationClient = aiFoundationClient;
|
this.aiFoundationClient = aiFoundationClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String REVIEW_PROMPT_TEMPLATE = """
|
/**
|
||||||
请你以内容安全审核员的身份,严格评估你刚刚生成的这段回复:
|
* Safety classification choices.
|
||||||
|
* Using OutputSpec.choice for reliable structured output.
|
||||||
|
*/
|
||||||
|
private static final String SAFE = "安全";
|
||||||
|
private static final String UNSAFE = "不安全";
|
||||||
|
private static final List<String> SAFETY_CHOICES = List.of(SAFE, UNSAFE);
|
||||||
|
|
||||||
文章:
|
/**
|
||||||
%s
|
* Quality rating choices for content quality assessment.
|
||||||
|
* Used to produce a meaningful score (1-5) instead of binary 0/100.
|
||||||
|
*/
|
||||||
|
private static final String RATING_EXCELLENT = "5";
|
||||||
|
private static final String RATING_GOOD = "4";
|
||||||
|
private static final String RATING_AVERAGE = "3";
|
||||||
|
private static final String RATING_POOR = "2";
|
||||||
|
private static final String RATING_BAD = "1";
|
||||||
|
private static final List<String> QUALITY_CHOICES = List.of(
|
||||||
|
RATING_EXCELLENT, RATING_GOOD, RATING_AVERAGE, RATING_POOR, RATING_BAD
|
||||||
|
);
|
||||||
|
|
||||||
|
private static final String SAFETY_SYSTEM_PROMPT = """
|
||||||
|
你是内容安全审核员。请严格评估AI生成的回复内容是否安全合规。
|
||||||
|
检查以下方面:
|
||||||
|
1. 是否包含辱骂、仇恨、偏见或煽动性言论
|
||||||
|
2. 是否包含不适宜公开传播的内容
|
||||||
|
3. 是否涉及暴力、歧视、人身攻击或违反法律法规的内容
|
||||||
|
只返回"安全"或"不安全"。""";
|
||||||
|
|
||||||
|
private static final String QUALITY_SYSTEM_PROMPT = """
|
||||||
|
你是AI回复质量评估员。请对AI生成的回复进行质量评分(1-5分)。
|
||||||
|
评分标准:
|
||||||
|
5分:回复切题、自然流畅、语气恰当、有帮助
|
||||||
|
4分:回复较好,基本切题,语气自然
|
||||||
|
3分:回复一般,基本切题但略显生硬或冗长
|
||||||
|
2分:回复较差,偏离主题或语气不当
|
||||||
|
1分:回复很差,完全不相关或不当
|
||||||
|
只返回数字 1-5。""";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Review AI reply content using two-stage assessment:
|
||||||
|
* 1. Safety check via OutputSpec.choice (安全/不安全)
|
||||||
|
* 2. Quality rating via OutputSpec.choice (1-5) — only if safe
|
||||||
|
*
|
||||||
|
* <p>Score mapping (0-100):
|
||||||
|
* <ul>
|
||||||
|
* <li>Unsafe → 0 (FAIL)</li>
|
||||||
|
* <li>Rating 5 → 100 (PASS)</li>
|
||||||
|
* <li>Rating 4 → 85 (PASS)</li>
|
||||||
|
* <li>Rating 3 → 70 (PASS)</li>
|
||||||
|
* <li>Rating 2 → 50 (PASS, borderline)</li>
|
||||||
|
* <li>Rating 1 → 30 (PASS, but low quality)</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
public Mono<ReviewResult> review(String articleContent, String commentContent, String aiReply,
|
||||||
|
String modelName) {
|
||||||
|
String userPrompt = String.format("""
|
||||||
原始评论:
|
原始评论:
|
||||||
%s
|
%s
|
||||||
|
|
||||||
生成的回复:
|
生成的回复:
|
||||||
%s
|
%s
|
||||||
|
|
||||||
请检查以下内容:
|
请判断以上回复是否安全合规。""",
|
||||||
1. 是否包含任何辱骂、仇恨、偏见或煽动性言论?
|
|
||||||
2. 是否包含不适宜公开传播的内容?
|
|
||||||
3. 是否涉及暴力、歧视、人身攻击或违反法律法规的内容?
|
|
||||||
|
|
||||||
请直接回答"安全"或"不安全"。如果"不安全",请重新生成一段符合规范的温和回复。
|
|
||||||
""";
|
|
||||||
|
|
||||||
public Mono<ReviewResult> review(String articleContent, String commentContent, String aiReply,
|
|
||||||
String modelName) {
|
|
||||||
String reviewPrompt = String.format(REVIEW_PROMPT_TEMPLATE,
|
|
||||||
truncate(articleContent, 2000),
|
|
||||||
truncate(commentContent, 500),
|
truncate(commentContent, 500),
|
||||||
truncate(aiReply, 500));
|
truncate(aiReply, 500));
|
||||||
|
|
||||||
return aiFoundationClient.chat(reviewPrompt, modelName)
|
// Stage 1: Safety check
|
||||||
.map(this::parseSafetyResult)
|
return aiFoundationClient.classify(SAFETY_SYSTEM_PROMPT, userPrompt, SAFETY_CHOICES, modelName)
|
||||||
|
.flatMap(safetyResult -> {
|
||||||
|
if (UNSAFE.equals(safetyResult)) {
|
||||||
|
log.warn("[Review] Content is UNSAFE");
|
||||||
|
return Mono.just(new ReviewResult(0, "FAIL", "内容安全审核不通过"));
|
||||||
|
}
|
||||||
|
if (!SAFE.equals(safetyResult)) {
|
||||||
|
log.warn("[Review] Unexpected safety result: {}, treating as unsafe", safetyResult);
|
||||||
|
return Mono.just(new ReviewResult(0, "FAIL", "内容安全审核结果异常"));
|
||||||
|
}
|
||||||
|
// Stage 2: Quality rating (only for safe content)
|
||||||
|
return rateQuality(commentContent, aiReply, modelName);
|
||||||
|
})
|
||||||
.defaultIfEmpty(new ReviewResult(100, "PASS", "审核无响应,自动通过"))
|
.defaultIfEmpty(new ReviewResult(100, "PASS", "审核无响应,自动通过"))
|
||||||
.onErrorResume(e -> {
|
.onErrorResume(e -> {
|
||||||
log.warn("Review failed, auto-passing: {}", e.getMessage());
|
log.warn("[Review] Review failed, auto-passing: {}", e.getMessage());
|
||||||
return Mono.just(new ReviewResult(100, "PASS", "审核服务异常,自动通过"));
|
return Mono.just(new ReviewResult(100, "PASS", "审核服务异常,自动通过"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReviewResult parseSafetyResult(String response) {
|
/**
|
||||||
if (response == null || response.isBlank()) {
|
* Rate the quality of a safe AI reply (1-5) and map to a 0-100 score.
|
||||||
return new ReviewResult(100, "PASS", "审核无响应,自动通过");
|
*/
|
||||||
|
private Mono<ReviewResult> rateQuality(String commentContent, String aiReply, String modelName) {
|
||||||
|
String qualityPrompt = String.format("""
|
||||||
|
评论:
|
||||||
|
%s
|
||||||
|
|
||||||
|
回复:
|
||||||
|
%s
|
||||||
|
|
||||||
|
请对以上回复进行质量评分(1-5分)。""",
|
||||||
|
truncate(commentContent, 500),
|
||||||
|
truncate(aiReply, 500));
|
||||||
|
|
||||||
|
return aiFoundationClient.classify(QUALITY_SYSTEM_PROMPT, qualityPrompt, QUALITY_CHOICES, modelName)
|
||||||
|
.map(rating -> {
|
||||||
|
int score = mapRatingToScore(rating);
|
||||||
|
String reason = "安全通过,质量评分: " + rating + "/5";
|
||||||
|
log.info("[Review] Content is SAFE, quality rating: {}/5, score: {}", rating, score);
|
||||||
|
return new ReviewResult(score, "PASS", reason);
|
||||||
|
})
|
||||||
|
.defaultIfEmpty(new ReviewResult(85, "PASS", "安全通过,质量评分默认 4/5"))
|
||||||
|
.onErrorResume(e -> {
|
||||||
|
log.warn("[Review] Quality rating failed, defaulting to 85: {}", e.getMessage());
|
||||||
|
return Mono.just(new ReviewResult(85, "PASS", "安全通过,质量评分异常"));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
String trimmed = response.trim().toLowerCase();
|
|
||||||
if (trimmed.contains("不安全") || trimmed.contains("unsafe")) {
|
/**
|
||||||
log.warn("AI Review: content is UNSAFE, response: {}", response);
|
* Map a 1-5 quality rating to a 0-100 score.
|
||||||
return new ReviewResult(0, "FAIL", "内容安全审核不通过");
|
*/
|
||||||
}
|
private int mapRatingToScore(String rating) {
|
||||||
if (trimmed.contains("安全") || trimmed.contains("safe")) {
|
return switch (rating) {
|
||||||
log.info("AI Review: content is SAFE");
|
case RATING_EXCELLENT -> 100;
|
||||||
return new ReviewResult(100, "PASS", "内容安全审核通过");
|
case RATING_GOOD -> 85;
|
||||||
}
|
case RATING_AVERAGE -> 70;
|
||||||
// If unclear response, default to pass
|
case RATING_POOR -> 50;
|
||||||
log.warn("AI Review: unclear response, auto-passing: {}", response);
|
case RATING_BAD -> 30;
|
||||||
return new ReviewResult(100, "PASS", "审核结果不明确,自动通过");
|
default -> 70; // default to average
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private String truncate(String text, int maxLength) {
|
private String truncate(String text, int maxLength) {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SentimentService {
|
public class SentimentService {
|
||||||
@@ -20,13 +22,27 @@ public class SentimentService {
|
|||||||
public static final String NEGATIVE = "NEGATIVE";
|
public static final String NEGATIVE = "NEGATIVE";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mono<SentimentResult> analyzeSentiment(String commentContent, String modelName) {
|
private static final List<String> CHOICES = List.of(
|
||||||
String prompt = buildSentimentPrompt(commentContent);
|
SentimentResult.POSITIVE, SentimentResult.NEUTRAL, SentimentResult.NEGATIVE
|
||||||
|
);
|
||||||
|
|
||||||
return aiFoundationClient.chat(prompt, modelName)
|
/**
|
||||||
.map(response -> {
|
* Analyze sentiment using AI Foundation structured output
|
||||||
String sentiment = parseSentiment(response);
|
* ({@code OutputSpec.choice}) for reliable classification.
|
||||||
return new SentimentResult(sentiment, 1.0);
|
*/
|
||||||
|
public Mono<SentimentResult> analyzeSentiment(String commentContent, String modelName) {
|
||||||
|
String systemPrompt = "你是一个情感分析助手。请分析评论的情感倾向,只返回 POSITIVE、NEUTRAL 或 NEGATIVE 之一。";
|
||||||
|
String userPrompt = "分析以下评论的情感倾向:\n\n" + commentContent;
|
||||||
|
|
||||||
|
return aiFoundationClient.classify(systemPrompt, userPrompt, CHOICES, modelName)
|
||||||
|
.map(sentiment -> {
|
||||||
|
String upper = sentiment.toUpperCase();
|
||||||
|
// Validate against known choices; default to NEUTRAL if unexpected
|
||||||
|
if (!CHOICES.contains(upper)) {
|
||||||
|
log.warn("[Sentiment] Unexpected classification result: {}, defaulting to NEUTRAL", sentiment);
|
||||||
|
return new SentimentResult(SentimentResult.NEUTRAL, 0.0);
|
||||||
|
}
|
||||||
|
return new SentimentResult(upper, 1.0);
|
||||||
})
|
})
|
||||||
.onErrorResume(e -> {
|
.onErrorResume(e -> {
|
||||||
log.warn("[Sentiment] Failed to analyze sentiment, defaulting to NEUTRAL: {}", e.getMessage());
|
log.warn("[Sentiment] Failed to analyze sentiment, defaulting to NEUTRAL: {}", e.getMessage());
|
||||||
@@ -34,16 +50,4 @@ public class SentimentService {
|
|||||||
})
|
})
|
||||||
.defaultIfEmpty(new SentimentResult(SentimentResult.NEUTRAL, 0.0));
|
.defaultIfEmpty(new SentimentResult(SentimentResult.NEUTRAL, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildSentimentPrompt(String commentContent) {
|
|
||||||
return "请分析以下评论的情感倾向。只回复一个词:POSITIVE(正面)、NEUTRAL(中性)或 NEGATIVE(负面)。\n\n评论内容:\n" + commentContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String parseSentiment(String response) {
|
|
||||||
if (response == null || response.isBlank()) return SentimentResult.NEUTRAL;
|
|
||||||
String upper = response.trim().toUpperCase();
|
|
||||||
if (upper.contains("POSITIVE")) return SentimentResult.POSITIVE;
|
|
||||||
if (upper.contains("NEGATIVE")) return SentimentResult.NEGATIVE;
|
|
||||||
return SentimentResult.NEUTRAL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ spec:
|
|||||||
- $formkit: textarea
|
- $formkit: textarea
|
||||||
name: customPromptTemplate
|
name: customPromptTemplate
|
||||||
label: 自定义Prompt模板
|
label: 自定义Prompt模板
|
||||||
value: "{{persona_prompt}}\n\n{{safety_prompt}}\n\n【语言要求】请用评论所使用的语言回复。如果评论是英文,请用英文回复;如果是中文,请用中文回复;如果是日文,请用日文回复;以此类推。\n\n请回复以下评论。注意:\n- 回复长度应与评论长度匹配,简短问候简短回复\n- 不要复述或总结文章内容\n- 自然对话,不要写小作文\n- 只有评论涉及具体内容时才针对性回应\n\n文章(仅供理解上下文,不要复述):\n{{article}}\n\n评论:\n{{comment}}"
|
value: "{{persona_prompt}}\n\n{{safety_prompt}}\n\n【语言要求】请用评论所使用的语言回复。如果评论是英文,请用英文回复;如果是中文,请用中文回复;如果是日文,请用日文回复;以此类推。\n\n请回复以下评论。注意:\n- 回复长度应与评论长度匹配,简短问候简短回复\n- 不要复述或总结文章内容\n- 自然对话,不要写小作文\n- 只有评论涉及具体内容时才针对性回应\n\n文章(仅供理解上下文,不要复述):\n{{article}}\n\n{{conversation_history}}\n评论:\n{{comment}}"
|
||||||
- $formkit: select
|
- $formkit: select
|
||||||
name: enabledPresets
|
name: enabledPresets
|
||||||
label: 启用预设
|
label: 启用预设
|
||||||
|
|||||||
@@ -5,9 +5,17 @@ kind: Plugin
|
|||||||
metadata:
|
metadata:
|
||||||
# The name defines how the plugin is invoked, A unique name
|
# The name defines how the plugin is invoked, A unique name
|
||||||
name: comment-ai-autopilot
|
name: comment-ai-autopilot
|
||||||
|
annotations:
|
||||||
|
# Recommend installing AI Foundation from the app store after installing this plugin
|
||||||
|
# https://www.halo.run/store/apps/app-acslk9nu
|
||||||
|
"store.halo.run/recommended-apps": '["app-acslk9nu"]'
|
||||||
spec:
|
spec:
|
||||||
enabled: true
|
enabled: true
|
||||||
requires: ">=2.25.0"
|
requires: ">=2.25.0"
|
||||||
|
pluginDependencies:
|
||||||
|
# Optional dependency: plugin still loads without AI Foundation,
|
||||||
|
# but AI features require it to be installed and enabled.
|
||||||
|
ai-foundation?: "*"
|
||||||
author:
|
author:
|
||||||
name: 暖心向阳335
|
name: 暖心向阳335
|
||||||
website: https://nxxy335.top
|
website: https://nxxy335.top
|
||||||
@@ -22,4 +30,4 @@ spec:
|
|||||||
url: "https://github.com/sunny-335/plugin-comment-ai-autopilot/blob/main/LICENSE"
|
url: "https://github.com/sunny-335/plugin-comment-ai-autopilot/blob/main/LICENSE"
|
||||||
settingName: "comment-ai-autopilot-settings"
|
settingName: "comment-ai-autopilot-settings"
|
||||||
configMapName: "comment-ai-autopilot-configmap"
|
configMapName: "comment-ai-autopilot-configmap"
|
||||||
version: "1.0.0-beta.1"
|
version: "1.0.0-beta.2"
|
||||||
|
|||||||
+4
-202
@@ -108,152 +108,11 @@
|
|||||||
</VCard>
|
</VCard>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Middle: Sentiment + Trend -->
|
|
||||||
<div class="grid grid-cols-1 gap-4 mt-4 lg:grid-cols-2">
|
|
||||||
<!-- Sentiment Distribution -->
|
|
||||||
<VCard :body-class="['!p-5']">
|
|
||||||
<h3 class="text-sm font-medium text-gray-500 mb-4">情感分布</h3>
|
|
||||||
<div class="space-y-3">
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<div class="w-2 h-2 rounded-full bg-green-500 shrink-0"></div>
|
|
||||||
<div class="flex-1 min-w-0">
|
|
||||||
<div class="flex items-center justify-between text-sm">
|
|
||||||
<span class="text-gray-700">正面</span>
|
|
||||||
<span class="font-medium text-green-600">{{ stats?.sentimentDistribution?.POSITIVE || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-1 h-1.5 bg-gray-100 rounded-full overflow-hidden">
|
|
||||||
<div
|
|
||||||
class="h-full bg-green-400 rounded-full transition-all duration-500"
|
|
||||||
:style="{ width: getSentimentPercent('POSITIVE') + '%' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<div class="w-2 h-2 rounded-full bg-gray-400 shrink-0"></div>
|
|
||||||
<div class="flex-1 min-w-0">
|
|
||||||
<div class="flex items-center justify-between text-sm">
|
|
||||||
<span class="text-gray-700">中性</span>
|
|
||||||
<span class="font-medium text-gray-600">{{ stats?.sentimentDistribution?.NEUTRAL || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-1 h-1.5 bg-gray-100 rounded-full overflow-hidden">
|
|
||||||
<div
|
|
||||||
class="h-full bg-gray-400 rounded-full transition-all duration-500"
|
|
||||||
:style="{ width: getSentimentPercent('NEUTRAL') + '%' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<div class="w-2 h-2 rounded-full bg-red-500 shrink-0"></div>
|
|
||||||
<div class="flex-1 min-w-0">
|
|
||||||
<div class="flex items-center justify-between text-sm">
|
|
||||||
<span class="text-gray-700">负面</span>
|
|
||||||
<span class="font-medium text-red-500">{{ stats?.sentimentDistribution?.NEGATIVE || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-1 h-1.5 bg-gray-100 rounded-full overflow-hidden">
|
|
||||||
<div
|
|
||||||
class="h-full bg-red-400 rounded-full transition-all duration-500"
|
|
||||||
:style="{ width: getSentimentPercent('NEGATIVE') + '%' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<div class="w-2 h-2 rounded-full bg-gray-300 shrink-0"></div>
|
|
||||||
<div class="flex-1 min-w-0">
|
|
||||||
<div class="flex items-center justify-between text-sm">
|
|
||||||
<span class="text-gray-700">未知</span>
|
|
||||||
<span class="font-medium text-gray-400">{{ stats?.sentimentDistribution?.UNKNOWN || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="mt-1 h-1.5 bg-gray-100 rounded-full overflow-hidden">
|
|
||||||
<div
|
|
||||||
class="h-full bg-gray-300 rounded-full transition-all duration-500"
|
|
||||||
:style="{ width: getSentimentPercent('UNKNOWN') + '%' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</VCard>
|
|
||||||
|
|
||||||
<!-- Daily Trend -->
|
|
||||||
<VCard :body-class="['!p-5']">
|
|
||||||
<div class="flex items-center justify-between mb-4">
|
|
||||||
<h3 class="text-sm font-medium text-gray-500">近7日回复趋势</h3>
|
|
||||||
<div class="inline-flex rounded-md border border-gray-200 overflow-hidden">
|
|
||||||
<button
|
|
||||||
class="px-2.5 py-1 text-xs transition-colors"
|
|
||||||
:class="range === '7' ? 'bg-blue-500 text-white' : 'bg-white text-gray-600 hover:bg-gray-50'"
|
|
||||||
@click="range = '7'"
|
|
||||||
>
|
|
||||||
7天
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="px-2.5 py-1 text-xs border-l border-gray-200 transition-colors"
|
|
||||||
:class="range === '30' ? 'bg-blue-500 text-white' : 'bg-white text-gray-600 hover:bg-gray-50'"
|
|
||||||
@click="range = '30'"
|
|
||||||
>
|
|
||||||
30天
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="px-2.5 py-1 text-xs border-l border-gray-200 transition-colors"
|
|
||||||
:class="range === 'all' ? 'bg-blue-500 text-white' : 'bg-white text-gray-600 hover:bg-gray-50'"
|
|
||||||
@click="range = 'all'"
|
|
||||||
>
|
|
||||||
全部
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="stats?.dailyTrend?.length" class="flex items-end gap-3" style="height: 160px">
|
|
||||||
<div
|
|
||||||
v-for="day in stats.dailyTrend"
|
|
||||||
:key="day.date"
|
|
||||||
class="flex-1 flex flex-col items-center justify-end h-full"
|
|
||||||
>
|
|
||||||
<div class="text-xs text-gray-500 mb-1 font-medium">{{ day.count }}</div>
|
|
||||||
<div
|
|
||||||
class="w-full rounded-t-md transition-all duration-500"
|
|
||||||
:class="day.count > 0 ? 'bg-gradient-to-t from-blue-500 to-blue-400' : 'bg-gray-100'"
|
|
||||||
:style="{ height: getTrendBarHeight(day.count) + 'px' }"
|
|
||||||
></div>
|
|
||||||
<div class="text-[10px] text-gray-400 mt-2 whitespace-nowrap">{{ formatTrendDate(day.date) }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else class="flex items-center justify-center text-sm text-gray-400" style="height: 160px">
|
|
||||||
暂无数据
|
|
||||||
</div>
|
|
||||||
</VCard>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Bottom: Score + Quick Actions -->
|
|
||||||
<div class="grid grid-cols-1 gap-4 mt-4 sm:grid-cols-2">
|
|
||||||
<!-- Avg Score -->
|
|
||||||
<VCard :body-class="['!p-5']">
|
|
||||||
<h3 class="text-sm font-medium text-gray-500 mb-3">平均审核评分</h3>
|
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<div class="text-4xl font-bold" :class="scoreColor">{{ stats?.avgScore?.toFixed(1) || '0.0' }}</div>
|
|
||||||
<div class="flex-1">
|
|
||||||
<div class="h-3 bg-gray-100 rounded-full overflow-hidden">
|
|
||||||
<div
|
|
||||||
class="h-full rounded-full transition-all duration-500"
|
|
||||||
:class="scoreBarColor"
|
|
||||||
:style="{ width: (stats?.avgScore || 0) * 10 + '%' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
<div class="flex justify-between text-[10px] text-gray-300 mt-1">
|
|
||||||
<span>0</span>
|
|
||||||
<span>5</span>
|
|
||||||
<span>10</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</VCard>
|
|
||||||
|
|
||||||
<!-- Quick Actions -->
|
<!-- Quick Actions -->
|
||||||
|
<div class="mt-4">
|
||||||
<VCard :body-class="['!p-5']">
|
<VCard :body-class="['!p-5']">
|
||||||
<h3 class="text-sm font-medium text-gray-500 mb-3">快捷操作</h3>
|
<h3 class="text-sm font-medium text-gray-500 mb-3">快捷操作</h3>
|
||||||
<div class="grid grid-cols-2 gap-2">
|
<div class="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
||||||
<button
|
<button
|
||||||
class="flex items-center gap-2 px-3 py-2.5 rounded-md bg-gray-50 hover:bg-gray-100 transition-colors text-sm text-gray-700"
|
class="flex items-center gap-2 px-3 py-2.5 rounded-md bg-gray-50 hover:bg-gray-100 transition-colors text-sm text-gray-700"
|
||||||
@click="$router.push({ name: 'CommentAiAutopilotLogs' })"
|
@click="$router.push({ name: 'CommentAiAutopilotLogs' })"
|
||||||
@@ -273,15 +132,6 @@
|
|||||||
</svg>
|
</svg>
|
||||||
插件设置
|
插件设置
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
class="flex items-center gap-2 px-3 py-2.5 rounded-md bg-gray-50 hover:bg-gray-100 transition-colors text-sm text-gray-700"
|
|
||||||
@click="$router.push({ name: 'CommentAiAutopilotSettings' })"
|
|
||||||
>
|
|
||||||
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
||||||
</svg>
|
|
||||||
AI角色
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="flex items-center gap-2 px-3 py-2.5 rounded-md bg-gray-50 hover:bg-gray-100 transition-colors text-sm text-gray-700"
|
class="flex items-center gap-2 px-3 py-2.5 rounded-md bg-gray-50 hover:bg-gray-100 transition-colors text-sm text-gray-700"
|
||||||
@click="refreshData"
|
@click="refreshData"
|
||||||
@@ -299,24 +149,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, watch } from "vue"
|
import { ref, computed, onMounted } from "vue"
|
||||||
import { axiosInstance } from "@halo-dev/api-client"
|
import { axiosInstance } from "@halo-dev/api-client"
|
||||||
import { VPageHeader, VButton, VCard, Toast } from "@halo-dev/components"
|
import { VPageHeader, VButton, VCard, Toast } from "@halo-dev/components"
|
||||||
import { IconPlug } from "@halo-dev/components"
|
import { IconPlug } from "@halo-dev/components"
|
||||||
|
|
||||||
interface DailyCount {
|
|
||||||
date: string
|
|
||||||
count: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface StatsResponse {
|
interface StatsResponse {
|
||||||
total: number
|
total: number
|
||||||
passCount: number
|
passCount: number
|
||||||
failCount: number
|
failCount: number
|
||||||
reviewingCount: number
|
reviewingCount: number
|
||||||
avgScore: number
|
|
||||||
sentimentDistribution: Record<string, number>
|
|
||||||
dailyTrend: DailyCount[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PersonaResponse {
|
interface PersonaResponse {
|
||||||
@@ -331,7 +173,6 @@ interface HealthResponse {
|
|||||||
|
|
||||||
const stats = ref<StatsResponse | null>(null)
|
const stats = ref<StatsResponse | null>(null)
|
||||||
const persona = ref<PersonaResponse | null>(null)
|
const persona = ref<PersonaResponse | null>(null)
|
||||||
const range = ref("7")
|
|
||||||
const health = ref<HealthResponse | null>(null)
|
const health = ref<HealthResponse | null>(null)
|
||||||
const healthVisible = ref(true)
|
const healthVisible = ref(true)
|
||||||
|
|
||||||
@@ -340,24 +181,10 @@ const passRate = computed(() => {
|
|||||||
return Math.round((stats.value.passCount / stats.value.total) * 100)
|
return Math.round((stats.value.passCount / stats.value.total) * 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
const scoreColor = computed(() => {
|
|
||||||
const score = stats.value?.avgScore || 0
|
|
||||||
if (score >= 7) return "text-green-600"
|
|
||||||
if (score >= 4) return "text-amber-500"
|
|
||||||
return "text-red-500"
|
|
||||||
})
|
|
||||||
|
|
||||||
const scoreBarColor = computed(() => {
|
|
||||||
const score = stats.value?.avgScore || 0
|
|
||||||
if (score >= 7) return "bg-gradient-to-r from-green-400 to-green-500"
|
|
||||||
if (score >= 4) return "bg-gradient-to-r from-amber-400 to-amber-500"
|
|
||||||
return "bg-gradient-to-r from-red-400 to-red-500"
|
|
||||||
})
|
|
||||||
|
|
||||||
const fetchStats = async () => {
|
const fetchStats = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axiosInstance.get(
|
const { data } = await axiosInstance.get(
|
||||||
`/apis/console.api.comment-ai-autopilot.nxxy335.top/v1alpha1/stats?range=${range.value}`,
|
`/apis/console.api.comment-ai-autopilot.nxxy335.top/v1alpha1/stats?range=7`,
|
||||||
)
|
)
|
||||||
stats.value = data
|
stats.value = data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -421,31 +248,6 @@ const openSettings = () => {
|
|||||||
window.location.href = "/console/comment-ai-autopilot/settings"
|
window.location.href = "/console/comment-ai-autopilot/settings"
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSentimentPercent = (sentiment: string): number => {
|
|
||||||
const dist = stats.value?.sentimentDistribution
|
|
||||||
if (!dist) return 0
|
|
||||||
const total = Object.values(dist).reduce((a, b) => a + b, 0)
|
|
||||||
if (total === 0) return 0
|
|
||||||
return Math.round(((dist[sentiment] || 0) / total) * 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
const getTrendBarHeight = (count: number): number => {
|
|
||||||
const trend = stats.value?.dailyTrend
|
|
||||||
if (!trend || trend.length === 0) return 0
|
|
||||||
const max = Math.max(...trend.map(d => d.count), 1)
|
|
||||||
return Math.max((count / max) * 100, count > 0 ? 8 : 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatTrendDate = (dateStr: string): string => {
|
|
||||||
if (!dateStr) return ''
|
|
||||||
const parts = dateStr.split('-')
|
|
||||||
return parts.length >= 3 ? `${parts[1]}/${parts[2]}` : dateStr
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(range, () => {
|
|
||||||
fetchStats()
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchStats()
|
fetchStats()
|
||||||
fetchPersona()
|
fetchPersona()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</VPageHeader>
|
</VPageHeader>
|
||||||
|
|
||||||
<!-- Batch Operation Toolbar -->
|
<!-- Batch Operation Toolbar -->
|
||||||
<div v-if="selectedNames.size > 0" class="mx-4 mt-2 flex items-center gap-3 bg-blue-50 border border-blue-200 rounded-lg px-4 py-2.5">
|
<div v-if="selectedNames.size > 0" class="m-4 mb-0 flex items-center gap-3 bg-blue-50 border border-blue-200 rounded-lg px-4 py-2.5">
|
||||||
<span class="text-sm text-blue-700">已选择 {{ selectedNames.size }} 项</span>
|
<span class="text-sm text-blue-700">已选择 {{ selectedNames.size }} 项</span>
|
||||||
<button
|
<button
|
||||||
class="text-xs px-3 py-1 rounded bg-green-600 text-white hover:bg-green-700 transition-colors"
|
class="text-xs px-3 py-1 rounded bg-green-600 text-white hover:bg-green-700 transition-colors"
|
||||||
@@ -39,10 +39,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Filter Bar -->
|
<!-- Filter Bar -->
|
||||||
<div class="mx-4 mt-2 flex items-center gap-3">
|
<div class="m-4 mb-0 flex items-center gap-3">
|
||||||
<select
|
<select
|
||||||
v-model="filterStatus"
|
v-model="filterStatus"
|
||||||
class="rounded-md border border-gray-300 px-3 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
class="rounded-md border border-gray-300 pl-3 pr-8 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||||
>
|
>
|
||||||
<option value="">全部状态</option>
|
<option value="">全部状态</option>
|
||||||
<option value="PASS">通过</option>
|
<option value="PASS">通过</option>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
v-model="filterSentiment"
|
v-model="filterSentiment"
|
||||||
class="rounded-md border border-gray-300 px-3 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
class="rounded-md border border-gray-300 pl-3 pr-8 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||||
>
|
>
|
||||||
<option value="">全部情感</option>
|
<option value="">全部情感</option>
|
||||||
<option value="POSITIVE">正面</option>
|
<option value="POSITIVE">正面</option>
|
||||||
@@ -152,7 +152,8 @@
|
|||||||
<div class="px-4 py-2.5 bg-gray-50 border-t border-gray-100 flex items-center justify-between">
|
<div class="px-4 py-2.5 bg-gray-50 border-t border-gray-100 flex items-center justify-between">
|
||||||
<div class="flex items-center gap-4 text-xs text-gray-400">
|
<div class="flex items-center gap-4 text-xs text-gray-400">
|
||||||
<span>
|
<span>
|
||||||
评分 <span :class="getScoreClass(reply.spec.score)" class="font-medium text-gray-600">{{ reply.spec.score }}</span>
|
评分 <span :class="getScoreClass(reply.spec.score)" class="font-medium">{{ reply.spec.score }}</span>
|
||||||
|
<span class="text-gray-300 ml-0.5">{{ getScoreLabel(reply.spec.score) }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="reply.spec.postSlug" class="flex items-center gap-1">
|
<span v-if="reply.spec.postSlug" class="flex items-center gap-1">
|
||||||
文章
|
文章
|
||||||
@@ -508,6 +509,14 @@ const getScoreClass = (score: number) => {
|
|||||||
return "text-red-600"
|
return "text-red-600"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getScoreLabel = (score: number) => {
|
||||||
|
if (score >= 85) return "优秀"
|
||||||
|
if (score >= 70) return "良好"
|
||||||
|
if (score >= 50) return "一般"
|
||||||
|
if (score > 0) return "较差"
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
const getStatusClass = (status: string) => {
|
const getStatusClass = (status: string) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "PASS":
|
case "PASS":
|
||||||
|
|||||||
+131
-16
@@ -5,23 +5,46 @@
|
|||||||
<IconPlug class="mr-2 self-center" />
|
<IconPlug class="mr-2 self-center" />
|
||||||
</template>
|
</template>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<VButton type="secondary" size="sm" @click="exportConfig">导出配置</VButton>
|
<VSpace spacing="sm">
|
||||||
|
<VButton size="sm" @click="exportConfig">
|
||||||
|
<template #icon>
|
||||||
|
<svg style="width:14px;height:14px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/></svg>
|
||||||
|
</template>
|
||||||
|
导出
|
||||||
|
</VButton>
|
||||||
<label class="inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
<label class="inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 cursor-pointer transition-colors">
|
||||||
导入配置
|
<svg style="width:14px;height:14px;margin-right:4px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"/></svg>
|
||||||
|
导入
|
||||||
<input type="file" accept=".json" class="hidden" @change="handleImportFile" />
|
<input type="file" accept=".json" class="hidden" @change="handleImportFile" />
|
||||||
</label>
|
</label>
|
||||||
<VButton @click="$router.push({ name: 'CommentAiAutopilot' })">返回概览</VButton>
|
<VButton size="sm" @click="$router.push({ name: 'CommentAiAutopilot' })">返回概览</VButton>
|
||||||
|
</VSpace>
|
||||||
</template>
|
</template>
|
||||||
</VPageHeader>
|
</VPageHeader>
|
||||||
|
|
||||||
<div class="m-4">
|
<div class="m-4">
|
||||||
<VLoading v-if="loading" />
|
<VLoading v-if="loading" />
|
||||||
|
|
||||||
<div v-if="!loading" class="settings-container">
|
<div v-if="!loading">
|
||||||
|
<!-- Tab Navigation (full width, above the grid) -->
|
||||||
|
<div class="settings-tabs">
|
||||||
|
<button
|
||||||
|
v-for="tab in tabItems"
|
||||||
|
:key="tab.value"
|
||||||
|
class="settings-tab"
|
||||||
|
:class="{ 'settings-tab--active': activeTab === tab.value }"
|
||||||
|
@click="activeTab = tab.value"
|
||||||
|
>
|
||||||
|
{{ tab.label }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Settings Grid: sections (left) + sidebar (right) -->
|
||||||
|
<div class="settings-container">
|
||||||
<!-- Left: Settings Sections -->
|
<!-- Left: Settings Sections -->
|
||||||
<div class="settings-sections space-y-5">
|
<div class="settings-sections space-y-5">
|
||||||
<!-- ========== 基本设置 ========== -->
|
<!-- ========== 基本设置 ========== -->
|
||||||
<section class="settings-section">
|
<section v-if="activeTab === 'basic'" class="settings-section">
|
||||||
<div class="section-header section-header--blue">
|
<div class="section-header section-header--blue">
|
||||||
<div class="section-header__icon">
|
<div class="section-header__icon">
|
||||||
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
|
||||||
@@ -104,7 +127,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ========== AI角色设置 ========== -->
|
<!-- ========== AI角色设置 ========== -->
|
||||||
<section class="settings-section">
|
<section v-if="activeTab === 'persona'" class="settings-section">
|
||||||
<div class="section-header section-header--purple">
|
<div class="section-header section-header--purple">
|
||||||
<div class="section-header__icon">
|
<div class="section-header__icon">
|
||||||
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
|
||||||
@@ -148,14 +171,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<VButton type="secondary" @click="openPersonaDialog(null)">
|
<VButton type="secondary" @click="openPersonaDialog(null)">
|
||||||
<svg style="width:16px;height:16px;margin-right:4px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
<svg style="width:16px;height:16px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
|
||||||
添加角色
|
添加角色
|
||||||
</VButton>
|
</VButton>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ========== 模型设置 ========== -->
|
<!-- ========== 模型设置 ========== -->
|
||||||
<section class="settings-section">
|
<section v-if="activeTab === 'model'" class="settings-section">
|
||||||
<div class="section-header section-header--green">
|
<div class="section-header section-header--green">
|
||||||
<div class="section-header__icon">
|
<div class="section-header__icon">
|
||||||
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
|
||||||
@@ -175,7 +198,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ========== Prompt设置 ========== -->
|
<!-- ========== Prompt设置 ========== -->
|
||||||
<section class="settings-section">
|
<section v-if="activeTab === 'prompt'" class="settings-section">
|
||||||
<div class="section-header section-header--amber">
|
<div class="section-header section-header--amber">
|
||||||
<div class="section-header__icon">
|
<div class="section-header__icon">
|
||||||
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
|
||||||
@@ -216,7 +239,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ========== 数据清理 ========== -->
|
<!-- ========== 数据清理 ========== -->
|
||||||
<section class="settings-section">
|
<section v-if="activeTab === 'cleanup'" class="settings-section">
|
||||||
<div class="section-header section-header--red">
|
<div class="section-header section-header--red">
|
||||||
<div class="section-header__icon">
|
<div class="section-header__icon">
|
||||||
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
|
||||||
@@ -275,16 +298,25 @@
|
|||||||
<!-- Right: Sticky Save Bar -->
|
<!-- Right: Sticky Save Bar -->
|
||||||
<div class="settings-sidebar">
|
<div class="settings-sidebar">
|
||||||
<div class="settings-sidebar__inner">
|
<div class="settings-sidebar__inner">
|
||||||
<div class="sidebar-card">
|
<div class="sidebar-card sidebar-card--primary">
|
||||||
|
<div class="sidebar-card__header">
|
||||||
<h4 class="sidebar-card__title">操作</h4>
|
<h4 class="sidebar-card__title">操作</h4>
|
||||||
|
<span v-if="hasUnsavedChanges" class="sidebar-card__badge">未保存</span>
|
||||||
|
</div>
|
||||||
<div class="sidebar-card__actions">
|
<div class="sidebar-card__actions">
|
||||||
<VButton block type="primary" @click="saveSettings" :disabled="saving">
|
<VButton block type="primary" @click="saveSettings" :disabled="saving">
|
||||||
|
<template v-if="!saving">
|
||||||
|
<svg style="width:14px;height:14px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
|
||||||
|
</template>
|
||||||
{{ saving ? '保存中...' : '保存设置' }}
|
{{ saving ? '保存中...' : '保存设置' }}
|
||||||
</VButton>
|
</VButton>
|
||||||
<VButton block @click="fetchSettings">重置为当前值</VButton>
|
<VButton block @click="fetchSettings" :disabled="saving">
|
||||||
|
<svg style="width:14px;height:14px" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
|
||||||
|
重置为当前值
|
||||||
|
</VButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-card">
|
<div v-if="activeTab === 'prompt'" class="sidebar-card">
|
||||||
<h4 class="sidebar-card__title">可用模板变量</h4>
|
<h4 class="sidebar-card__title">可用模板变量</h4>
|
||||||
<div class="sidebar-card__vars">
|
<div class="sidebar-card__vars">
|
||||||
<div v-for="v in promptVariables" :key="v.name" class="sidebar-var">
|
<div v-for="v in promptVariables" :key="v.name" class="sidebar-var">
|
||||||
@@ -297,6 +329,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Commenter Selection Dialog -->
|
<!-- Commenter Selection Dialog -->
|
||||||
<div v-if="showCommenterDialog" class="dialog-overlay" @click.self="showCommenterDialog = false">
|
<div v-if="showCommenterDialog" class="dialog-overlay" @click.self="showCommenterDialog = false">
|
||||||
@@ -414,8 +447,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, computed, onMounted, watch } from "vue"
|
import { ref, reactive, computed, onMounted, watch } from "vue"
|
||||||
import { axiosInstance, coreApiClient } from "@halo-dev/api-client"
|
import { axiosInstance, coreApiClient } from "@halo-dev/api-client"
|
||||||
import { VPageHeader, VButton, VLoading, Toast, VModal, VSpace } from "@halo-dev/components"
|
import { VPageHeader, VButton, VLoading, Toast, VModal, VSpace, IconPlug } from "@halo-dev/components"
|
||||||
import { IconPlug } from "@halo-dev/components"
|
|
||||||
|
const activeTab = ref("basic")
|
||||||
|
const tabItems = [
|
||||||
|
{ label: "基本设置", value: "basic" },
|
||||||
|
{ label: "AI角色", value: "persona" },
|
||||||
|
{ label: "模型设置", value: "model" },
|
||||||
|
{ label: "Prompt", value: "prompt" },
|
||||||
|
{ label: "数据清理", value: "cleanup" },
|
||||||
|
]
|
||||||
|
|
||||||
const promptVariables = [
|
const promptVariables = [
|
||||||
{ name: '{{persona_prompt}}', desc: '人格提示词' },
|
{ name: '{{persona_prompt}}', desc: '人格提示词' },
|
||||||
@@ -489,6 +530,12 @@ const settings = reactive({
|
|||||||
cleanup: { cleanupEnabled: true, retentionDays: 30 },
|
cleanup: { cleanupEnabled: true, retentionDays: 30 },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Track unsaved changes: snapshot of settings after last fetch/save
|
||||||
|
const lastSavedSnapshot = ref("")
|
||||||
|
const hasUnsavedChanges = computed(() => {
|
||||||
|
return JSON.stringify(settings) !== lastSavedSnapshot.value
|
||||||
|
})
|
||||||
|
|
||||||
const configMapName = "comment-ai-autopilot-configmap"
|
const configMapName = "comment-ai-autopilot-configmap"
|
||||||
const apiBase = "/apis/console.api.comment-ai-autopilot.nxxy335.top/v1alpha1"
|
const apiBase = "/apis/console.api.comment-ai-autopilot.nxxy335.top/v1alpha1"
|
||||||
|
|
||||||
@@ -817,7 +864,11 @@ const fetchSettings = async () => {
|
|||||||
if (Object.keys(cleanup).length) { settings.cleanup.cleanupEnabled = cleanup.cleanupEnabled !== false; settings.cleanup.retentionDays = (cleanup.retentionDays as number) || 30 }
|
if (Object.keys(cleanup).length) { settings.cleanup.cleanupEnabled = cleanup.cleanupEnabled !== false; settings.cleanup.retentionDays = (cleanup.retentionDays as number) || 30 }
|
||||||
}
|
}
|
||||||
} catch (e) { console.error("Failed to fetch settings", e) }
|
} catch (e) { console.error("Failed to fetch settings", e) }
|
||||||
finally { loading.value = false }
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
// Update snapshot after fetch to reset unsaved indicator
|
||||||
|
lastSavedSnapshot.value = JSON.stringify(settings)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveSettings = async () => {
|
const saveSettings = async () => {
|
||||||
@@ -834,6 +885,8 @@ const saveSettings = async () => {
|
|||||||
}
|
}
|
||||||
await coreApiClient.configMap.updateConfigMap({ name: configMapName, configMap: updated })
|
await coreApiClient.configMap.updateConfigMap({ name: configMapName, configMap: updated })
|
||||||
Toast.success("设置已保存")
|
Toast.success("设置已保存")
|
||||||
|
// Update snapshot after save to reset unsaved indicator
|
||||||
|
lastSavedSnapshot.value = JSON.stringify(settings)
|
||||||
} catch (e) { console.error("Failed to save settings", e); Toast.error("保存设置失败") }
|
} catch (e) { console.error("Failed to save settings", e); Toast.error("保存设置失败") }
|
||||||
finally { saving.value = false }
|
finally { saving.value = false }
|
||||||
}
|
}
|
||||||
@@ -847,6 +900,43 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* ===== Layout ===== */
|
/* ===== Layout ===== */
|
||||||
|
.settings-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 4px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
.settings-tab {
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #6b7280;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.settings-tab:hover {
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
.settings-tab--active {
|
||||||
|
background: #3b82f6;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.settings-tab--active:hover {
|
||||||
|
background: #2563eb;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.settings-container {
|
.settings-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 280px;
|
grid-template-columns: 1fr 280px;
|
||||||
@@ -1221,14 +1311,39 @@ onMounted(async () => {
|
|||||||
background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
|
background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
.sidebar-card--primary {
|
||||||
|
border-color: #dbeafe;
|
||||||
|
background: linear-gradient(135deg, #eff6ff 0%, #fff 100%);
|
||||||
|
}
|
||||||
|
.sidebar-card__header {
|
||||||
|
display: flex; align-items: center; justify-content: space-between;
|
||||||
|
margin-bottom: 14px; padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #f3f4f6;
|
||||||
|
}
|
||||||
|
.sidebar-card__badge {
|
||||||
|
display: inline-flex; align-items: center;
|
||||||
|
padding: 2px 8px; font-size: 11px; font-weight: 500;
|
||||||
|
background: #fef3c7; color: #d97706; border-radius: 4px;
|
||||||
|
}
|
||||||
.sidebar-card__title {
|
.sidebar-card__title {
|
||||||
font-size: 14px; font-weight: 600; color: #1f2937;
|
font-size: 14px; font-weight: 600; color: #1f2937;
|
||||||
margin: 0 0 14px; padding-bottom: 10px;
|
margin: 0 0 14px; padding-bottom: 10px;
|
||||||
border-bottom: 1px solid #f3f4f6;
|
border-bottom: 1px solid #f3f4f6;
|
||||||
}
|
}
|
||||||
|
.sidebar-card--primary .sidebar-card__title {
|
||||||
|
margin-bottom: 0; padding-bottom: 0; border-bottom: none;
|
||||||
|
}
|
||||||
.sidebar-card__actions {
|
.sidebar-card__actions {
|
||||||
display: flex; flex-direction: column; gap: 8px;
|
display: flex; flex-direction: column; gap: 8px;
|
||||||
}
|
}
|
||||||
|
/* Align icon + text inside VButton (btn-content wraps the default slot) */
|
||||||
|
.sidebar-card__actions :deep(.btn-content),
|
||||||
|
.section-body :deep(.btn-content) {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
.sidebar-card__vars {
|
.sidebar-card__vars {
|
||||||
display: flex; flex-direction: column; gap: 8px;
|
display: flex; flex-direction: column; gap: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user