RuleGo-Editor RuleGo-Editor
🏠首页
🧭使用
  • 简介
  • 安装
  • 配置
  • 组件
  • 架构设计
  • 国际化
  • 事件系统
  • 调试功能
  • AI功能
  • 自定义节点
  • 分组节点
  • RuleGo-Editor (opens new window)
  • RuleGo-Server (opens new window)
  • 后端API文档 (opens new window)
RuleGo (opens new window)
  • English
  • 简体中文
🏠首页
🧭使用
  • 简介
  • 安装
  • 配置
  • 组件
  • 架构设计
  • 国际化
  • 事件系统
  • 调试功能
  • AI功能
  • 自定义节点
  • 分组节点
  • RuleGo-Editor (opens new window)
  • RuleGo-Server (opens new window)
  • 后端API文档 (opens new window)
RuleGo (opens new window)
  • English
  • 简体中文
  • 简介
  • 安装
  • 配置
  • 节点组件
  • 架构设计
  • 国际化
  • 事件系统
  • 调试功能
  • AI 功能
    • 启用条件
      • 后端
      • 前端
    • AI 对话面板
      • 打开方式
      • 功能特性
      • 使用流程
      • 面板 Props
      • 面板事件
    • AI 代理节点
      • ai/agent 智能体节点
      • ai/llm 文本生成节点
      • ai/intent 意图识别节点
      • ai/localIntent 本地意图识别节点
      • ai/mcpClient MCP 客户端节点
      • ai/createImage 图像生成节点
      • RAG 相关节点
    • AI 服务商配置
      • 内置服务商列表
      • 使用方式
      • 自定义服务商
      • 自定义嵌入模型服务商
    • AI 对话配置
      • 配置项
      • 配置方式
      • 配置优先级
    • 工具栏配置
  • 自定义节点开发
  • 分组节点
目录

AI 功能

RuleGo-Editor 集成了 AI 能力,包括 AI 对话面板和 AI 代理节点两大功能。AI 对话面板允许用户通过自然语言对话自动生成和修改规则链;AI 代理节点则在规则链运行时调用大模型能力,实现智能体、文本生成、意图识别等场景。

图文教程:手把手教你使用 AI 助手创建规则链(含操作截图),请参考 AI 助手使用教程 (opens new window)

# 启用条件

AI 功能需要后端和前端同时满足条件才能使用。

# 后端

RuleGo 后端需要使用 with_ai 构建标签编译:

go build -tags with_ai
1

# 前端

前端会自动检测 AI 组件是否可用。检测逻辑为:从后端 API 加载的组件列表(nodeComponents)中是否存在 ai/agent 类型的组件。如果存在,编辑器工具栏会自动显示【AI 助手】按钮,左侧组件面板也会展示 AI 分类下的所有节点。

无需额外的前端配置,只要后端启用了 AI 组件,前端即可自动识别。


# AI 对话面板

AI 对话面板(RuleChainChatPanel.vue)是一个内嵌在编辑器中的 AI 助手,用户可以通过自然语言描述需求,AI 会自动生成规则链配置并应用到画布。

# 打开方式

点击工具栏中的【AI 助手】按钮即可打开面板。面板支持两种显示模式:

  • 浮动模式(默认):面板以浮动窗口形式显示在画布右下角,支持拖拽移动和调整大小。
  • 分割模式:面板显示在画布右侧,与画布并排排列,适合宽屏使用。

# 功能特性

特性 说明
多轮对话 支持上下文连续对话,AI 能记住之前的对话内容
规则链上下文 自动将当前画布上的规则链数据作为上下文发送给 AI
选中元素感知 自动将用户选中的节点和连线作为上下文
流式输出 AI 回复以流式方式逐字显示,支持随时中断
工具调用展示 AI 调用工具时实时显示执行进度和结果
思考过程展示 支持展示推理模型的思考过程(如 DeepSeek-R1)
规则链预览 AI 生成的规则链可以直接预览并应用到画布
异链操作 AI 创建新规则链时,支持在当前画布或新窗口打开
对话持久化 对话历史保存在 localStorage 中,刷新页面不丢失
快捷提示词 首次打开时提供常用提示词卡片,点击即可发送
输入历史 空输入时按上下箭头可浏览历史输入
重新生成 支持对最后一条 AI 回复重新生成

