> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memorylake.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 编辑知识条目

> 替换知识条目的内容，或修改它的匹配文本

```
PATCH /openapi/memorylake/api/v3/workspaces/{workspaceId}/analysis-models/{modelId}/entries/{entryId}
```

修改一条知识条目。未传入的字段保持当前值。

传入 `payload` 时会整体替换条目的内容，所以请带上所有要保留的槽位，而不只是要修改的那些。和[添加条目](https://docs.memorylake.cn/features/memorylake/api-reference/database/analysis-models/add-knowledge-entry.md)时一样，保存时会再次检查优化案例中的 SQL。

如果只是想停用或恢复条目，也可以调用[停用或恢复知识条目](https://docs.memorylake.cn/features/memorylake/api-reference/database/analysis-models/disable-knowledge-entry.md)。

> [!NOTE]
>
> **所需权限：** `analysis_model:modify`

### 路径参数

**workspaceId** `string` *required*

工作空间 ID

**modelId** `string` *required*

分析模型 ID

**entryId** `string` *required*

知识条目 ID

### 请求体

**entity\_type** `string` *required*

被编辑条目创建时的类型，例如 `general` 或 `few_shot`。编辑请求按它路由，而有些类型仅凭 ID 无法定位。

**embedding** `string`

用于归档和匹配的新文本。不传则保留当前值。各类型中它放的是什么，参见[添加知识条目](https://docs.memorylake.cn/features/memorylake/api-reference/database/analysis-models/add-knowledge-entry.md)。

**payload** `object`

条目的新内容，结构须符合 `entity_type` 的要求。不传则保留当前内容。

**general · 通用知识**

**artifact.general** `object`

背景知识本身，通常是纯文本或 Markdown

**biz\_rule · 业务知识**

**artifact.biz\_rule** `object`

规则本身

**source\_spec** `array`

只读。读取条目时会返回；传入它不会产生任何效果。

**few\_shot · 优化案例**

**artifact.question** `object`

这个案例回答的问题

**artifact.few\_shot** `object`

回答该问题的 SQL，`type` 设为 `SQL`。其中引用的每张表都必须存在于模型所基于的数据源中。

**drilldown\_entity · 业务模型**

**artifact.busi\_caliber** `object`

业务口径：这个指标对业务意味着什么

**artifact.tech\_caliber** `object`

技术口径：这个指标如何计算

**artifact.threshold** `object`

什么样的值对这个指标来说算异常

**artifact.analysis\_hint** `object`

这个指标变动时首先要看什么

**槽位对象**

**type** `string`

`content` 的读取方式：`LIST`、`DICT`、`MARKDOWN`、`TEXT`、`SQL` 或 `FILE`。它表示值的格式，而不是条目的类型。

**desc** `string`

槽位的显示名称，供渲染方使用

**content** `string`

值本身

**disabled** `boolean`

设为 `true` 时让条目不再参与回答，设为 `false` 时让它重新参与。不传则保持当前状态。

**extra** `object`

您希望随条目一起保存的任意内容。不传则保留现有内容；传入的值会替换它。

```bash Replace the SQL theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/analysis-models/am-9d3f7b1e5a2c4d8f6b0e3a7c9d1f5b2e/entries/5d2e7b9cb31d11f1a7c35e9b2d4f6a81' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'EOF'
{
  "entity_type": "few_shot",
  "payload": {
    "artifact": {
      "question": {
        "type": "TEXT",
        "content": "What was total revenue last month?"
      },
      "few_shot": {
        "type": "SQL",
        "content": "SELECT COALESCE(SUM(total_amount), 0) FROM sales.orders WHERE created_at >= date_trunc('month', now()) - interval '1 month' AND created_at < date_trunc('month', now())"
      }
    }
  }
}
EOF
```

```bash Take out of use theme={null}
curl -X PATCH 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws-8001856949ad4f6a5b6226f415ffa877/analysis-models/am-9d3f7b1e5a2c4d8f6b0e3a7c9d1f5b2e/entries/5d2e7b9cb31d11f1a7c35e9b2d4f6a81' \
  -H 'Authorization: Bearer sk_xxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "entity_type": "few_shot",
    "disabled": true
  }'
```

### 响应

返回编辑后的条目。

**data** `object`

**知识条目对象**

**id** `string`

知识条目标识符，请把它当作不透明字符串处理。

**entity\_type** `string`

知识类型，例如 `general` 或 `few_shot`。它决定 `payload` 的结构。

**embedding** `string`

条目用于匹配的文本：问题要与它相似，条目才会被使用。对通用知识条目，它只用于命名条目；对业务规则，它可能是根据规则本身推导出来的。

**disabled** `boolean`

条目当前是否被排除在回答之外

**score** `number`

条目与检索时 `keyword` 的接近程度，取值 0 到 1。不在检索中时它不携带任何信息，通常为 0 或不返回，请不要把它当作条目的质量分。

**payload** `object`

条目的内容。结构随 `entity_type` 而定：内容放在 `artifact` 下的具名槽位中，每个槽位都是一个槽位对象。这里没有列出的键按保存时的原样返回。

**general · 通用知识**

**artifact.general** `object`

背景知识本身，通常是纯文本或 Markdown

**biz\_rule · 业务知识**

**artifact.biz\_rule** `object`

规则本身

**source\_spec** `array`

这条规则所属的数据实体，每项带有其匹配文本。只读：它由条目之间的关联推导而来，本 API 不提供设置关联的方式。

**few\_shot · 优化案例**

**artifact.question** `object`

这个案例回答的问题

**artifact.few\_shot** `object`

回答该问题的 SQL

**drilldown\_entity · 业务模型**

**artifact.busi\_caliber** `object`

业务口径：这个指标对业务意味着什么

**artifact.tech\_caliber** `object`

技术口径：这个指标如何计算

**artifact.threshold** `object`

什么样的值对这个指标来说算异常

**artifact.analysis\_hint** `object`

这个指标变动时首先要看什么

**槽位对象**

**type** `string`

`content` 的读取方式：`LIST`、`DICT`、`MARKDOWN`、`TEXT`、`SQL` 或 `FILE`

**desc** `string`

槽位的显示名称，供渲染方使用

**content** `string`

值本身

**extra** `object`

您随条目一起保存的内容，原样返回。没有保存时不返回该字段。

**source\_count** `integer`

指向这个条目的条目数量

**target\_count** `integer`

这个条目指向的条目数量

**created\_at** `string`

条目的添加时间

**updated\_at** `string`

条目的最后修改时间。停用或恢复也算一次修改。

```json Success (200) theme={null}
{
  "success": true,
  "data": {
    "id": "5d2e7b9cb31d11f1a7c35e9b2d4f6a81",
    "embedding": "What was total revenue last month?",
    "disabled": false,
    "score": 0.0,
    "payload": {
      "artifact": {
        "question": {
          "type": "TEXT",
          "content": "What was total revenue last month?"
        },
        "few_shot": {
          "type": "SQL",
          "content": "SELECT COALESCE(SUM(total_amount), 0) FROM sales.orders WHERE created_at >= date_trunc('month', now()) - interval '1 month' AND created_at < date_trunc('month', now())"
        }
      }
    },
    "entity_type": "few_shot",
    "source_count": 0,
    "target_count": 0,
    "created_at": "2026-09-21T09:26:38.417Z",
    "updated_at": "2026-09-22T03:05:12.630Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.