知识辅助

本页包含 Generative knowledge assist 界面模块(也称为 Knowledge Assist V2)的 API 文档。此模块供客服人员查询公司知识库并接收由生成式 AI 提供的答案。

用法

使用以下代码在 HTML 页面中导入模块:

<script src="https://www.gstatic.com/agent-assist-ui-modules/v2/knowledge_assist.js"></script>

使用以下标记嵌入模块:

<agent-assist-knowledge-assist-v2>

属性

属性名称 类型 评论
session-id 字符串 非基于对话的用法的可选会话 ID。
父级 字符串 要用于非基于对话的用例的父项目位置名称。示例:“projects/foo/locations/global”

用法

属性是基于字符串的组件属性,可以通过以下方式进行设置:

直接从 HTML 模板中:

<element-selector property-name="value">

在 JavaScript 代码中:

var el = document.querySelector('element-selector');
el.setAttribute('property-name', 'value');

输入

属性名称 类型 评论
config KnowledgeAssistV2Config 知识辅助 V2 模块的可选配置。

用法

输入通常是 JavaScript 对象或其他复杂属性类型,必须直接在元素实例上分配:

const el = document.querySelector('element-selector');
el.propertyName = value;

类型

如需了解该组件使用的自定义类型,请参阅以下部分。

KnowledgeAssistV2Config

interface KnowledgeAssistV2Config {
  articleLinkConfig: {
    /**
     * Whether to open the article in a new tab, or as a popup. Defaults to new
     * tab.
     */
    target?: "blank" | "popup";
    /**
     * Options to configure the popup's size and location. See
     * https://developer.mozilla.org/en-US/docs/Web/API/Window/open#window_features.
     */
    popupWindowOptions?: string;
    /**
     * The field name on the document metadata if a separate article link source
     * is provided.
     */
    linkMetadataKey?: string;
  };
  showCopyAnswer: boolean;
  showPasteAnswer: boolean;
}