# 使用流程

  1. 点击工具栏【AI 助手】按钮打开面板
  2. 首次使用时需要在面板设置中配置 AI 服务商和 API Key
  3. 在输入框中描述你想要的规则链,例如:创建一个 MQTT 到 HTTP 的数据转发规则链
  4. AI 会分析需求并生成规则链配置
  5. 生成完成后点击【应用到画布】将规则链应用到当前画布
  6. 可以继续对话进行修改,例如:在 HTTP 节点前面加一个过滤节点

图文教程:更详细的 AI 助手使用教程(含截图)请参考 AI 助手使用教程 (opens new window)

# 面板 Props

属性 类型 默认值 说明
mode string floating 显示模式:floating(浮动)或 split(分割)
getGraphData Function () => null 获取当前画布规则链数据的函数
getSelectedElements Function () => ({nodes: [], edges: []}) 获取当前选中元素的函数
baseUrl string '' RuleGo 服务 API 基础地址
initialRuleChain Object null 初始规则链数据
isSubChain boolean false 是否为子规则链模式

# 面板事件

事件名 说明 回调参数
apply-rule-chain 将 AI 生成的规则链应用到画布 data:规则链数据
rule-chain-saved AI 调用保存工具成功后触发 -
open-rule-chain 在画布中打开其他规则链 data:规则链数据
open-settings 打开 AI 设置面板 -
close 关闭面板 -

# AI 代理节点

AI 代理节点是可以在规则链中拖拽使用的组件,在规则链运行时调用 AI 能力。所有 AI 节点位于左侧组件面板的 ai 分类下。

# ai/agent 智能体节点

基于 ReAct(Reasoning and Acting)框架的 AI 智能体节点,支持调用工具和技能完成复杂任务。智能体会根据用户输入进行推理,决定调用哪些工具,并根据工具返回结果继续推理,直到任务完成。

连接关系:Success、Failure、Stream

配置项:

字段 类型 必选 说明
provider string 否 AI 服务商,选择后自动填充 API 地址和模型列表
url string 是 API 地址,默认 https://api.openai.com/v1
key string 否 API 密钥
model string 否 模型名称,默认 gpt-4,支持手动输入
systemPrompt string 否 系统提示词,支持 ${} 占位符变量
messages array 否 内置消息列表,当输入消息非 JSON 格式时自动使用
images string 否 图像 URL 列表,用于视觉理解(需模型支持)
params object 否 大模型参数,包含 temperature、topP、maxTokens 等
tools array 否 工具列表,配置大模型可调用的工具
maxStep number 否 最大迭代次数
maxToolOutputLength number 否 工具输出最大长度,默认 50000
maxRetries number 否 最大重试次数,对 429/5xx/网络错误自动重试,默认 3

params 子字段:

字段 类型 默认值 说明
temperature number 0.7 采样温度,范围 [0.0, 2.0],值越高输出越随机
topP number - 核心采样,范围 [0.0, 1.0]
presencePenalty number - 存在惩罚,范围 [0.0, 1.0]
frequencyPenalty number - 频率惩罚,范围 [0.0, 1.0]
maxTokens number - 最大输出长度
stop string - 模型停止输出的标记
responseFormat string text 输出格式:text、json_object、json_schema
jsonSchema string - JSON Schema 定义(responseFormat 为 json_schema 时使用)
keepThink boolean - 是否保留输出思考过程(仅 text 格式生效)
extraFields object - 扩展字段,用于传递模型特定参数

# ai/llm 文本生成节点

调用大模型进行文本生成,适用于简单的文本处理场景,不支持工具调用。

配置项:

字段 类型 必选 说明
url string 否 API 地址
key string 否 API 密钥
model string 否 模型名称,支持手动输入
systemPrompt string 否 系统提示词,支持 ${} 占位符变量
messages array 是 上下文/用户消息列表
images string 否 图像 URL 列表,用于视觉理解
params object 否 大模型参数(同 ai/agent 的 params)

messages 字段说明:

每条消息包含 role 和 content 两个字段:

字段 类型 说明
role string 角色:user(用户)或 assistant(助手)
content string 消息内容

# ai/intent 意图识别节点

基于大模型分析用户输入的意图,并根据识别结果路由到对应的分支连接。适用于构建基于意图分类的对话系统或消息路由。

