实现每机器人独立 LLM 消息队列

主要变更:
- 后端:为 botNodeRecord 添加 llm_queue_enabled 和 llm_include_channel_messages 字段
- 后端:移除全局 LLM 队列开关,完全基于每个机器人的设置
- 后端:重写 enqueueChannelMessageToLLM,为每个启用了「包含频道消息」的机器人创建独立队列记录
- 后端:频道消息不再使用 bot_id=0,每条消息都有明确的机器人归属
- 前端:AdminLLM.vue 完全重写,添加机器人 LLM 设置面板
- 前端:消息列表表格新增「机器人」列,显示机器人名称和节点 ID
- 前端:消息类型判断逻辑改为使用 channel_id 区分频道/私聊
- 前后端类型同步更新
This commit is contained in:
2026-06-17 20:51:22 +08:00
parent e2bf6aa173
commit b0a9f52096
6 changed files with 253 additions and 112 deletions
+12
View File
@@ -266,6 +266,8 @@ type botNodeRecord struct {
NodeInfoBroadcastIntervalSeconds int64 `gorm:"column:nodeinfo_broadcast_interval_seconds;not null"`
LastNodeInfoBroadcastAt *time.Time `gorm:"column:last_nodeinfo_broadcast_at;index"`
LastPacketID int64 `gorm:"column:last_packet_id;not null"`
LLMQueueEnabled bool `gorm:"column:llm_queue_enabled;not null;default:1;index"`
LLMIncludeChannelMessages bool `gorm:"column:llm_include_channel_messages;not null;default:0;index"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;index"`
}
@@ -667,6 +669,16 @@ func migrateBotNodePSK(tx *gorm.DB, migrator gorm.Migrator, driver string) error
return fmt.Errorf("migrate bot_nodes last_nodeinfo_broadcast_at column: %w", err)
}
}
if !migrator.HasColumn(&botNodeRecord{}, "LLMQueueEnabled") {
if err := tx.Exec("ALTER TABLE bot_nodes ADD COLUMN llm_queue_enabled numeric NOT NULL DEFAULT 1").Error; err != nil {
return fmt.Errorf("migrate bot_nodes llm_queue_enabled column: %w", err)
}
}
if !migrator.HasColumn(&botNodeRecord{}, "LLMIncludeChannelMessages") {
if err := tx.Exec("ALTER TABLE bot_nodes ADD COLUMN llm_include_channel_messages numeric NOT NULL DEFAULT 0").Error; err != nil {
return fmt.Errorf("migrate bot_nodes llm_include_channel_messages column: %w", err)
}
}
return nil
}