是否在网聊中添加多回合提示?

问题描述 投票:1回答:1

我向Qna制造商添加了多转弯提示。它将超链接呈现为QnAmaker中的按钮,但不呈现为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.")

谢谢!

python botframework qnamaker
1个回答
0
投票

Bot Framework目前在Python中尚无有效的'Multi-Turn QnA'示例。这里有一个示例正在处理:

https://github.com/microsoft/BotBuilder-Samples/tree/trboehre/python-49.qnamaker-all-features/samples/python/49.qnamaker-all-features

由于正在积极地使用Python SDK,所以库here可能没有正确的方法来返回问题是否具有后续提示(又称多回合)。请密切注意Python SDK的进一步工作!

© www.soinside.com 2019 - 2024. All rights reserved.