

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 蓝图操作 CLI
<a name="bda-blueprint-operations"></a>

本指南涵盖了通过 AWS Amazon Bedrock 数据自动化命令行接口 (CLI) (BDA) 提供的蓝图操作。

## 创建蓝图
<a name="create-blueprints-cli"></a>

蓝图定义了要从文档、图像、音频或视频文件中提取的数据的结构和属性。使用 create-blueprint 命令定义新的蓝图。

以下命令创建一个专为从护照图像中提取数据而定制的新蓝图。

**语法**

```
aws bedrock-data-automation create-blueprint \
      --blueprint-name "passport-blueprint" \
      --type "IMAGE" \
      --blueprint-stage "DEVELOPMENT" \
      --schema '{
        "class": "Passport",
        "description": "Blueprint for processing passport images",
        "properties": {
          "passport_number": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport identification number"
          },
          "full_name": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The full name of the passport holder"
          },
          "expiration_date": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport expiration date"
          }
        }
      }'
```

## 完整参数参考
<a name="create-blueprint-parameters"></a>

下表显示 `create-blueprint` 命令的所有可用参数。


**create-blueprint 的参数**  

| 参数 | 必需 | 默认值 | Description | 
| --- | --- | --- | --- | 
| --blueprint-name | 是 | 不适用 | 蓝图的名称 | 
| --type | 是 | 不适用 | 内容类型（IMAGE、DOCUMENT、AUDIO、VIDEO） | 
| --blueprint-stage | 否 | 实时 | 蓝图的阶段（DEVELOPMENT 或 LIVE） | 
| --schema | 是 | 不适用 | 定义蓝图结构的 JSON 架构 | 
| --client-token | 否 | 自动生成 | 请求幂等性的唯一标识符 | 

## 查看蓝图配置
<a name="view-blueprint-cli"></a>

**列出所有蓝图**

使用 list-blueprints 命令检索与您账户关联的所有蓝图的列表。

**语法**

```
aws bedrock-data-automation list-blueprints
```

**查看蓝图详细信息**

要查看有关特定蓝图的详细信息，包括其架构和配置，请使用 get-blueprint 命令。

**语法**

```
aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)"
```

**检查特定版本**

使用具有版本控制的蓝图时，通过 get-blueprint 命令和 --blueprint-version 选项来查看特定版本。

**语法**

```
      aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-version "version-number"
```

**检查特定阶段**

要查看处于 DEVELOPMENT 或 LIVE 阶段的蓝图，请使用：

```
      aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-stage "LIVE"
```

## 编辑蓝图规范
<a name="edit-blueprint-cli"></a>

**更新蓝图设置**

要修改现有蓝图的架构或属性，请使用 update-blueprint 命令。

**语法**

```
aws bedrock-data-automation update-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --schema '{
        "class": "Passport",
        "description": "Updated blueprint for processing passport images",
        "properties": {
          "passport_number": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport identification number"
          },
          "full_name": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The full name of the passport holder"
          },
          "expiration_date": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport expiration date"
          }
        }
      }'
```

**注意：**更新蓝图时，即使对于您没有进行更改的字段，也必须提供完整的架构。

**提升为 LIVE**

要将蓝图从 DEVELOPMENT 阶段转到 LIVE 阶段用于生产，请使用 update-blueprint 命令和 --blueprint-阶段选项。

**语法**

```
aws bedrock-data-automation update-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-stage "LIVE"
```

**蓝图版本控制**

在使用 create-blueprint-version命令进行重大更改之前，创建蓝图的新版本以保留其当前状态。

**语法**

```
aws bedrock-data-automation create-blueprint-version \
      --blueprint-arn "Amazon Resource Name (ARN)"
```

## 管理蓝图标签
<a name="tag-management-cli"></a>

标签可帮助用户整理和分类蓝图，从而简化管理。

**添加标签**

通过添加标签将元数据应用到蓝图。

**语法**

```
aws bedrock-data-automation tag-resource \
      --resource-arn "Amazon Resource Name (ARN)" \
      --tags '{"Department":"Finance","Project":"PassportProcessing"}'
```

**移除标签**

使用 untag-resource 命令从蓝图中移除特定标签。

**语法**

```
aws bedrock-data-automation untag-resource \
      --resource-arn "Amazon Resource Name (ARN)" \
      --tag-keys '["Department","Project"]'
```

**查看标签**

使用 list-tags-for-resource命令列出与您的蓝图关联的所有标签。

**语法**

```
aws bedrock-data-automation list-tags-for-resource \
      --resource-arn "Amazon Resource Name (ARN)"
```

## 删除蓝图
<a name="delete-blueprint-cli"></a>

**删除整个蓝图**

使用 delete-blueprint 命令永久删除蓝图及其所有版本。

**语法**

```
aws bedrock-data-automation delete-blueprint \
          --blueprint-arn "Amazon Resource Name (ARN)"
```

**注意：**此命令将永久删除蓝图且无法将其恢复。

**重要提示：**您不能删除当前由任何项目使用的蓝图。删除蓝图之前，请确保该蓝图未在任何项目的自定义输出配置中引用。

## 蓝图优化
<a name="blueprint-optimization-cli"></a>

### 调用蓝图优化
<a name="invoking-blueprint-optimization"></a>

启动异步蓝图优化作业，以改进蓝图对每个蓝图字段的指令和结果的准确性。

**语法**

```
aws bedrock-data-automation invoke-blueprint-optimization-async \
    --blueprint blueprintArn="arn:aws:bedrock:<region>:<account_id>:blueprint/<blueprint_id>",stage="DEVELOPMENT" \
    --samples '[
        {
            "assetS3Object": {
                "s3Uri": "s3://my-optimization-bucket/samples/document1.pdf"
            },
            "groundTruthS3Object": {
                "s3Uri": "s3://my-optimization-bucket/ground-truth/document1-expected.json"
            }
        }
    ]' \
    --output-configuration s3Object='{s3Uri="s3://my-optimization-bucket/results/optimization-output"}' \
    --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

### 检查蓝图优化状态
<a name="checking-blueprint-optimization-status"></a>

监控蓝图优化作业的进度和结果。

**语法**

```
aws bedrock-data-automation get-blueprint-optimization-status \
    --invocation-arn "arn:aws:bedrock:<region>:<account_id>:blueprint-optimization-invocation/opt-12345abcdef"
```

使用此命令跟踪优化作业的状态。完成后，响应包括当前状态（已创建 InProgress ServiceError、、成功或 ClientError）和输出配置详细信息。

### 复制蓝图阶段
<a name="copying-blueprint-stages"></a>

将蓝图从一个关卡复制到另一个阶段

**语法**

```
aws bedrock-data-automation copy-blueprint-stage \
    --blueprint-arn "arn:aws:bedrock:<region>:<account_id>:blueprint/<blueprint_id>" \
    --source-stage "DEVELOPMENT" \
    --target-stage "LIVE"
```

**注意：**此命令将整个蓝图配置从源阶段复制到目标阶段，覆盖目标阶段中的任何现有配置。

**重要：**在复制到生产 (LIVE) 阶段之前，请确保蓝图在源代码阶段经过全面测试。无法方便地撤消该操作。