在dialogflow中发送批量创建实体请求时遇到困难。

问题描述 投票:0回答:1

我定义了以下功能。目的是用对话流客户端进行批量创建实体请求。我在使用这个方法后,发了很多个测试都没有很好的扩展。

问题似乎出在定义EntityType的那一行。似乎 "entityType "是无效的,但这是我正在使用的dialogflow v2文档中的内容。

有什么办法可以解决这个问题吗?

def create_batch_entity_types(self):
    client = self.get_entity_client()
    print(DialogFlowClient.batch_list)

    EntityType = {
        "entityTypes": DialogFlowClient.batch_list
    }

    response = client.batch_update_entity_types(parent=AGENT_PATH, entity_type_batch_inline=EntityType)

    def callback(operation_future):
        # Handle result.
        result = operation_future.result()
        print(result)

    response.add_done_callback(callback)

运行函数后,我收到了这个错误

Traceback (most recent call last):
  File "df_client.py", line 540, in <module>
    create_entity_types_from_database()
  File "df_client.py", line 426, in create_entity_types_from_database
    df.create_batch_entity_types()
  File "/Users/andrewflorial/Documents/PROJECTS/curlbot/dialogflow/dialogflow_accessor.py", line 99, in create_batch_entity_types
    response = client.batch_update_entity_types(parent=AGENT_PATH, entity_type_batch_inline=EntityType)
  File "/Users/andrewflorial/Documents/PROJECTS/curlbot/venv/lib/python3.7/site-packages/dialogflow_v2/gapic/entity_types_client.py", line 767, in batch_update_entity_types
    update_mask=update_mask,
ValueError: Protocol message EntityTypeBatch has no "entityTypes" field.
python-3.x dialogflow
1个回答
0
投票

参数为 entity_type_batch_inline 必定与 EntityTypeBatch.

看看那个类型是怎样的。https:/dialogflow-python-client-v2.readthedocs.ioenlatestgapicv2types.html#dialogflow_v2.type.EntityTypeBatch。

它必须有 entity_types 场,不 entityTypes.

© www.soinside.com 2019 - 2024. All rights reserved.