我希望在我的QnA python机器人中使用一些AdaptiveCard。 我使用botbuilder repo的示例代码:
from botbuilder.ai.qna import QnAMaker, QnAMakerEndpoint
from botbuilder.core import ActivityHandler, MessageFactory, TurnContext
from botbuilder.schema import ChannelAccount
from config import DefaultConfig
class QnABot(ActivityHandler):
def __init__(self, config: DefaultConfig):
self.qna_maker = QnAMaker(
QnAMakerEndpoint(
knowledge_base_id=config.QNA_KNOWLEDGEBASE_ID,
endpoint_key=config.QNA_ENDPOINT_KEY,
host=config.QNA_ENDPOINT_HOST,
)
)
async def on_members_added_activity(
self, members_added: [ChannelAccount], turn_context: TurnContext
):
for member in members_added:
if member.id != turn_context.activity.recipient.id:
await turn_context.send_activity(
"Hallo!"
)
async def on_message_activity(self, turn_context: TurnContext):
# The actual call to the QnA Maker service.
response = await self.qna_maker.get_answers(turn_context)
if response and len(response) > 0:
await turn_context.send_activity(MessageFactory.text(response[0].answer))
else:
await turn_context.send_activity("Ich kann nicht")
那么,我必须如何配置qna_maker.get_answers()和qna知识库中的行,以便使用AdaptiveCards作为问题的答案
UPD
我希望返回卡片内的答案:
card = HeroCard(
title="Answer Title here",
subtitle="short answer",
buttons=[task_module_action], #task_module_action - button which have to show long variant of answer
)
目前没有回答
相关问题 更多 >
编程相关推荐