Chatterbot not answer...
Hi... the chatterbot not answer...
I uses this...
Chatterbot 1.0.8 Flask 1.1.2
The app
`from flask import Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer
app = Flask(name, template_folder="templates")
chatbot = ChatBot('Toni')
Create a new trainer for the chatbot trainer = ChatterBotCorpusTrainer(chatbot)
Train the chatbot based on the english corpus trainer.train("chatterbot.corpus.english")
Train the chatbot based on the spanish corpus trainer.train("chatterbot.corpus.spanish")
@app.route('/') def home(): return render_template('home.html')
@app.route("/get") def get_bot_response(): userText = request.args.get('msg') return str(bot.get_response(userText))
if name == "main":
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
(I don't know if waitress is ok... I am músican no programer)
The html is there ``
``
<style>
body {
font-family: monospace;
color: #fff;
}
h1 {
display: inline-block;
font-size: 3em;
margin: 0;
padding: 14px;
}
h3 {
color: black;
font-size: 20px;
margin-top: 3px;
text-align: center;
}
#chatbox {
margin-left: auto;
margin-right: auto;
width: 40%;
margin-top: 60px;
}
#userInput {
margin-left: auto;
margin-right: auto;
width: 40%;
margin-top: 70px;
}
#textInput {
width:40%;
border: none;
border-bottom: 5px solid #00cc99;
font-family: monospace;
font-size: 17px;
}
.userText {
color: white;
font-family: monospace;
font-size: 17px;
text-align: right;
line-height: 30px;
}
.userText span {
background-color: #4169e1;
padding: 10px;
border-radius: 2px;
}
.botText {
color: white;
font-family: monospace;
font-size: 17px;
text-align: left;
line-height: 30px;
}
.botText span {
background-color: #a4c639;
padding: 10px;
border-radius: 2px;
}
#tidbit {
position: absolute;
bottom: 0;
right: 0;
width: 300px;
}
.boxed {
margin-left: auto;
margin-right: auto;
width: 78%;
margin-top: 60px;
border: 1px solid #00cc99;
}
.box {
border: 2px solid #00cc99;
}
</style>
Welcome to my ChatBot
Hello! My name is Bob. Your personal chatbot!
Hi! Nice to meet you!
<script>
function getBotResponse() {
var rawText = $("#textInput").val();
var userHtml = '<p class="userText"><span>' + rawText + "</span></p>";
$("#textInput").val("");
$("#chatbox").append(userHtml);
document
.getElementById("userInput")
.scrollIntoView({ block: "start", behavior: "smooth" });
$.get("/get", { msg: rawText }).done(function (data) {
var botHtml = '<p class="botText"><span>' + data + "</span></p>";
$("#chatbox").append(botHtml);
document
.getElementById("userInput")
.scrollIntoView({ block: "start", behavior: "smooth" });
});
}
$("#textInput").keypress(function (e) {
if (e.which == 13) {
getBotResponse();
}
});
</script>
</div>
``
Thanks for help me.