def getBodyTemplate1(self, content): template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_token(self.BODY_TEMPLATE1_TOKEN) renderTemplate = RenderTemplate(template) return renderTemplate
def couplet_intent(self): self.wait_answer() zodiac = self.get_slots('zodiac') couplet_size = self.get_slots('couplet_size') word_size = self.get_slots('word_size') couplet_content = self.get_slots('sys.wildcard-slot') couplet = self.get_slots('couplet') foot = u'你可以对我说:小度小度,' + random.choice(self.common_dialog) if couplet: couplet_list, find_content = self.utils.get_couplet( zodiac, couplet_content, word_size, couplet_size) if couplet_content and not find_content: head = u'没有找到包含%s的对联,为您推荐:\n' else: head = '' content, outputSpeech = self.get_ssml_content( couplet_list, head, foot) else: content = foot outputSpeech = content template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.BACKGROUD_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate, outputSpeech)
def searchRequest(self): self.ask('deviceName') # card = TextCard('您要查找什么智能设备呢? 比如"查找我的空调"') # card.addCueWords("百度") # card.addCueWords("百度") # card.addCueWords("百度") # card.setAnchor("http://www.baidu.com", "百度") # renderTemplate = RenderTemplate() bodyTemplate = BodyTemplate1() bodyTemplate.set_token('token') bodyTemplate.set_title('托尔斯泰的格言') bodyTemplate.set_background_image( 'https://skillstore.cdn.bcebos.com/icon/100/c709eed1-c07a-be4a-b242-0b0d8b777041.jpg' ) bodyTemplate.set_plaintext_content('拖尔斯泰-理想的书籍是智慧的钥匙') renderTemplate = RenderTemplate(bodyTemplate) # renderTemplate.setTemplate(bodyTemplate) renderTemplate.set_token("renderTemplate") return { 'directives': [renderTemplate], 'outputSpeech': '<speak>您要查找什么智能设备呢? 比如"查找我的空调"</speak>' }
def getTemplate(self, content): template = BodyTemplate1() template.set_title('智能导购') template.set_plain_text_content(content) template.set_token('0c71de96-15d2-4e79-b97e-e52cec25c254') renderTemplate = RenderTemplate(template) return renderTemplate
def getTemplate(self, content, title = ""): template = BodyTemplate1() template.set_title(title) template.set_plain_text_content(content) #template.set_background_image('https://gss0.bdstatic.com/-4o3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268/sign=644d464dab18972ba33a07ccdecc7b9d/cefc1e178a82b901fecbb96a738da9773912ef01.jpg') template.set_token('e9f72c66-78da-3236-5222-d460e5de2509') #renderTemplate = RenderTemplate(template) return template
def getTemplate(self, content): template = BodyTemplate1() template.set_title('查询个税') template.set_plain_text_content(content) template.set_background_image('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1532350870263&di=c93edb2fb9a3cfe7a632acc46cceba62&imgtype=0&src=http%3A%2F%2Ffile25.mafengwo.net%2FM00%2F0A%2FAC%2FwKgB4lMC26CAWsKoAALb5778DWg60.rbook_comment.w1024.jpeg') template.set_token('0c71de96-15d2-4e79-b97e-e52cec25c254') renderTemplate = RenderTemplate(template) return renderTemplate
def askWhichAnimal(self): self.nlu.ask('animal') content = r'请问您想听什么动物的声音呢?' template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate)
def next_step_intent(self): self.wait_answer() couplet_list = self.utils.get_random_couplet() foot = u'你可以对我说' + random.choice(self.common_dialog) content, outputSpeech = self.get_ssml_content(couplet_list, '', foot) template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.BACKGROUD_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate, outputSpeech)
def launch_request(self): """ 打开调用名 """ self.wait_answer() content = '欢迎进入新春对联,您可以这样对我说,猪年的对联' template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.BACKGROUD_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate, content)
def end_request(self): """ 清空状态,结束会话 """ content = r'您得到了想要的春联了吗?推荐您使用技能动物声音,聆听各种萌萌哒的声音哦' self.wait_answer() template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content("") template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate)
def end_request(self): """ 清空状态,结束会话 """ template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(self.WELCOM_TIPS) template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) outputSpeech = r'期待下次与您见面,再见!' stop = Stop() return {'directives': [stop], 'outputSpeech': outputSpeech}
def launch_request(self): """ 打开调用名 """ self.wait_answer() template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(self.WELCOM_TIPS) template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) outputSpeech = r'欢迎聆听动物声音,请告诉我您想听什么动物的叫声呢?' return self.getResponse(outputSpeech, renderTemplate, outputSpeech)
def end_request(self): """ 清空状态,结束会话 """ self.wait_answer() template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(self.WELCOM_TIPS) template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) outputSpeech = r'期待下次与您见面,再见!' return self.getResponse(outputSpeech, renderTemplate, outputSpeech)
def launch_request(self): """ 打开调用名 """ self.wait_answer() template = BodyTemplate1() template.set_title('查询个税') template.set_plain_text_content('欢迎进入查询个税') template.set_background_image('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1532350870263&di=c93edb2fb9a3cfe7a632acc46cceba62&imgtype=0&src=http%3A%2F%2Ffile25.mafengwo.net%2FM00%2F0A%2FAC%2FwKgB4lMC26CAWsKoAALb5778DWg60.rbook_comment.w1024.jpeg') template.set_token('0c71de96-15d2-4e79-b97e-e52cec25c254') renderTemplate = RenderTemplate(template) return { 'directives': [renderTemplate], 'outputSpeech': r'欢迎进入查询个税,请告诉我你所在的城市是哪里呢' }
def launch_request(self): """ 打开调用名 """ self.wait_answer() content = self.WELLCOM_TIPS template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.ICON_URL) template.set_token(self.BODY_TEMPLATE1_TOKEN) renderTemplate = RenderTemplate(template) card = self.getCard(self.WELLCOM_TIPS) card.set_anchor(self.ICON_URL, self.TITLE) return self.getResponse(content, card, renderTemplate)
def launch_request(self): """ 打开调用名 """ self.wait_answer() template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(self.WELCOM_TIPS) template.set_background_image(self.ICON_URL) renderTemplate = RenderTemplate(template) hints = self.getHints() outputSpeech = r'你可以对我说播放猫的叫声?' return self.getResponse(outputSpeech, renderTemplate, hints, outputSpeech)
def ai_dueros_common_default_intent_intent(self): self.wait_answer() query = self.request.get_query() # self.utils.save_user_query(query) couplet_list, find_content = self.utils.get_couplet( None, query, None, 3) foot = u'你可以对我说: 小度小度' + random.choice(self.common_dialog) if couplet_list.__len__() > 0: content, outputSpeech = self.get_ssml_content( couplet_list, '', foot) else: content = foot outputSpeech = content template = BodyTemplate1() template.set_title(self.TITLE) template.set_plain_text_content(content) template.set_background_image(self.BACKGROUD_URL) renderTemplate = RenderTemplate(template) return self.getResponse(content, renderTemplate, outputSpeech)
def launch_request(self): """ 打开调用名 """ self.wait_answer() template = BodyTemplate1() template.set_title('智能导购') template.set_plain_text_content('欢迎进入智能导购') template.set_background_image( 'http://dbp-resource.gz.bcebos.com/ed4f7f94-fee0-cecf-344e-f4792d94406a/ai_guide_icon.png?authorization=bce-auth-v1%2Fa4d81bbd930c41e6857b989362415714%2F2018-09-06T06%3A07%3A01Z%2F-1%2F%2F16927c417355bb40cb810fe87afbcf2634f94a386781003d8ce93090fa036262' ) template.set_token('0c71de96-15d2-4e79-b97e-e52cec25c254') renderTemplate = RenderTemplate(template) card = self.getCard('欢迎进入智能导购') return { 'card': card, 'directives': [renderTemplate], 'outputSpeech': r'欢迎进入智能导购' }
def handle_move_help(self): self.wait_answer() template = BodyTemplate1() template.set_background_image(BG) content = '技能帮助如下:\n' \ '第一:您要先选择查看哪个城市的影讯,比如:"查看北京的"。\n' \ '第二:之后选择查看哪部电影的信息,比如:"查看第一个".\n' \ '第三:您可以查看选中电影的主要演员列表和预告片,比如:"查看演员列表或者播放预告片"\n' \ '第四:如果您想回到列表页面,可以对我说:"返回列表页"\n' template.set_plain_text_content(content) directive = RenderTemplate(template) hint = Hint(['查看北京的']) directives = [] directives.append(hint) directives.append(directive) return { 'directives': directives, 'outputSpeech': content + '您可以在任何时候对我说:"帮助" 来获取帮助信息。现在请您告诉我要查看哪个城市的影讯' }
def setUp(self): self.template = BodyTemplate1() self.template.set_plain_text_content('test') self.template.set_background_image('http://www.baidu.com') self.template.set_token('0c71de96-15d2-4e79-b97e-e52cec25c254')