我们正在尝试使用Azure documentation作为参考,使用Luis框架和Python SDK创建一个聊天机器人。我们已经能够使用它们添加Intent,实体和预建实体。这些更改将显示在门户上,以确认添加。
但是添加话语的代码未显示在门户上或未在终端上列出。
def create_utterance(intent,utterance,*labels):
"""
Add an example LUIS utterance from utterance text and a list of
labels. Each label is a 2-tuple containing a label name and the
text within the utterance that represents that label.
Utterances apply to a specific intent,which must be specified.
"""
text = utterance.lower()
def label(name,value):
value = value.lower()
start = text.index(value)
return dict(entity_name=name,start_char_index=start,end_char_index=start + len(value),role=None)
return dict(text=text,intent_name=intent,entity_labels=[label(n,v) for (n,v) in labels])
utterances = [create_utterance("FindFlights","find flights in economy to Madrid",("Flight","economy to Madrid"),("Location","Madrid"),("Class","economy")),create_utterance("FindFlights","find flights to London in first class","London in first class"),"London"),"first")),"find flights from seattle to London in first class","flights from seattle to London in first class"),"Seattle"),"first"))]
client.examples.batch(appId,appVersion,utterances,raw=True)
client.examples.list(appId,appVersion)
此代码不返回任何错误,但也未列出话语。