Microsoft LUIS:无法为 datetimeV2 实体设置时区 (datetimeReference)

Microsoft LUIS: unable to set time zone (datetimeReference) for datetimeV2 entities

我正在使用 V3 API 从 LUIS 端点获取预测,我需要一种方法来告诉 LUIS 我的时区,以便相对时间表达式(例如 "in the past two hours"、"in 10 minutes") 由 datetimeV2 实体正确解析。

如果我将 V2 API 与 timezoneOffset 选项一起使用,一切都会完美运行,但我无法使 V3 API 使用新选项 datetimeReference(应该替换 timezoneOffset) .实际上,我什至不知道应该为 datetimeReference 设置哪个值(整数?日期时间?)。

这是我对 Python 的尝试。谁能告诉我有什么问题吗?

from datetime import datetime
import requests

appId           = # my app id
subscriptionKey = # my subscription key

query = "tra 10 minuti" # = "in 10 minutes" (my app speaks Italian)

# ATTEMPT 1
# based on https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-concept-data-alteration?tabs=V2#change-time-zone-of-prebuilt-datetimev2-entity,
# assuming it works the same way as timezoneOffset
endpoint = 'https://westeurope.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/{appId}/slots/staging/predict?datetimeReference=120&subscription-key={subscriptionKey}&query={query}'
endpoint = endpoint.format(appId = appId, subscriptionKey = subscriptionKey, query = query)

response = requests.get(endpoint)

# ATTEMPT 2
# according to https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-migration-api-v3
endpoint = 'https://westeurope.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/{appId}/slots/staging/predict?'
endpoint = endpoint.format(appId = appId)

json = {
    "query" : query,
    "options":{
        "datetimeReference": datetime.now().strftime("%Y-%m-%dT%H:%M:%S"), # e.g. "2020-05-07T13:54:33". Not clear if that's what it wants
        "preferExternalEntities": True
    },
    "externalEntities":[],
    "dynamicLists":[]
}

response = requests.post(endpoint, json, headers = {'Ocp-Apim-Subscription-Key' : subscriptionKey})

更新:在 ATTEMPT 2 中发送请求的正确方式是

response = requests.post(endpoint, json = json, headers = {'Ocp-Apim-Subscription-Key' : subscriptionKey})

如您所见,您的 JSON 应该放在 json 参数中而不是 data 参数中:

response = requests.post(endpoint, json = json, headers = {'Ocp-Apim-Subscription-Key' : subscriptionKey})