配置项:

字段 类型 必选 说明
url string 否 API 地址,默认 https://ai.gitee.com/v1
key string 否 API 密钥
model string 否 模型名称,默认 Qwen2.5-72B-Instruct
input string 否 用户输入表达式,支持 ${msg.key} 和 ${metadata.key},为空时使用消息体数据
intents array 否 预定义的意图列表
defaultIntent string 否 无法识别时的默认意图,默认 default
systemPrompt string 否 自定义意图识别提示词,为空时使用内置默认提示词
temperature number 否 采样温度,默认 0.1(低温度适合分类任务)
maxTokens number 否 最大输出长度,默认 0(使用模型默认值)

intents 字段说明:

字段 类型 说明
name string 意图标识,同时作为路由连接的类型
description string 意图描述,帮助模型识别

意图识别节点的每个意图对应一条输出连接,连接类型即为意图名称。当 AI 识别出用户意图后,消息会通过对应的连接路由到下一个节点。

# ai/localIntent 本地意图识别节点

基于嵌入向量的本地意图分类,无需调用 LLM,通过语义相似度匹配意图。适合对响应速度要求高、意图类别固定的场景。

连接关系:Success、Failure

配置项:

字段 类型 必选 说明
provider string 否 嵌入模型服务商,选择后自动填充配置
url string 是 嵌入模型 API 地址
key string 否 API 密钥
model string 否 嵌入模型名称
input string 否 用户输入表达式
intents array 否 预定义的意图列表(与 intentsFile 二选一)
intentsFile string 否 外部意图配置文件路径,支持 YAML 和 JSON 格式
threshold number 否 相似度阈值,默认 0.65
minGap number 否 最小置信度差值,默认 0.05
defaultIntent string 否 默认意图,默认 Default

intents 字段说明:

字段 类型 说明
name string 意图标识
description string 意图描述
examples array 示例语句列表,建议 3-10 条

# ai/mcpClient MCP 客户端节点

连接远程 MCP(Model Context Protocol)服务器,调用指定的 MCP 工具并将结果写入消息体。

连接关系:Success、Failure

配置项:

字段 类型 必选 说明
server string 是 MCP 服务器地址,支持 HTTP URL 或 stdio 命令
toolName string 否 工具名称,支持 ${msg.xxx}、${metadata.xxx} 表达式
args string 否 工具参数 JSON 模板,支持表达式
toolFilter array 否 工具名称过滤器,支持 * 通配

# ai/createImage 图像生成节点

调用 DALL-E 或兼容接口生成图像。

配置项:

字段 类型 必选 默认值 说明
url string 否 https://ai.gitee.com/v1 API 地址
key string 否 - API 密钥
model string 否 dall-e-3 模型名称
prompt string 否 - 图像生成的描述文本
n number 否 1 生成数量
size string 否 1024x1024 图像尺寸
quality string 否 standard 质量:standard 或 hd
style string 否 vivid 风格:vivid 或 natural
response_format string 否 url 响应格式:url 或 b64_json

# RAG 相关节点

RuleGo-Editor 还提供了文档加载、文本分块、向量嵌入和向量检索等 RAG(检索增强生成)相关节点:

节点类型 说明
ai/transform/documentLoader 文档加载器,支持从文件、URL、S3 加载文档
ai/transform/textChunker 文本分块器,将长文档分割为小块
ai/embedding/openai OpenAI 嵌入节点,生成文本向量
ai/indexer/milvus Milvus 索引节点,将向量写入 Milvus
ai/indexer/redis Redis 索引节点,将向量写入 Redis
ai/retriever/milvus Milvus 检索节点,从 Milvus 检索向量
ai/retriever/redis Redis 检索节点,从 Redis 检索向量

# AI 服务商配置

AI 对话面板内置了多个 AI 服务商,用户可以在面板中选择使用。所有服务商均兼容 OpenAI Chat Completions API 格式。

# 内置服务商列表

