找不到 EntityType - SessionEntityType 名称由会话名称和 EntityType.display_name 组成

Cannot find the EntityType - SessionEntityType name is composed of Session name and EntityType.display_name

即使我在 SessionEntityTypes 中提供了正确的信息,我仍然收到以下错误。尝试了 REST 和 Python 选项,请让我知道集成中是否缺少任何内容。

请求 HTTP 方法:POST

{
  "name": "projects/{projectId}/locations/asia-northeast1/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types",
  "entities": [
    {
      "value": "APPLE_KEY",
      "synonyms": [
        "apple",
        "green apple",
        "crabapple"
      ]
    },
    {
      "value": "ORANGE_KEY",
      "synonyms": [
        "orange"
      ]
    }
  ],
  "entityOverrideMode": "ENTITY_OVERRIDE_MODE_SUPPLEMENT"
}

回应

{
  "error": {
    "code": 400,
    "message": "com.google.apps.framework.request.BadRequestException: Cannot find the EntityType of SessionEntityType 'projects/{projectId}/locations/asia-northeast1/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types'. Please note that the SessionEntityType name is composed of Session name and EntityType.display_name.",
    "status": "INVALID_ARGUMENT"
  }
}

Google 试试这个 API

我将在这里解释一下这个问题,以确保我没有遗漏任何细节:您正在尝试使用 “Try this API” tool 创建一个 sessionEntity,这是 Create (POST ) 版本 2.

问题是您在请求正文中传递的“名称”没有有效格式 for API v2

您使用的名称格式是:
projects/<ProjectID>/locations/<LocationID>/agent/environments/<EnvironmentID>/users/<UserID>/sessions/<SessionID>/entityTypes/<EntityTypeDisplayName>

下面我列出了 v2 的两种有效名称格式,如您所见,不需要 locations/

projects/<Project ID>/agent/sessions/<Session ID>/entityTypes/<Entity Type Display Name>

projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/entityTypes/<Entity Type Display Name>

下面的请求正文按预期工作,我在同一个 “Try this API” tool:

中对其进行了测试
{
"name":"projects/{projectId}/agent/environments/draft/users/-/sessions/c973fe-e44-9b5-34e-b404439b7/entityTypes/speciality_types",
  "entities":[
     {
        "value":"APPLE_KEY",
        "synonyms":[
           "apple",
           "green apple",
           "crabapple"
        ]
     },
     {
        "value":"ORANGE_KEY",
        "synonyms":[
           "orange"
        ]
     }
  ],
  "entityOverrideMode":"ENTITY_OVERRIDE_MODE_SUPPLEMENT"
}