

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 檢視代理程式的資訊
<a name="agents-view"></a>

建立代理程式後，您可以根據需要檢視或更新其組態。組態適用於工作草稿。如果您不再需要某個代理程式，可以將其刪除。

若要了解如何檢視代理程式的相關資訊，請選擇您偏好方法的標籤，然後遵循下列步驟：

------
#### [ Console ]

**檢視代理程式的詳細資訊**

1. 使用具有 Amazon Bedrock 主控台使用許可的 IAM 身分登入AWS 管理主控台。接著，開啟位於 [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock) 的 Amazon Bedrock 主控台。

1. 從左側導覽窗格選取**代理程式**。接著，在**代理程式**區段中選擇代理程式。

1. 在代理程式詳細資訊頁面上，您可以看到套用至所有版本的代理程式、相關標籤及其版本與別名功能的組態。

1. 若要查看代理程式工作草稿的詳細資訊，請選擇**在代理程式建置器中編輯**。

------
#### [ API ]

若要取得代理程式的相關資訊，請使用 [Amazon Bedrock 代理程式建置時期端點](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-bt)傳送 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_GetAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_GetAgent.html) 請求，並指定 `agentId`。

```
    def get_agent(self, agent_id, log_error=True):
        """
        Gets information about an agent.

        :param agent_id: The unique identifier of the agent.
        :param log_error: Whether to log any errors that occur when getting the agent.
                          If True, errors will be logged to the logger. If False, errors
                          will still be raised, but not logged.
        :return: The information about the requested agent.
        """

        try:
            response = self.client.get_agent(agentId=agent_id)
            agent = response["agent"]
        except ClientError as e:
            if log_error:
                logger.error(f"Couldn't get agent {agent_id}. {e}")
            raise
        else:
            return agent
```

如需詳細資訊，請參閱 [Hello Amazon Bedrock 代理人](bedrock-agent_example_bedrock-agent_Hello_section.md)。

若要列出代理程式的相關資訊，請使用 [Amazon Bedrock 代理程式建置時期端點](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-bt)傳送 [ListAgents](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ListAgents.html) 請求。[查看程式碼範例](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-agent_example_bedrock-agent_ListAgents_section.html)。您可以指定以下選用參數：


****  

| 欄位 | 簡短描述 | 
| --- | --- | 
| maxResults | 回應傳回的結果數目上限。 | 
| nextToken | 如果結果多於您在 maxResults 欄位中指定的數字，則回應會傳回 nextToken 值。若要查看下一批結果，請在另一個請求中傳送 nextToken 值。 | 

若要列出代理程式的所有標籤，請使用 [Amazon Bedrock 代理程式建置時期端點](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-bt)傳送 [ListTagsForResource](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_ListTagsForResource.html) 請求，並包含代理程式的 Amazon Resource Name (ARN)。

```
    def list_agents(self):
        """
        List the available Amazon Bedrock Agents.

        :return: The list of available bedrock agents.
        """

        try:
            all_agents = []

            paginator = self.client.get_paginator("list_agents")
            for page in paginator.paginate(PaginationConfig={"PageSize": 10}):
                all_agents.extend(page["agentSummaries"])

        except ClientError as e:
            logger.error(f"Couldn't list agents. {e}")
            raise
        else:
            return all_agents
```

如需詳細資訊，請參閱 [Hello Amazon Bedrock 代理人](bedrock-agent_example_bedrock-agent_Hello_section.md)。

------