服务商 ID 默认 API 地址 默认模型 可用模型
Gitee AI gitee_ai https://ai.gitee.com/v1 DeepSeek-V4-Flash DeepSeek-V4-Flash、DeepSeek-R1、GLM-5.1、Qwen3-Coder
DeepSeek deepseek https://api.deepseek.com deepseek-chat DeepSeek-V4-Flash、DeepSeek-V3.2、DeepSeek-R1
通义千问 qwen https://dashscope.aliyuncs.com/compatible-mode/v1 qwen-plus qwen-plus、qwen-turbo、qwen-max
智谱 AI zhipu https://open.bigmodel.cn/api/paas/v4 glm-5 glm-5.1、glm-5、glm-4.7
OpenAI openai https://api.openai.com/v1 gpt-4o gpt-4o、gpt-4o-mini
Ollama (本地) ollama http://localhost:11434/v1 llama3 llama3、qwen2、mistral

# 使用方式

在 AI 助手面板中:

  1. 点击面板右上角的设置按钮
  2. 选择 AI 服务商
  3. 填写 API Key(Ollama 本地部署无需 API Key)
  4. 选择模型
  5. 如需使用自定义 API 地址,可手动修改

# 自定义服务商

通过 window.rulegoAiProviders 全局变量可以添加自定义 AI 服务商。在 public/config/config.js 或页面中设置:

window.rulegoAiProviders = [
  {
    id: 'custom',
    label: '自定义AI',
    url: 'https://api.custom.com/v1',
    defaultModel: 'model-1',
    models: [
      { label: 'Model 1', value: 'model-1' },
      { label: 'Model 2', value: 'model-2' },
    ]
  }
]
1
2
3
4
5
6
7
8
9
10
11
12

设置后会覆盖内置服务商列表。如果需要追加而非覆盖,可以先获取内置列表再合并:

// 获取当前服务商列表(包含内置和已自定义的)
const currentProviders = window.rulegoAiProviders || []

window.rulegoAiProviders = [
  ...currentProviders,
  {
    id: 'my_provider',
    label: '我的AI服务',
    url: 'https://my-ai.example.com/v1',
    defaultModel: 'my-model',
    models: [
      { label: 'My Model', value: 'my-model' },
    ]
  }
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

# 自定义嵌入模型服务商

类似地,通过 window.rulegoAiEmbeddingProviders 可以配置嵌入模型服务商,用于本地意图识别等场景:

window.rulegoAiEmbeddingProviders = [
  {
    id: 'custom_embedding',
    label: '自定义嵌入',
    url: 'https://api.custom.com/v1/embeddings',
    defaultModel: 'embedding-model',
    models: [
      { label: 'Embedding Model', value: 'embedding-model' },
    ]
  }
]
1
2
3
4
5
6
7
8
9
10
11

# AI 对话配置

编辑器内置了 config.js 配置文件,定义了 AI 聊天功能的默认参数。可通过 window.rulegoEditorConfig.aiChat 覆盖。

# 配置项

字段 类型 默认值 说明
maxHistoryPerChain number 50 每条规则链最大保留消息数
maxContextMessages number 20 发送给 AI 的最大上下文消息数
maxMessageLength number 2000 单条消息最大字符数(超出将截断)
storageKeyPrefix string rulego-chat-history- localStorage key 前缀
maxActiveChains number 20 内存中最多保留的规则链聊天状态数

# 配置方式

在 public/config/config.js 中设置:

window.rulegoEditorConfig = {
  baseUrl: 'http://127.0.0.1:9090',
  aiChat: {
    maxHistoryPerChain: 100,
    maxContextMessages: 30,
    maxMessageLength: 3000,
    storageKeyPrefix: 'my-chat-',
    maxActiveChains: 50,
  }
}
1
2
3
4
5
6
7
8
9
10

# 配置优先级

配置使用 Proxy 实现动态读取,优先级为:

  1. window.rulegoEditorConfig.aiChat 中的值(最高)
  2. AI_CHAT_BASE 中的默认值(最低)

修改 window.rulegoEditorConfig.aiChat 后立即生效,无需重启。


# 工具栏配置

AI 助手按钮可通过 options.toolbar.showAiChat 控制显隐:

const options = ref({
  toolbar: {
    showAiChat: true,  // 默认 true,设为 false 隐藏
  },
})
1
2
3
4
5

详见 配置 文档。

上次更新: 2026/05/29, 04:08:46
调试功能
自定义节点开发

← 调试功能 自定义节点开发→

Theme by Vdoing | Copyright © 2023-2026 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式