3

私はラサチャットボットに取り組んでいます。チャットボットをトレーニングするために、すべてのトレーニング データをnlu.mdファイルに追加しました。ストーリーをstories.mdファイルに追加しました。ファイルを構成しdomain.yml、ユーザーが特定の質問をしたときにボットが実行するカスタム アクションもいくつか作成しました。次に、rasa train コマンドを使用してチャットボットをトレーニングしました。これにより、models フォルダー内に zip ファイルが作成されました。

次のコマンドでNLUサーバーを起動しました

rasa run --enable-api -m models/nlu-20190919-171124.tar.gz

フロント エンドでは、django を使用してチャットボット用の Web アプリケーションを作成しています。

これはindex.htmlファイルです

<form class="" action="" method="post">
    {% csrf_token %}
    <input type="text" name="message">
    <button type="submit" name="button">Send</button>
</form>

ユーザーが入力領域にメッセージを入力して送信をクリックすると、このビューが実行されます

def index(request):
    if request.method == 'POST':
        user_message = request.POST['message']
        response = requests.get("http://localhost:5005/model/parse",params={"q":user_message})
        print(response)
        return redirect('home')

    else:
        return render(request, 'index.html')

しかし、送信ボタンをクリックすると、405 error. これは、NLU サーバーからの完全なエラー メッセージです。

Traceback (most recent call last):
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/app.py", line 893, in handle_request
    handler, args, kwargs, uri = self.router.get(request)
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/router.py", line 407, in get
    return self._get(request.path, request.method, "")
  File "/Users/sashaanksekar/anaconda3/lib/python3.7/site-packages/sanic/router.py", line 446, in _get
    raise method_not_supported
sanic.exceptions.MethodNotSupported: Method GET not allowed for URL /model/parse

これは、私の django サーバーからのメッセージです。

<Response [405]>

私が間違っているのかわかりません。rasa documentationに示されている手順に従っています。

4

1 に答える 1