我在Qna maker中添加了多圈提示。它将超链接呈现为QnAmaker中的按钮,而不是webchat上的按钮。有没有办法在webchat频道上渲染它们
注意:我找到了解决这个问题的nodejs解决方案,但我正在寻找python方法。
这是我目前的代码:
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(
"Hi I am your Engineering Bot! Ask me a question and I will try "
"to answer it."
)
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("No QnA Maker answers were found.")
谢谢
Bot框架目前还没有Python中的“Multi-Turn QnA”示例。这里有一个正在处理的示例:
https://github.com/microsoft/BotBuilder-Samples/tree/trboehre/python-49.qnamaker-all-features/samples/python/49.qnamaker-all-features
由于pythonsdk正在积极开发中,库here可能没有正确的方法来返回问题是否有后续提示(也称为multi-turn)。请密切关注Python SDK,以便进行进一步的工作
相关问题 更多 >
编程相关推荐