View a markdown version of this page

開始使用 - Amazon Bedrock AgentCore

開始使用

本主題提供建立end-to-end工作流程。

資料集結構描述

每個資料集schemaType都會在建立時宣告 。AgentCore 會在接受每個範例之前,針對宣告的結構描述進行驗證。支援兩種結構描述類型:

  • AGENTCORE_EVALUATION_PREDEFINED_V1 — 用於針對預先編寫的對話輪換測試客服人員。必要欄位:scenario_idturns(非空白清單;每個回合必須包含 input)。

  • AGENTCORE_EVALUATION_SIMULATED_V1 — 用於產生合成對話。必要欄位:scenario_idactor_profile(具有必要 context和 的物件goal)、input

如需完整的結構描述欄位定義、範例和 Ground Truth 映射,請參閱資料集結構描述

端對端工作流程

下列範例示範完整的資料集生命週期:建立、新增範例、列出範例、發佈版本和清除。

範例
AgentCore CLI
  1. # 1. Create dataset agentcore add dataset --name my_eval_dataset \ --schema-type AGENTCORE_EVALUATION_PREDEFINED_V1 # 2. Add your scenarios to the JSONL file # File: agentcore/datasets/my_eval_dataset.jsonl # 3. Deploy to create the dataset and sync examples agentcore deploy # 4. Publish version 1 agentcore dataset publish-version --name my_eval_dataset # 5. Check status (shows versions and example count) agentcore status --type dataset # 6. Download a published version to local file agentcore dataset download --name my_eval_dataset --version 1 # 7. Cleanup agentcore remove dataset --name my_eval_dataset agentcore deploy
AgentCore SDK
  1. from bedrock_agentcore.evaluation import DatasetClient client = DatasetClient(region_name="us-west-2") # 1. Create dataset (polls until ACTIVE) ds = client.create_dataset_and_wait( datasetName="my_eval_dataset", schemaType="AGENTCORE_EVALUATION_PREDEFINED_V1", source={ "inlineExamples": { "examples": [ { "scenario_id": "TC-01", "turns": [{"input": "What is my balance?", "expected_response": "Your balance is $50."}], "assertions": ["Response includes a dollar amount"], } ] } }, ) dataset_id = ds["datasetId"] print(f"Created: {dataset_id}, status={ds['status']}") # 2. Add more examples ds = client.add_examples_and_wait( datasetId=dataset_id, source={ "inlineExamples": { "examples": [ {"scenario_id": "TC-02", "turns": [{"input": "Transfer $100", "expected_response": "Transfer complete."}]} ] } }, ) print(f"Example count: {ds['exampleCount']}") # 3. List examples resp = client.list_dataset_examples(datasetId=dataset_id) for example in resp["examples"]: print(f" {example['exampleId']}: {example['scenario_id']}") # 4. Publish version 1 ds = client.create_dataset_version_and_wait(datasetId=dataset_id) print(f"Published, draftStatus: {ds.get('draftStatus')}") # 5. List versions resp = client.list_dataset_versions(datasetId=dataset_id) for v in resp["versions"]: print(f" Version {v['datasetVersion']}: {v['exampleCount']} examples") # 6. Cleanup client.delete_dataset_and_wait(datasetId=dataset_id)