数据鉴权插件配置
前言
AI应用支持将盘古平台中根据模型产生的业务数据推送给智能体进行数据分析,盘古平台权限中心支持业务数据隔离,需要将用户权限范围内的业务数据推送给智能体用作AI数据分析,因此盘古提供数据鉴权的插件,支持将插件关联到智能体中以达到数据鉴权的作用。
以下为在星海智能体平台配置数据鉴权插件和提示词的步骤。
插件
首先进入星海智能体平台,点击[插件],创建插件,需要配置两个插件:“查询数据名称信息插件”和“查询数据值信息插件”
分别将“查询数据名称信息插件”和“查询数据值信息插件”中的“OpenAPI文件内容”替换到左侧部分,点击[解析],再点击[去校验],插件即可配置完成
查询数据名称信息插件
插件名称:查询数据名称信息插件
插件描述:根据 AI 智能体标识(apiKey)获取其绑定的数据模型和字段元数据。帮助大模型理解数据结构,并选择正确的字段编码进行查询。
OpenAPI文件内容:
{
"openapi": "3.0.0",
"info": {
"title": "AI 数据模型元数据接口",
"description": "根据 AI 智能体标识(apiKey)获取其绑定的数据模型和字段元数据。帮助大模型理解数据结构,并选择正确的字段编码进行查询。",
"version": "1.0.0"
},
"servers": [
{
"url": "https://devportal.hisense.com/api/pangea-ai-proxy",
"description": "生产环境"
}
],
"paths": {
"/dataPlugin/getDataNameInfo": {
"post": {
"summary": "根据 AI 智能体标识(apiKey)获取数据模型和字段的编码和对应的含义描述",
"description": "返回指定 AI 智能体(apiKey)绑定的数据模型和字段列表。包含字段编码和描述,帮助大模型将用户问题映射到精确的数据查询。",
"operationId": "getDataNameInfo",
"parameters": [
{
"name": "apiKey",
"in": "query",
"description": "AI 智能体的唯一标识,用于确定其绑定的数据模型。",
"required": true,
"schema": {
"type": "string",
"example": "ai-agent-123"
}
},
{
"name": "systemName",
"in": "header",
"description": "调用系统名编码(例如 'pangea')。",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "envCode",
"in": "header",
"description": "环境编码(例如 'dev'-开发环境, 'prod'-生产环境)。",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "成功返回数据模型和字段元数据。",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"dataCode": {
"type": "string",
"description": "数据模型的唯一编码(例如 'sales_data'-销售数据)。",
"example": "sales_data"
},
"dataName": {
"type": "string",
"description": "数据模型的可读名称(例如 '销售记录')。",
"example": "销售记录"
},
"dataDesc": {
"type": "string",
"description": "数据模型的详细描述。",
"example": "包含按区域和产品的月度销售数据。"
},
"fieldCode": {
"type": "string",
"description": "字段的唯一编码(例如 'region_code'-区域编码)。用于后续数据查询。",
"example": "region_code"
},
"fieldName": {
"type": "string",
"description": "字段的可读名称(例如 '区域')。帮助大模型匹配用户问题。",
"example": "区域"
}
},
"required": [
"dataCode",
"fieldCode"
]
}
},
"example": [
{
"dataCode": "sales_data",
"dataName": "销售记录",
"dataDesc": "按区域和产品的月度销售数据。",
"fieldCode": "region_code",
"fieldName": "区域"
},
{
"dataCode": "sales_data",
"dataName": "销售记录",
"dataDesc": "按区域和产品的月度销售数据。",
"fieldCode": "sales_amount",
"fieldName": "销售额"
}
]
}
}
},
"400": {
"description": "参数无效或缺失(例如未提供 apiKey)。"
},
"401": {
"description": "未授权访问(例如 systemName 或 envCode 错误)。"
}
}
}
}
}
}
查询数据值信息插件
插件名称:查询数据值信息插件
插件描述:该接口允许AI智能体通过apiKey标识查询关联系统的结构化数据,支持多模型多条件组合查询。每个智能体可以查询1-5个数据模型,每个模型支持2个筛选条件。返回的数据可用于AI决策、分析或展示。
OpenAPI文件内容:
{
"openapi": "3.0.1",
"info": {
"title": "智能体数据查询服务",
"description": "该接口允许AI智能体通过apiKey标识查询关联系统的结构化数据,支持多模型多条件组合查询。每个智能体可以查询1-5个数据模型,每个模型支持2个筛选条件。返回的数据可用于AI决策、分析或展示。",
"version": "1.0.0"
},
"servers": [
{
"url": "https://devportal.hisense.com/api/pangea-ai-proxy",
"description": "生产环境"
}
],
"paths": {
"/dataPlugin/getDataValueInfo": {
"post": {
"tags": [
"Data Plugin"
],
"summary": "智能体数据查询接口",
"description": "通过智能体标识(apiKey)查询关联系统的数据,支持多模型多条件组合查询。典型场景:- 查询用户信息(如年龄>18且状态=active的用户)- 获取商品库存数据- 验证业务规则条件",
"operationId": "getDataValueInfo",
"parameters": [
{
"name": "apiKey",
"in": "query",
"description": "AI 智能体的唯一标识,用于确定其绑定的数据模型。",
"required": true,
"schema": {
"type": "string",
"example": "ai-agent-123"
}
},
{
"name": "systemName",
"in": "header",
"description": "调用系统名编码(例如 'pangea')。",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "envCode",
"in": "header",
"description": "环境编码(例如 'dev'-开发环境, 'prod'-生产环境)。",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "数据查询参数",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"code1": {
"type": "string",
"description": "First code identifier"
},
"code1FieldCode1": {
"type": "string",
"description": "First field code for code1"
},
"code1FieldValue1": {
"type": "string",
"description": "First field value for code1"
},
"code1Operate1": {
"type": "string",
"description": "Operation for first field of code1"
},
"code1FieldCode2": {
"type": "string",
"description": "Second field code for code1"
},
"code1FieldValue2": {
"type": "string",
"description": "Second field value for code1"
},
"code1Operate2": {
"type": "string",
"description": "Operation for second field of code1"
},
"code2": {
"type": "string",
"description": "Second code identifier"
},
"code2FieldCode1": {
"type": "string",
"description": "First field code for code2"
},
"code2FieldValue1": {
"type": "string",
"description": "First field value for code2"
},
"code2Operate1": {
"type": "string",
"description": "Operation for first field of code2"
},
"code2FieldCode2": {
"type": "string",
"description": "Second field code for code2"
},
"code2FieldValue2": {
"type": "string",
"description": "Second field value for code2"
},
"code2Operate2": {
"type": "string",
"description": "Operation for second field of code2"
},
"code3": {
"type": "string",
"description": "Third code identifier"
},
"code3FieldCode1": {
"type": "string",
"description": "First field code for code3"
},
"code3FieldValue1": {
"type": "string",
"description": "First field value for code3"
},
"code3Operate1": {
"type": "string",
"description": "Operation for first field of code3"
},
"code3FieldCode2": {
"type": "string",
"description": "Second field code for code3"
},
"code3FieldValue2": {
"type": "string",
"description": "Second field value for code3"
},
"code3Operate2": {
"type": "string",
"description": "Operation for second field of code3"
},
"code4": {
"type": "string",
"description": "Fourth code identifier"
},
"code4FieldCode1": {
"type": "string",
"description": "First field code for code4"
},
"code4FieldValue1": {
"type": "string",
"description": "First field value for code4"
},
"code4Operate1": {
"type": "string",
"description": "Operation for first field of code4"
},
"code4FieldCode2": {
"type": "string",
"description": "Second field code for code4"
},
"code4FieldValue2": {
"type": "string",
"description": "Second field value for code4"
},
"code4Operate2": {
"type": "string",
"description": "Operation for second field of code4"
},
"code5": {
"type": "string",
"description": "Fifth code identifier"
},
"code5FieldCode1": {
"type": "string",
"description": "First field code for code5"
},
"code5FieldValue1": {
"type": "string",
"description": "First field value for code5"
},
"code5Operate1": {
"type": "string",
"description": "Operation for first field of code5"
},
"code5FieldCode2": {
"type": "string",
"description": "Second field code for code5"
},
"code5FieldValue2": {
"type": "string",
"description": "Second field value for code5"
},
"code5Operate2": {
"type": "string",
"description": "Operation for second field of code5"
}
},
"example": {
"code1": "sampleCode1",
"code1FieldCode1": "field1",
"code1FieldValue1": "value1",
"code1Operate1": "equals",
"code1FieldCode2": "field2",
"code1FieldValue2": "value2",
"code1Operate2": "contains"
}
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
},
"400": {
"description": "Invalid input"
},
"401": {
"description": "Unauthorized"
},
"500": {
"description": "Internal server error"
}
}
}
}
}
}
提示词配置
进入需要关联数据鉴权插件的智能体
关联插件:将创建的两个数据鉴权插件关联到智能体
配置人设与回复逻辑
点击智能体的[调用],复制当前智能体的api_key,每个智能体的api_key是唯一的
在智能体编排处,将以下内容复制到人设与回复逻辑处,并录入上方获取到的智能体唯一标识
(人设与回复逻辑此处为插件相关的配置,您可在此基础上增加您需要的信息)
##变量
智能体唯一标识:
##技能
1.精准判断用户需求,必要时使用智能体唯一标识调用查询数据名称信息插件查询用户绑定的元数据,根据用户的需要从插件返回结果中筛选出数据模型和字段信息
2.根据查询数据名称信息插件查询到的数据模型和字段,从中挑选可以解答用户问题的字段,调用查询数据值信息插件查询出对应的数据值。
##插件描述
1.查询数据名称信息插件
📌 何时调用该插件?
当你需要根据AI智能体唯一标识(apiKey)获取该智能体可访问的数据模型结构及字段信息信息时,此插件可以返回该智能体绑定的所有数据模型及其字段的元数据,使大模型从返回结果中挑选出可以解答用户问题的字段。
2.查询数据值信息插件
📌 何时调用该插件?
当你需要根据数据模型编码查询结构化数据时,可使用此接口。例如:
"查询user模型中age字段值大于18的数据"
"查询Form模型中创建时间在2025.05.21之后的数据"
📌 调用方式:
每次最多传入5个模型,对应模型编码code1至code5,每个模型可以设置两个查询条件,例如,code5FieldCode1对应该模型code5的第一个筛选字段,code5FieldValue1对应该字段的过滤值,code5Operate1对应该字段的逻辑操作符。
其中Operate相关的字段定义为:
EQ(等于)
GT(大于)
GTE(大于等于)
LT(小于)
LTE(小于等于)
NEQ(不等于)
LIKE(like)
CONTAINS(contains)
NOT_CONTAINS(not_contains)
IN(in)
NOT_IN(not_in)
IS_NULL(is null)
IS_NOT_NULL(is not null)
📌 调用方式示例:
例如要查询User模型中,age字段大于18,status字段值等于active的数据:
{
"code1": "User",
"code1FieldCode1": "age",
"code1FieldValue1": "18",
"code1Operate1": "GT",
"code1FieldCode2": "status",
"code1FieldValue2": "active",
"code1Operate2": "EQ"
}