Back to Nightingale

各页面快捷提问(recommend_action)规格

doc/api/ai-chat-recommend-action.md

9.1.17.2 KB
Original Source

各页面快捷提问(recommend_action)规格

新会话创建后,AICopilot 在空会话面板上展示「快捷提问」按钮,文案根据 /chat/new 请求里携带的 page 决定。这些预置提示词由前端硬编码维护(不再由后端 /chat/new 接口下发),本文档作为前后端共同的提示词规格。

设计约定

每条快捷提问最终会作为一次 /message/new 调用发出,前端按下表填充 query 字段:

字段来源说明
query.content本文档表格里的「文案」列直接作为用户消息内容
query.action.param/chat/new 时使用的 param(即会话的 page_from.param前端把页面级上下文透传到 action
query.page_from当前会话的 page_from/chat/new 请求一致

不传 action.key:该字段已废弃,后端不再读取(前端发送前会剥掉)。处理路径由后端从 content 确定性解析——创建类文案命中 creation 关键词 fast-path,其余走 general_chat 通用 agent。

示例(在 explorer 页面点击第 1 条快捷提问):

json
{
  "chat_id": "...",
  "query": {
    "content": "帮我生成一个查询主机 CPU 使用率的语句",
    "action": {
      "param": { "datasource_type": "prometheus", "datasource_id": 1 }
    },
    "page_from": {
      "page": "explorer",
      "param": { "datasource_type": "prometheus", "datasource_id": 1 }
    }
  }
}

页面预置提示词总览

page来源页面提示词条数页面 param 建议字段
explorer时序数据探索3datasource_type, datasource_id
dashboards仪表盘列表3busi_group_id(可选)
alert_rule告警规则列表3busi_group_id(可选)
alert_history历史告警列表3可省略
active_alert活跃告警列表3可省略
notify_tpl消息模板配置4可省略
datasource数据源配置3datasource_type, datasource_id(可选)
alert_event_detail告警事件详情3event_id(必填),可选 rule_idtarget_identdatasource_id

未列出的 page 值不展示快捷提问。

各页面的提示词内容

文案多语言由前端按当前 UI 语种就地切换;下表列出英文(缺省)与简体中文,其他语种的翻译由前端根据 i18n 资源补齐。

explorer — 时序数据探索

#英文(缺省)zh_CN
1Generate a query for host CPU usage帮我生成一个查询主机 CPU 使用率的语句
2Generate a query for memory usage帮我生成一个查询机器内存使用率的语句
3Generate a query for host disk usage帮我生成一个查询机器磁盘使用率的语句

param 通常携带当前查询编辑器的数据源(datasource_type, datasource_id),后端将其注入提示词并转发到查询工具层。生成的查询语句以 Markdown 代码块内嵌在 markdown 回答正文中。

dashboards — 仪表盘列表

#英文(缺省)zh_CN
1Create a Host machine dashboard帮我创建一个 Host 机器的仪表盘
2Create a MySQL dashboard帮我创建一个 MySQL 的仪表盘
3Create a Redis dashboard帮我创建一个 Redis 的仪表盘

这些文案会命中后端 creation 关键词 fast-path 并触发 preflight:若 param 中缺少 busi_group_id 等必填上下文,后端会先返回 form_select 让用户补齐。

alert_rule — 告警规则列表

#英文(缺省)zh_CN
1Create a CPU usage alert rule with a threshold above 80%创建一条 CPU 使用率超过 80% 的告警规则
2Create a host down alert rule based on target heartbeat loss创建一条主机失联的告警规则
3Create a disk usage alert rule with a threshold above 85%创建一条机器磁盘使用率超过 85% 的告警规则

dashboards 一样会命中 creation fast-path 并走 preflight;create-alert-rule skill 同时要求 busi_group_iddatasource_id

alert_history — 历史告警列表

#英文(缺省)zh_CN
1Summarize alert trends in the current filter range总结当前筛选范围内的告警趋势
2Which alert rules fired most frequently哪些告警规则触发最频繁
3Break down current alerts by severity, busi group and target按级别、业务组、对象拆解当前告警

active_alert — 活跃告警列表

#英文(缺省)zh_CN
1Summarize the distribution of currently active alerts总结当前活跃告警的分布情况
2Which rules or targets have the most active alerts哪些规则或对象的活跃告警最多
3Group current active alerts by severity and busi group按级别和业务组汇总当前活跃告警

notify_tpl — 消息模板配置

#英文(缺省)zh_CN
1Add hostname and severity label to the notification template在通知模板中加入主机名和告警级别
2Format trigger_value with two decimal places in the template把 trigger_value 保留两位小数
3Include a runbook link in the notification template在通知模板中加入排障文档链接
4Add alert duration and first triggered time to the template在模板中加入告警持续时间和首次触发时间

datasource — 数据源配置

#英文(缺省)zh_CN
1Diagnose why datasource connection fails with an x509 certificate error数据源连接报 x509 证书错误,如何排查
2My datasource test returns 401 unauthorized, how to fix数据源测试连通返回 401 怎么解决
3Help me write the correct URL for connecting Nightingale to this datasource帮我写这个数据源的正确接入 URL

alert_event_detail — 告警事件详情

#英文(缺省)zh_CN
1Analyze the root cause of this alert event分析这条告警事件的根因
2Find similar historical alerts on the same target/rule查找同对象/同规则下的相似历史告警
3Show other active alerts on the same target around this time看下同一对象在这个时间点附近还有哪些活跃告警

param 必须携带 event_id,后端将其注入提示词上下文,通用 agent 据此调用 get_alert_event_detail 等工具读取事件详情;如能一并传入 rule_idtarget_identdatasource_id 可减少二次查询。

新增/修改预置提示词

  1. 在前端 AICopilot 的预置提示词常量表里新增/修改对应 page 下的条目,文案在前端 i18n 资源中补齐多语种翻译。
  2. 同步更新本文件里对应章节的表格。
  3. 如新增的是新 page 类型,需要在后端 models/ai_assistant.goAssistantPageType 常量里同步登记(本文「页面预置提示词总览」表也一并更新),确保 /chat/new 接收到新值时不会被当作未知 page。