使用DialogFlow detectintent无法正常工作

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

i使用DialogFlow v2(并尝试使用v2Beta1),使用python中的SDK,但问题是detectIntent方法无法识别查询输入中的参数。

所以,寻找解决方案,我使用简单的cUrl调用重新创建了问题。

下一个是创建EntityType的cUrl:

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://dialogflow.googleapis.com/v2beta1/projects/myproject_id/agent/entityTypes?languageCode=es" \
--data "{
    'displayName': 'customer',
    'kind': 'KIND_MAP',
    'autoExpansionMode': 'AUTO_EXPANSION_MODE_DEFAULT',
    'entities': [
        {
            'value': 'one',
            'synonyms': [
                'one', 'uno'
            ]
        },
        {
            'value': 'two',
            'synonyms': [
                'two', 'dos'
            ]
        }
    ],
    'enableFuzzyExtraction': true
}"

效果很好,并创建了EntityType。

现在,创建意图:

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://dialogflow.googleapis.com/v2beta1/projects/myproject_id/agent/intents" \
--data "{
    'displayName': 'ExampleIntent',
    'priority': 500000,
    'mlDisabled': false,
    'trainingPhrases': [
        {
            'type': 'EXAMPLE',
            'parts': [
                {
                    'text': 'start '
                },
                {
                    'text': 'one',
                    'alias': 'customer',
                    'entityType': '@customer',
                    'userDefined': true
                }
            ]
        },
        {
            'type': 'EXAMPLE',
            'parts': [
                {
                    'text': 'begin '
                },
                {
                    'text': 'one',
                    'alias': 'customer',
                    'entityType': '@customer',
                    'userDefined': true
                }
            ]
        },
        {
            'type': 'EXAMPLE',
            'parts': [
                {
                    'text': 'do '
                },
                {
                    'text': 'one',
                    'alias': 'customer',
                    'entityType': '@customer',
                    'userDefined': true
                }
            ]
        }
    ],
    'action': 'start',
    'messages': [
        {
            'text': {
                'text': [
                    'Hi'
                ]
            }
        }
    ],
}"

也可以。

现在,我尝试检测意图:

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://dialogflow.googleapis.com/v2beta1/projects/myproject_id/agent/sessions/0:detectIntent" \
    --data "{
        'queryInput': {
            'text': {
                'text': 'do one',
                'languageCode': 'es'
            }
        }
    }"

响应没有参数:

{
"responseId": "de68c5f5-6aa9-4716-ac22-626a22fc5d43-b81332aa",
"queryResult": {
    "queryText": "do one",
    "action": "start",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Hi",
    "fulfillmentMessages": [
    {
        "text": {
        "text": [
            "Hi"
        ]
        }
    }
    ],
    "intent": {
    "name": "projects/myproject_id/agent/intents/20ab36d6-e8c8-40d6-87dc-78a61e2de600",
    "displayName": "ExampleIntent"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "es"
}
}

我尝试训练:

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://dialogflow.googleapis.com/v2beta1/projects/myproject_id/agent:train"

结果相同。

但是,如果我转到Web控制台,请输入意图并单击保存按钮... detectIntent开始起作用。

{
"responseId": "45c919dc-677d-4ae4-8572-588955cd5414-b81332aa",
"queryResult": {
    "queryText": "do one",
    "action": "start",
    "parameters": {
    "customer": [
        "one"
    ]
    },
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Hi",
    "fulfillmentMessages": [
    {
        "text": {
        "text": [
            "Hi"
        ]
        }
    }
    ],
    "intent": {
    "name": "projects/myproject_id/agent/intents/20ab36d6-e8c8-40d6-87dc-78a61e2de600",
    "displayName": "ExampleIntent"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "es"
}
}

我想念什么?

感谢任何线索使这项工作有效。

nlp dialogflow agent
1个回答
0
投票

嗯...经过一些研究,我发现了问题,我在createIntent中缺少parameters参数:

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://dialogflow.googleapis.com/v2beta1/projects/myproject_id/agent/intents" \
--data "{
    'displayName': 'ExampleIntent',
    'priority': 500000,
    'mlDisabled': false,
    'parameters': [
        {
            'displayName': 'customer',
            'entityTypeDisplayName': '@customer',
            'value': '$customer'
        }
    ],
    'trainingPhrases': [
        {
© www.soinside.com 2019 - 2024. All rights reserved.