获取样本列表
更新时间:2024-09-23
功能介绍
本接口用于获取样本列表。
SDK调用
使用说明
本文API支持通过Python SDK、Go SDK、Java SDK 和 Node.js SDK调用,调用流程请参考SDK安装及使用流程。
调用示例
import os
from qianfan.resources import Data
# 使用安全认证AK/SK鉴权,通过环境变量方式初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
os.environ["QIANFAN_ACCESS_KEY"] = "your_iam_ak"
os.environ["QIANFAN_SECRET_KEY"] = "your_iam_sk"
resp = Data.list_all_entity_in_dataset(
dataset_id="ds-7pkzh1exthpuy10n",
offset=0,
page_size=10,
)
print(resp)
package main
import (
"context"
"fmt"
"os"
"github.com/baidubce/bce-qianfan-sdk/go/qianfan"
)
func main() {
// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
os.Setenv("QIANFAN_ACCESS_KEY", "your_iam_ak")
os.Setenv("QIANFAN_SECRET_KEY", "your_iam_sk")
ca := qianfan.NewConsoleAction()
res, err := ca.Call(context.TODO(), "/wenxinworkshop/entity/list", "", map[string]interface{}{
"offset": 0,
"pageSize": 10,
"datasetId": "ds-7pkzh1exthpuy10n",
"importTime": []int{},
"annoTime": []int{},
"tabType": 1,
"labelId": "",
})
if err != nil {
panic(err)
}
fmt.Println(string(res.Body))
}
import com.baidubce.qianfan.Qianfan;
import com.baidubce.qianfan.model.console.ConsoleResponse;
import com.baidubce.qianfan.util.CollUtils;
import com.baidubce.qianfan.util.Json;
import java.util.Map;
public class Dome {
public static void main(String args[]){
// 使用安全认证AK/SK鉴权,替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
Qianfan qianfan = new Qianfan("your_iam_ak", "your_iam_sk");
ConsoleResponse<Map<String, Object>> response = qianfan.console()
// 调用本文API,该参数值为固定值,无需修改;对应本文HTTP调用-请求说明-请求地址的后缀
.route("/wenxinworkshop/entity/list")
// 需要传入参数的场景,可以自行封装请求类,或者使用Map.of()来构建请求Body
// Java 8可以使用SDK提供的CollUtils.mapOf()来替代Map.of()
// 对应本文HTTP调用-请求说明-请求参数-Body参数,具体使用请查看Body参数说明,根据实际使用选择参数
.body(CollUtils.mapOf(
"offset", 0,
"pageSize", 10,
"datasetId", "ds-7pkzh1exthpuy10n",
"importTime", new String[]{},
"annoTime", new String[]{},
"tabType", 1,
"labelId", ""
))
.execute();
System.out.println(Json.serialize(response));
}
}
import {consoleAction, setEnvVariable} from "@baiducloud/qianfan";
// 使用安全认证AK/SK鉴权,通过环境变量初始化;替换下列示例中参数,安全认证Access Key替换your_iam_ak,Secret Key替换your_iam_sk
setEnvVariable('QIANFAN_ACCESS_KEY','your_iam_ak');
setEnvVariable('QIANFAN_SECRET_KEY','your_iam_sk');
async function main() {
//base_api_route:调用本文API,该参数值为固定值,无需修改;对应本文HTTP调用-请求说明-请求地址的后缀
//data:对应本文HTTP调用-请求说明-请求参数-Body参数,具体使用请查看Body参数说明,根据实际使用选择参数
const res = await consoleAction({base_api_route: '/wenxinworkshop/entity/list', data: {
"offset": 0,
"pageSize": 10,
"datasetId": "ds-7pkzh1exthpuy10n",
"importTime": [],
"annoTime": [],
"tabType": 1,
"labelId": ""
}
});
console.log(res);
}
main();
返回示例
QfResponse(
code=200,
headers={...},
body={
"log_id": "kap2pmsw2gh4prik",
"result": {
"totalAll":1,
"total":1,
"items": [{
"id":
"f9bc93825e8563588xxx_7951870f3xxxx2f3814b8f268",
"name": "",
"labels": [],
"url": "https://xxxxx",
"memorySize": 0.01,
"isEncrypted": False,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0,
}
}],
},
"status": 200,
"success": True,
},
)
{
"log_id": "15jk2d6tkisnidt9",
"result": {
"totalAll": 138,
"total": 102,
"items": [
{
"id": "172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2Ff45a5fd525e465f03c21ce3962422f3dbf71d1fd0e9ee8e0b591830845bd333b",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
{
"id": "13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2F9b863c3444f671d8667bc32fe31517f05e372878b13b5b56460946236785b736",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
]
},
"status": 200,
"success": true
}
{
"log_id": "15jk2d6tkisnidt9",
"result": {
"totalAll": 138,
"total": 102,
"items": [
{
"id": "172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2Ff45a5fd525e465f03c21ce3962422f3dbf71d1fd0e9ee8e0b591830845bd333b",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
{
"id": "13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2F9b863c3444f671d8667bc32fe31517f05e372878b13b5b56460946236785b736",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
]
},
"status": 200,
"success": true
}
错误码
{
log_id: '15jk2d6tkisnidt9',
result: {
totalAll: 138,
total: 102,
items: [
{
id: '172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e',
name: '',
labels: [
{
label_id: '654887c72733b0c09e2d5bc0',
name: 'ERNIE_BOT',
color: '#1A73E8'
}
],
url: 'https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e?authorization=bce-auth-v1/50c8bb753dcb4e1d8646bb1ffefd3503/2023-11-08T08:49:27Z/7200/host/f45a5fd525e465f03c21ce3962422f3dbf71d1fd0e9ee8e0b591830845bd333b',
memorySize: 0.01,
isEncrypted: false,
textExtra: {
domainType: '',
taskType: '',
wordNum: 0,
repetitiveCharRatio: 0,
specialCharRatio: 0,
flaggedWordRatio: 0,
langProb: 0,
perplexity: 0
}
},
{
id: '13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6',
name: '',
labels: [
{
label_id: '654887c72733b0c09e2d5bc0',
name: 'ERNIE_BOT',
color: '#1A73E8'
}
],
url: 'https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6?authorization=bce-auth-v1/50c8bb753dcb4e1d8646bb1ffefd3503/2023-11-08T08:49:27Z/7200/host/9b863c3444f671d8667bc32fe31517f05e372878b13b5b56460946236785b736',
memorySize: 0.01,
isEncrypted: false,
textExtra: {
domainType: '',
taskType: '',
wordNum: 0,
repetitiveCharRatio: 0,
specialCharRatio: 0,
flaggedWordRatio: 0,
langProb: 0,
perplexity: 0
}
},
]
},
status: 200,
success: true
}
请求参数
注意:以下为Python SDK参数说明,Go SDK、Java SDK、Node.js SDK参数说明请参考本文HTTP调用-请求说明。
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
dataset_id | string | 是 | 数据集版本ID,说明: (1)可以通过以下任一方式获取该字段值: · 方式一,通过调用创建数据集接口,返回的datasetId字段获取 · 方式二,在控制台-数据集管理列表页面,点击详情,在版本信息页查看,如下图所示: (2)该字段新增支持string类型,如果之前使用的是int类型,建议变更为string类型,后续可能将逐步废弃int类型;例如之前是通过调用创建数据集接口,返回的id字段获取,请替换为接口返回的datasetId字段获取 |
offset | int | 否 | 分页偏移,默认0 |
page_size | int | 否 | 分页大小,说明: · 范围[1,30],超出最大范围按最大范围处理 · 默认20 |
import_time_closure | List[int] | 否 | 导入日期区间,可以获取该区间数据,说明: 需传入2个日期的时间戳,单位毫秒,分别是开始日期时间戳、结束日期时间戳 |
annotating_time_closure | List[int] | 否 | 标注日期区间,可以获取该区间数据,说明: 需传入2个日期的时间戳,单位毫秒,分别是开始日期时间戳、结束日期时间戳 |
listing_type | EntityListingType | 否 | 可选值如下: · EntityListingType.AnnotatedOnly:已标注 · EntityListingType.NotAnnotatedOnly :未标注 · EntityListingType.All:全部,默认值 |
label_id_str | string | 否 | 标签id,说明: · 多个labelId用英文逗号分开,如1,2 · 仅文生图支持 |
返回参数
请参考本文HTTP调用-响应说明。
HTTP调用
鉴权说明
调用本文API,使用“基于安全认证AK/SK”进行签名计算鉴权,即使用安全认证中的Access Key ID 和 Secret Access Key进行鉴权,具体鉴权认证机制参考HTTP调用鉴权说明。
请求说明
- 基本信息
请求地址:https://qianfan.baidubce.com/wenxinworkshop/entity/list
请求方式:POST
- Header参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
Content-Type | string | 是 | 固定值:application/json |
x-bce-date | string | 否 | 当前时间,遵循ISO8601规范,格式如2016-04-06T08:23:49Z |
Authorization | string | 是 | 用于验证请求合法性的认证信息,更多内容请参考鉴权认证机制,签名工具可参考IAM签名工具 |
- Body参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
datasetId | string | 是 | 数据集版本ID,说明: (1)可以通过以下任一方式获取该字段值: · 方式一,通过调用创建数据集接口,返回的datasetId字段获取 · 方式二,在控制台-数据集管理列表页面,点击详情,在版本信息页查看,如下图所示: (2)该字段新增支持string类型,如果之前使用的是int类型,建议变更为string类型,后续可能将逐步废弃int类型;例如之前是通过调用创建数据集接口,返回的id字段获取,请替换为接口返回的datasetId字段获取 |
offset | int | 否 | 分页偏移,默认0 |
pageSize | int | 否 | 分页大小,说明: · 范围[1,30],超出最大范围按最大范围处理 · 默认20 |
importTime | int[] | 否 | 导入日期区间,可以获取该区间数据,说明: 需传入2个日期的时间戳,单位毫秒,分别是开始日期时间戳、结束日期时间戳 |
annoTime | int[] | 否 | 标注日期区间,可以获取该区间数据,说明: 需传入2个日期的时间戳,单位毫秒,分别是开始日期时间戳、结束日期时间戳 |
tabType | int | 否 | 可选值如下: · 1:已标注 · 2:未标注 · 0:全部 |
labelId | string | 否 | 标签id,说明: · 多个labelId用英文逗号分开,如1,2 · 仅文生图支持 |
响应说明
说明:返回的部分字段如下,未说明的字段暂无需关注。
名称 | 类型 | 描述 |
---|---|---|
log_id | string | 操作记录id |
result | object | 返回结果 |
status | int | 状态码 |
success | bool | 是否操作成功,说明: · true:成功 · false:失败 |
result说明
名称 | 类型 | 描述 |
---|---|---|
totalAll | int | 总数量 |
total | int | 筛选后的数量 |
items | object[] | 样本列表 |
items说明
名称 | 类型 | 描述 |
---|---|---|
id | string | 样本ID |
name | string | 样本名称,图片才有 |
labels | object[] | 标签列表 |
url | string | 存储地址 |
memorySize | int | 样本大小,单位为MB |
isEncrypted | bool | 是否加密 |
textExtra | object | 文档附加说明 |
label说明
名称 | 类型 | 描述 |
---|---|---|
label_id | string | 标签id |
name | string | 标签名称 |
color | string | 标签颜色 |
textExtra说明
名称 | 类型 | 描述 |
---|---|---|
domainType | string | 领域类型 |
taskType | string | 任务类型 |
wordNum | int | 词数目 |
repetitiveCharRatio | int | 重复率 |
specialCharRatio | int | 特殊字符 |
flaggedWordRatio | int | 色暴词率 |
langProb | int | 语言概率 |
perplexity | int | 困惑率 |
请求示例
# 替换下列示例中的Authorization值、x-bce-date值
curl -i --location 'https://qianfan.baidubce.com/wenxinworkshop/entity/list' \
--header 'Authorization: bce-auth-v1/f0ee7axxxx/2023-09-19T13:42:13Z/180000/host;x-bce-date/9a8cfb8ee58a8f44a21a52640015de61bc55ca2e6d8cc23d080016e374525543' \
--header 'x-bce-date: 2023-09-19T13:37:10Z' \
--header 'Content-Type: application/json' \
--data '{
"offset": 0,
"pageSize": 10,
"datasetId": "ds-7pkzh1exthpuy10n",
"importTime": [],
"annoTime": [],
"tabType": 1,
"labelId": ""
}'
响应示例
{
"log_id": "15jk2d6tkisnidt9",
"result": {
"totalAll": 138,
"total": 102,
"items": [
{
"id": "172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_172383aab601a661be32e89bafccccd17789ba45d5a24cb5db4ec9722fbebe63_1ff9e03fe288419fa1c693b75e38e96e?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2Ff45a5fd525e465f03c21ce3962422f3dbf71d1fd0e9ee8e0b591830845bd333b",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
{
"id": "13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6",
"name": "",
"labels": [
{
"label_id": "654887c72733b0c09e2d5bc0",
"name": "ERNIE_BOT",
"color": "#1A73E8"
}
],
"url": "https://bj.bcebos.com/sdc-default/_system_/dataset/ds-2x3fxhunezkuwu4w/texts/data/raw_13d48401c36e2442ffb0dba377f63e7706799d96a908d950baddb72c4d61f2f6_a48201bb7a72430288ef090790a59ad6?authorization=bce-auth-v1%2F50c8bb753dcb4e1d8646bb1ffefd3503%2F2023-11-08T08%3A49%3A27Z%2F7200%2Fhost%2F9b863c3444f671d8667bc32fe31517f05e372878b13b5b56460946236785b736",
"memorySize": 0.01,
"isEncrypted": false,
"textExtra": {
"domainType": "",
"taskType": "",
"wordNum": 0,
"repetitiveCharRatio": 0,
"specialCharRatio": 0,
"flaggedWordRatio": 0,
"langProb": 0,
"perplexity": 0
}
},
]
},
"status": 200,
"success": true
}
错误码
若请求错误,服务器将返回的JSON文本包含以下参数:
名称 | 描述 |
---|---|
code | 错误码 |
message | 错误描述信息,帮助理解和解决发生的错误 |
例如参数错误返回:
{
"code": 500001,
"message": "param invalid"
}
更多错误码,请查看错误码说明。