Entities 模块
更新时间:2026-11-03
实体接口
本文介绍实体相关的 3 个接口。查询从记忆中抽取的实体列表、实体详情和实体共现图。
调用说明
- 接入地址:
https://cloud.memory.bj.baidubce.com/api,下文路径直接拼接在该地址后。 - 请求头:
Authorization: Bearer <token>必填;有 JSON 请求体时需携带Content-Type: application/json。 - 错误码、异步操作和
operationId的说明见 API 简介。
接口列表
| 接口 | 方法 | 路径 |
|---|---|---|
| 列出 entity | GET |
/v1/default/banks/{bank_id}/entities |
| 获取 entity 共现图 | GET |
/v1/default/banks/{bank_id}/entities/graph |
| 获取 entity 详情 | GET |
/v1/default/banks/{bank_id}/entities/{entity_id} |
列出 entity
GET /v1/default/banks/{bank_id}/entities
列出 bank 已知的所有 entities(人物、组织等),按提及次数排序;支持分页。
参数
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
bank_id |
path | string |
是 | Bank 的唯一标识符。 |
limit |
query | integer |
否 | 返回 entity 的最大数量;默认值:100;最小值:0 |
offset |
query | integer |
否 | 分页偏移量;默认值:0;最小值:0 |
请求头
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
Authorization |
header | string |
是 | Bearer token。 |
响应
- 状态码:
200— 成功响应 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
items |
array<EntityListItem> |
是 | 结果项目列表。 |
total |
integer |
是 | 总数量。 |
limit |
integer |
是 | 返回数量上限。 |
offset |
integer |
是 | 分页偏移量。 |
items[] · EntityListItem
数据结构 EntityListItem:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id |
string |
是 | 资源的唯一标识符。 |
canonical_name |
string |
是 | Entity 的规范名称。 |
mention_count |
integer |
是 | 提及次数。 |
first_seen |
string? |
否 | 首次出现时间。 |
last_seen |
string? |
否 | 最近出现时间。 |
metadata |
object? |
否 | 附加元数据。 |
响应示例
JSON
1{
2 "items": [
3 {
4 "canonical_name": "John",
5 "first_seen": "2024-01-15T10:30:00Z",
6 "id": "123e4567-e89b-12d3-a456-426614174000",
7 "last_seen": "2024-02-01T14:00:00Z",
8 "mention_count": 15
9 }
10 ],
11 "limit": 100,
12 "offset": 0,
13 "total": 150
14}
响应
- 状态码:
422— 校验错误 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
detail |
array<ValidationError> |
否 | 详细信息或校验错误列表。 |
detail[] · ValidationError
数据结构 ValidationError:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
loc |
array<string \| integer> |
是 | 发生校验错误的位置路径;数组元素可以是字段名或索引。 |
msg |
string |
是 | 错误消息或状态消息。 |
type |
string |
是 | 对象或错误的类型。 |
input |
any |
否 | 触发校验的原始输入值。 |
ctx |
Context |
否 | 错误上下文信息。 |
响应示例
JSON
1{
2 "detail": [
3 {
4 "loc": [],
5 "msg": "string",
6 "type": "string",
7 "input": null,
8 "ctx": {}
9 }
10 ]
11}
operationId=list_entities
获取 entity 共现图
GET /v1/default/banks/{bank_id}/entities/graph
返回 entities(节点)及其共现关系(edges)的图数据,用于可视化。
参数
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
bank_id |
path | string |
是 | Bank 的唯一标识符。 |
limit |
query | integer |
否 | 返回共现边的最大数量;默认值:1000;最小值:0 |
min_count |
query | integer |
否 | 纳入共现边所需的最低cooccurrence_count;默认值:1 |
请求头
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
Authorization |
header | string |
是 | Bearer token。 |
响应
- 状态码:
200— 成功响应 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
nodes |
array<object> |
是 | 图中的节点列表。 |
edges |
array<object> |
是 | 图中的边列表。 |
total_entities |
integer |
是 | entity 总数。 |
total_edges |
integer |
是 | 边总数。 |
limit |
integer |
是 | 返回数量上限。 |
响应示例
JSON
1{
2 "edges": [
3 {
4 "data": {
5 "color": "#ffd700",
6 "id": "uuid-1-uuid-2",
7 "lastCooccurred": "2024-02-01T14:00:00Z",
8 "lineStyle": "solid",
9 "link类型。": "cooccurrence",
10 "source": "uuid-1",
11 "target": "uuid-2",
12 "weight": 5
13 }
14 }
15 ],
16 "limit": 1000,
17 "nodes": [
18 {
19 "data": {
20 "color": "#42a5f5",
21 "id": "uuid-1",
22 "label": "Alice",
23 "mentionCount": 12
24 }
25 },
26 {
27 "data": {
28 "color": "#42a5f5",
29 "id": "uuid-2",
30 "label": "Google",
31 "mentionCount": 8
32 }
33 }
34 ],
35 "total_edges": 1,
36 "total_entities": 2
37}
响应
- 状态码:
422— 校验错误 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
detail |
array<ValidationError> |
否 | 详细信息或校验错误列表。 |
detail[] · ValidationError
数据结构 ValidationError:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
loc |
array<string \| integer> |
是 | 发生校验错误的位置路径;数组元素可以是字段名或索引。 |
msg |
string |
是 | 错误消息或状态消息。 |
type |
string |
是 | 对象或错误的类型。 |
input |
any |
否 | 触发校验的原始输入值。 |
ctx |
Context |
否 | 错误上下文信息。 |
响应示例
JSON
1{
2 "detail": [
3 {
4 "loc": [],
5 "msg": "string",
6 "type": "string",
7 "input": null,
8 "ctx": {}
9 }
10 ]
11}
operationId=get_entity_graph
获取 entity 详情
GET /v1/default/banks/{bank_id}/entities/{entity_id}
获取 entity 的详细信息,包括 observations(mental model)。
参数
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
bank_id |
path | string |
是 | Bank 的唯一标识符。 |
entity_id |
path | string |
是 | Entity 的唯一 ID。 |
请求头
| 名称 | In | 类型 | 必填 | 说明 |
|---|---|---|---|---|
Authorization |
header | string |
是 | Bearer token。 |
响应
- 状态码:
200— 成功响应 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id |
string |
是 | 资源的唯一标识符。 |
canonical_name |
string |
是 | Entity 的规范名称。 |
mention_count |
integer |
是 | 提及次数。 |
first_seen |
string? |
否 | 首次出现时间。 |
last_seen |
string? |
否 | 最近出现时间。 |
metadata |
object? |
否 | 附加元数据。 |
observations |
array<EntityObservationResponse> |
是 | observation 列表。 |
observations[] · EntityObservationResponse
数据结构 EntityObservationResponse:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
text |
string |
是 | 文本内容。 |
mentioned_at |
string? |
否 | 被提及时间。 |
响应示例
JSON
1{
2 "canonical_name": "John",
3 "first_seen": "2024-01-15T10:30:00Z",
4 "id": "123e4567-e89b-12d3-a456-426614174000",
5 "last_seen": "2024-02-01T14:00:00Z",
6 "mention_count": 15,
7 "observations": [
8 {
9 "mentioned_at": "2024-01-15T10:30:00Z",
10 "text": "John works at Google"
11 }
12 ]
13}
响应
- 状态码:
422— 校验错误 - 格式:
application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
detail |
array<ValidationError> |
否 | 详细信息或校验错误列表。 |
detail[] · ValidationError
数据结构 ValidationError:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
loc |
array<string \| integer> |
是 | 发生校验错误的位置路径;数组元素可以是字段名或索引。 |
msg |
string |
是 | 错误消息或状态消息。 |
type |
string |
是 | 对象或错误的类型。 |
input |
any |
否 | 触发校验的原始输入值。 |
ctx |
Context |
否 | 错误上下文信息。 |
响应示例
JSON
1{
2 "detail": [
3 {
4 "loc": [],
5 "msg": "string",
6 "type": "string",
7 "input": null,
8 "ctx": {}
9 }
10 ]
11}
operationId=get_entity
评价此篇文章
