首页 > 解决方案 > Rasa:创建自定义通道以通过 API 训练数据

问题描述

我现在有一个 rasa 应用程序,它运行得非常好。但是,我想使用 API(可能使用自定义通道)为我的聊天机器人训练更多数据。具体来说,我将通过 API 发送如下文件:nlu、story、domain,并将替换旧的数据文件。然后再次调用 API 激活 train 命令。

现在我有一个这样的自定义频道:

class MyBOT(InputChannel):
    def name(cls) -> Text:
        """Name of your custom channel."""
        return "mybot"

    def blueprint(
        self, on_new_message: Callable[[UserMessage], Awaitable[None]]
    ) -> Blueprint:

        custom_webhook = Blueprint(
            "custom_webhook_{}".format(type(self).__name__),
            inspect.getmodule(self).__name__,
        )

        @custom_webhook.route("/", methods=["GET"])
        async def health(request: Request) -> HTTPResponse:
            return response.json({"status": "ok"})

        @custom_webhook.route("/webhook", methods=["POST"])
        async def receive(request: Request) -> HTTPResponse:
            ...
            return response.json(collector.messages)
        return custom_webhook

        @custom_webhook.route("/custom/train", methods=["POST"])
        async def health(request: Request) -> HTTPResponse:
            # This is where I want to receive training data files from client side and replace existing data files.
            return response.json({"status": "ok"})

但 rasa 似乎不知道我的 API /custom/train

有人有什么想法吗?

还是有另一种方法可以调用 API 来触发 rasa 命令?请帮我。

标签: rasa

解决方案


推荐阅读