本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
藍圖操作 CLI
本指南涵蓋透過 AWS Command Line Interface (CLI) for Amazon BedrockData Automation (BDA) 提供的藍圖操作。
建立藍圖
藍圖定義您要從文件、影像、音訊或影片檔案擷取之資料的結構和屬性。使用 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" } } }'
完成參數參考
下表顯示 create-blueprint 命令的所有可用參數:
| 參數 | 必要 | 預設 | Description |
|---|---|---|---|
--blueprint-name |
是 | N/A | 藍圖的名稱 |
--type |
是 | N/A | 內容類型 (IMAGE、DOCUMENT、AUDIO、VIDEO) |
--blueprint-stage |
否 | LIVE | 藍圖階段 (DEVELOPMENT 或 LIVE) |
--schema |
是 | N/A | 定義藍圖結構的 JSON 結構描述 |
--client-token |
否 | 自動產生 | 請求冪等性的唯一識別符 |
檢視藍圖組態
列出所有藍圖
使用 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"
編輯藍圖規格
更新藍圖設定
若要修改現有藍圖的結構描述或屬性,請使用 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-stage 選項。
語法
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)"
管理藍圖標籤
標籤可協助使用者組織和分類藍圖,以簡化管理。
新增標籤
新增標籤,將中繼資料套用至您的藍圖。
語法
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)"
刪除藍圖
刪除整個藍圖
使用 delete-blueprint 命令永久移除藍圖及其所有版本。
語法
aws bedrock-data-automation delete-blueprint \ --blueprint-arn "Amazon Resource Name (ARN)"
注意:此命令會永久刪除藍圖,且無法復原。
重要:您無法刪除任何專案目前正在使用的藍圖。刪除前,請先確定任何專案的自訂輸出組態中未參考該藍圖。
藍圖最佳化
調用藍圖最佳化
啟動非同步藍圖最佳化任務,以改善每個藍圖欄位的藍圖說明和結果準確性。
語法
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"
檢查藍圖最佳化狀態
監控藍圖最佳化任務的進度和結果。
語法
aws bedrock-data-automation get-blueprint-optimization-status \ --invocation-arn "arn:aws:bedrock:<region>:<account_id>:blueprint-optimization-invocation/opt-12345abcdef"
使用此命令來追蹤最佳化任務狀態。回應包含目前狀態 (建立、InProgress、成功、ServiceError 或 ClientError),以及完成時的輸出組態詳細資訊。
複製藍圖階段
將藍圖從一個階段複製到另一個階段
語法
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) 階段之前,已在來源階段經過徹底測試。此操作難以復原。