Я в основном пытаюсь создать чат-бота с помощью Rasa и внедрить его с помощью Flask или, по крайней мере, найти какой-либо метод для внедрения чат-бота на мой сайт навсегда. Мне отчаянно нужна помощь, и я начинаю разочаровываться в использовании Расы на этом этапе. Я потратил слишком много часов, пытаясь просто развернуть чат-бота на моем сайте. В настоящее время все, что я пытаюсь сделать, это внедрить Rasa в localhost: 5000. Я использую веб-сокеты для соединения с Flask, но в принципе не смог добиться прогресса. Вот мой html шаблон
<!doctype html>
<html>
<head>
</head>
<body>
<div id="webchat">
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-0.5.8.js"></script>
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "/get_started",
interval: 1000, // 1000 ms between each message
socketUrl: "http://localhost:5000",
socketPath: "/socket.io/",
title: "SIA",
inputTextFieldHint: "Type a message...",
connectingText: "Waiting for server...",
hideWhenNotConnected: false,
fullScreenMode: true,
profileAvatar: "/static/bot.png",
openLauncherImage: 'myCustomOpenImage.png',
closeLauncherImage: 'myCustomCloseImage.png',
params: {
images: {
dims: {
width: 300,
height: 200,
}
},
storage: "session"
}
})
</script>
</div>
</body>
</html>`
вот мой файл server.py, который подключается к веб-сокету
from rasa_core.channels import SocketIOInput
from rasa_core.agent import Agent
from rasa_core.interpreter import RegexInterpreter
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
from rasa_core.policies import KerasPolicy, MemoizationPolicy
# load your trained agent
interpreter = RasaNLUInterpreter('./models/nlu/profiler/nlu')
agent = Agent.load('./models/dialogue',
interpreter=interpreter,
action_endpoint=EndpointConfig('http://localhost:5055/webhook')
#for action endpoint
)
input_channel = SocketIOInput(
# event name for messages sent from the user
user_message_evt="user_uttered",
# event name for messages sent from the bot
bot_message_evt="bot_uttered",
# socket.io namespace to use for the messages
namespace=None
)
# set serve_forever=True if you want to keep the server running
s = agent.handle_channels([input_channel], 5000, serve_forever=False)
наконец вот мои файлы app.py, который использует Flask
from flask import Flask
from flask import render_template
# creates a Flask application, named app
app = Flask(__name__, static_url_path='/static')
# a route to display our html page gotten from [react-chat-widget](https://github.com/mrbot-ai/rasa-webchat)
@app.route("/")
def index():
return render_template('index.html')
# run the application
if __name__ == "__main__":
app.run(debug=True)
Это ошибка, которую я получаю с элементом inspect на моей веб-странице:
"webchat-0.5.8.js:33 GET http://localhost:5000/socket.io/?EIO=3&transport=polling&t=M-bhVfa 404 (NOT FOUND)"
Если кто-нибудь сможет мне помочь, это будет очень признательно. Возможно, мне не хватает информации, которая может помочь ответить на этот вопрос, который мне может не хватать, и если кому-то понадобится дополнительная информация, я сообщу немедленно.
Еще одна деталь, которую я забыл добавить, была моя версия Flask - 1.1.1, моя версия Rasa - 1.6.0, моя версия rasa-nlu - 0.15. а у меня версия rasa-core 0.14.5