communications-mining
latest
false
- API 文档
- CLI
- 集成指南
- 博客
重要 :
请注意,此内容已使用机器翻译进行了本地化。
Communications Mining 开发者指南
上次更新日期 2024年12月20日
创建流
/api/v1/datasets/<project>/<dataset_name>/streams
/api/v1/datasets/<project>/<dataset_name>/streams
所需权限:流管理员、查看标签
- 重击
curl -X PUT 'https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams' \ -H "Authorization: Bearer $REINFER_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "stream": { "comment_filter": { "user_properties": { "number:Spend": { "maximum": 100000, "minimum": 100 }, "number:Transactions": { "one_of": [ 1 ] }, "string:Country": { "one_of": [ "uk", "de" ] } } }, "description": "Used by ACME RPA to create tickets for disputes.", "model": { "label_thresholds": [ { "name": [ "Some Label" ], "threshold": 0.37 }, { "name": [ "Another Label" ], "threshold": 0.46 }, { "name": [ "Parent Label", "Child Label" ], "threshold": 0.41 } ], "version": 8 }, "name": "dispute", "title": "Collateral Disputes" } }'
curl -X PUT 'https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams' \ -H "Authorization: Bearer $REINFER_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "stream": { "comment_filter": { "user_properties": { "number:Spend": { "maximum": 100000, "minimum": 100 }, "number:Transactions": { "one_of": [ 1 ] }, "string:Country": { "one_of": [ "uk", "de" ] } } }, "description": "Used by ACME RPA to create tickets for disputes.", "model": { "label_thresholds": [ { "name": [ "Some Label" ], "threshold": 0.37 }, { "name": [ "Another Label" ], "threshold": 0.46 }, { "name": [ "Parent Label", "Child Label" ], "threshold": 0.41 } ], "version": 8 }, "name": "dispute", "title": "Collateral Disputes" } }' - 节点
const request = require("request"); request.put( { url: "https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams", headers: { Authorization: "Bearer " + process.env.REINFER_TOKEN, }, json: true, body: { stream: { comment_filter: { user_properties: { "number:Spend": { maximum: 100000, minimum: 100 }, "number:Transactions": { one_of: [1] }, "string:Country": { one_of: ["uk", "de"] }, }, }, description: "Used by ACME RPA to create tickets for disputes.", model: { label_thresholds: [ { name: ["Some Label"], threshold: 0.37 }, { name: ["Another Label"], threshold: 0.46 }, { name: ["Parent Label", "Child Label"], threshold: 0.41 }, ], version: 8, }, name: "dispute", title: "Collateral Disputes", }, }, }, function (error, response, json) { // digest response console.log(JSON.stringify(json, null, 2)); } );
const request = require("request"); request.put( { url: "https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams", headers: { Authorization: "Bearer " + process.env.REINFER_TOKEN, }, json: true, body: { stream: { comment_filter: { user_properties: { "number:Spend": { maximum: 100000, minimum: 100 }, "number:Transactions": { one_of: [1] }, "string:Country": { one_of: ["uk", "de"] }, }, }, description: "Used by ACME RPA to create tickets for disputes.", model: { label_thresholds: [ { name: ["Some Label"], threshold: 0.37 }, { name: ["Another Label"], threshold: 0.46 }, { name: ["Parent Label", "Child Label"], threshold: 0.41 }, ], version: 8, }, name: "dispute", title: "Collateral Disputes", }, }, }, function (error, response, json) { // digest response console.log(JSON.stringify(json, null, 2)); } ); - Python
import json import os import requests response = requests.put( "https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams", headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]}, json={ "stream": { "name": "dispute", "title": "Collateral Disputes", "description": "Used by ACME RPA to create tickets for disputes.", "model": { "version": 8, "label_thresholds": [ {"name": ["Some Label"], "threshold": 0.37}, {"name": ["Another Label"], "threshold": 0.46}, { "name": ["Parent Label", "Child Label"], "threshold": 0.41, }, ], }, "comment_filter": { "user_properties": { "string:Country": {"one_of": ["uk", "de"]}, "number:Spend": {"minimum": 100, "maximum": 100000}, "number:Transactions": {"one_of": [1]}, } }, } }, ) print(json.dumps(response.json(), indent=2, sort_keys=True))
import json import os import requests response = requests.put( "https://<my_api_endpoint>/api/v1/datasets/project1/collateral/streams", headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]}, json={ "stream": { "name": "dispute", "title": "Collateral Disputes", "description": "Used by ACME RPA to create tickets for disputes.", "model": { "version": 8, "label_thresholds": [ {"name": ["Some Label"], "threshold": 0.37}, {"name": ["Another Label"], "threshold": 0.46}, { "name": ["Parent Label", "Child Label"], "threshold": 0.41, }, ], }, "comment_filter": { "user_properties": { "string:Country": {"one_of": ["uk", "de"]}, "number:Spend": {"minimum": 100, "maximum": 100000}, "number:Transactions": {"one_of": [1]}, } }, } }, ) print(json.dumps(response.json(), indent=2, sort_keys=True)) - 响应
{ "status": "ok", "stream": { "context": "0", "created_at": "2019-08-03T12:30:00.123456Z", "dataset_id": "abcdef0123456789", "description": "Used by ACME RPA to create tickets for disputes.", "id": "0123456789abcdef", "model": { "version": 8 }, "name": "dispute", "title": "Collateral Disputes", "updated_at": "2019-08-03T12:30:00.123456Z" } }
{ "status": "ok", "stream": { "context": "0", "created_at": "2019-08-03T12:30:00.123456Z", "dataset_id": "abcdef0123456789", "description": "Used by ACME RPA to create tickets for disputes.", "id": "0123456789abcdef", "model": { "version": 8 }, "name": "dispute", "title": "Collateral Disputes", "updated_at": "2019-08-03T12:30:00.123456Z" } }
流通过数据集中的注释启用持久的有状态迭代,并使用已固定的模型计算预测标签和常规字段。
创建流后,可使用和方法可用于遍历注释。
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
name | 字符串 | 是 | 流的 API 名称,在 URL 中使用。 在数据集中必须是唯一的,并且必须匹配[A-Za-z0-9-_]{1,256} 。
|
title | 字符串 | 否 | 流的单行人类可读标题。 |
description | 字符串 | 否 | 更长的流说明。 |
model | 模型 | 否 | 如果指定,从此流中获取的注释将包含来自已固定的模型的预测。 |
comment_filter | CommentFilter | 否 | 如果指定,则不会返回与筛选器不匹配的注释。 有关注释筛选器将如何影响流返回的结果,请参见详细信息。 |
其中
Model
具有以下格式:
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
version | 整数 | 是 | 已通过“模型”页面固定的模型版本。 |
label_thresholds | array<LabelThreshold> | 否 | 如果设置,则仅返回与给定label_thresholds 匹配的值。 如果未设置,则将返回所有标签和所有预测值。
|
其中
LabelThreshold
具有以下格式:
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
name | array<string> | 是 | 要返回的标签名称,格式为层次结构标签列表。 例如,标签"Some Label" 将具有["Some Label"] 格式,而标签"Parent Label > Child Label" 将具有["Parent Label", "Child Label"] 格式。
|
threshold | 数字 | 是 | 用于标签的可信度阈值 (0.0 到 1.0 之间的数字)。 仅当注释的预测值高于此阈值时,才会返回注释的标签。 |
其中
CommentFilter
具有以下格式:
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
user_properties | UserPropertyFilter | 否 | 适用于注释的用户属性的筛选器。 有关用户属性的更多信息,请参阅注释参考。 |
UserPropertyFilter
是要筛选的用户属性名称的映射。 字符串属性可能会筛选为集合 ( {"one_of": ["val_1", "val_2"]}
) 中的值。 数字属性可以筛选为集合中的值 ( {"one_of": [123, 456]}
) 或范围 ( {"minimum": 123, "maximum": 456}
)。