Skip to content

AI 面板

image

介绍

可将 AI 面板组件拖入到页面的任意位置,实现业务与 AI 智能的结合。

API

Props

参数字段名描述类型默认值
默认状态status组件的显隐状态控制default / hidden / destroy'default'
能力配置appCode选择已配置的 AI 应用string-
变量inputs智能体配置时所需的变量,返回对象function返回空对象
触发模式mode用户输入input / 固定fixedinput-
输入内容fixedInput固定模式下固定的查询语句string-
占位文字placeholder占位文字string-
图标icon展开面板图标string-
图表颜色iconColor展开面板图标颜色string-
标题文字title展开面板标题stringAI面板
操作栏bubbleActions气泡操作栏配置BubbleActionItem[]
javascript
interface Message {
  type: "ai" | "user"; // 消息类型
  id: number;
  content: string; // 消息内容
  thougth?: string; // 思考内容
  pageJson?: any; // 页面json
  isThinking?: boolean; // 是否正在思考中
  thinkTime?: boolean; // 思考时间
  status?: "loading" | "success" | "fail"; // 消息状态
  files?: MessageFileItem[]; // 气泡中显示的文件
}


interface BubbleActionItem {
  operateType: "copy" | "refresh" | "custom"; // 操作类型,复制、重新生成、自定义,复制和重新生成为内置功能
  type: "icon" | "text"; // 按钮展示类型,图标或文本
  icon: string; // 图标 type === "icon"
  text: string; // 文本 type === "text"
  color?: string; // 按钮显示颜色
  tip?: string; // 按钮提示信息
  showCondition?: (ctx, params: { item: Message }) => boolean; // 显示条件,返回true/false
  onClick?: (ctx, params: { item: Message }) => void; // 按钮的点击事件
}