ChatterBot icon indicating copy to clipboard operation
ChatterBot copied to clipboard

Unable to get a response.

Open intercontoni opened this issue 4 years ago • 13 comments

Chatterbot 1 0 5....

My app...

from chatbot import chatbot

from flask import Flask, render_template, request

app = Flask(__name__)
app.static_folder = 'static'

@app.route("/")
def home():
    return render_template("index.html")

@app.route("/get")
def get_bot_response():
    userText = request.args.get('msg')
    return str(chatbot.get_response(userText))


if __name__ == "__main__":
    app.run()

Chatboy py

from chatterbot import ChatBot

chatbot = ChatBot(
    'CoronaBot', 
    read_only = True, 
     logic_adapters=[
        'chatterbot.logic.MathematicalEvaluation',
        'chatterbot.logic.TimeLogicAdapter',
        'chatterbot.logic.BestMatch',
        {
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': 'I am sorry, but I do not understand. I am still learning.',
            'maximum_similarity_threshold': 0.90
        }
    ],
    database_uri='sqlite:///database.sqlite3'
)

# Training With Own Questions 
from chatterbot.trainers import ListTrainer

trainer = ListTrainer(chatbot)

training_data_quesans = open('training_data/ques_ans.txt').read().splitlines()
training_data_personal = open('training_data/personal_ques.txt').read().splitlines()

training_data = training_data_quesans + training_data_personal

trainer.train(training_data)

# Training With Corpus
from chatterbot.trainers import ChatterBotCorpusTrainer

trainer_corpus = ChatterBotCorpusTrainer(chatbot)

trainer_corpus.train(
    'chatterbot.corpus.english'
)

Look... http://intercongreso.vps.co.ve/toninot ......

I have another in chatterbot 1.0.8 the same problem.

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', read_only = True, storage_adapter='chatterbot.storage.SQLStorageAdapter',
database_uri='sqlite:///database.sqlite3')

# Training with spanish Corpus Data 
trainer_corpus = ChatterBotCorpusTrainer(chatbot)

trainer_corpus.train(
    'chatterbot.corpus.spanish'
)


@app.route("/")
def home():    
    return render_template("elultimo.html") 
    
@app.route("/get")
def get_bot_response():    
    userText = request.args.get('msg')    
    return str(bot.get_response(userText)) 
    
if __name__ == "__main__":
     app.run()

Look http://intercongreso.vps.co.ve/toni ..... Work on the terminal not on the web...

What happen?

intercontoni avatar Mar 01 '21 00:03 intercontoni

Any help?

intercontoni avatar Mar 02 '21 04:03 intercontoni

ChatterBot is no longer supported.

Pro100rus32 avatar Mar 10 '21 15:03 Pro100rus32

@intercontoni a bit more information would be useful. What are you doing. What is not working. Error messages?

AnAnalogGuy avatar Apr 01 '21 17:04 AnAnalogGuy

Not response... I change...

http://intercongreso.vps.co.ve/tonib

This is my app...

from flask import Flask, render_template, request
from chatterbot import ChatBot
from chatterbot import languages

app = Flask(__name__)

bot = ChatBot('Toni', storage_adapter={
        'tagger_language': languages.SPA,
        'import_path': 'chatterbot.storage.SQLStorageAdapter',
         },
            logic_adapters=[
        'chatterbot.logic.MathematicalEvaluation',
        'chatterbot.logic.BestMatch',
        {
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': 'Yo lo siento mucho, pero como no te estoy entendiendo.',
            'maximum_similarity_threshold': 0.90
        }],
            read_only = True,
            preprocessors=['chatterbot.preprocessors.clean_whitespace',
                        'chatterbot.preprocessors.unescape_html',
                        'chatterbot.preprocessors.convert_to_ascii']
                        )
                       
@app.route("/")
def home():
    return render_template("index.html")

@app.route("/get")
def get_bot_response():
    user_input = request.args.get('msg')
    return str(bot.get_response(user_input))

if __name__ == "__main__":
    app.run(debug=True)

Whit this I speack whit terminal chatbot.py

from chatterbot import ChatBot

bot = ChatBot('Toni',
            logic_adapters=[{
            'import_path': 'chatterbot.logic.BestMatch',
            'default_response': 'Lo siento mucho pero como que no te estoy entendiendo.',
            'maximum_similarity_threshold': 0.90
        }],
            read_only = True,
            preprocessors=['chatterbot.preprocessors.clean_whitespace',
                        'chatterbot.preprocessors.unescape_html',
                        'chatterbot.preprocessors.convert_to_ascii']
                        )


# run and get response from user.
name = input('Digame su nombre primero: ')

print ('Bienvenido a mi servicio, en que te puedo ayudar?')

while True:

    request = input(name+': ')

    if request=="Chao" or request=='chao':
        print('Bot: Chao')
        break
    else:
        response=bot.get_response(request)
        print('Bot: ', response)

intercontoni avatar Apr 01 '21 18:04 intercontoni

I get a 404 from the server when sending a comment.

Request: GET | http://intercongreso.vps.co.ve/get?msg=Test Response: 404 Not Found

I would first check if your application is triggered at all (i.e. by checking the webserver log or writing out some log lines into your own log file from within your app).

AnAnalogGuy avatar Apr 01 '21 18:04 AnAnalogGuy

well, I'm not a programmer .... I'm going to look for information to see how it does what it tells me.

I'll tell you later ..

intercontoni avatar Apr 01 '21 19:04 intercontoni

I have in python setup cpanel this...

Passenger log file
You can define the path along with the filename ...

I don't see nothing in there...

intercontoni avatar Apr 01 '21 20:04 intercontoni

I don't think this is the problem ...

opt/passenger-5.3.7-13.el7.cloudlinux/src/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
App 10684 output:   import sys, os, io, re, imp, threading, signal, traceback, socket, select, struct, logging, 

intercontoni avatar Apr 01 '21 20:04 intercontoni

As said above, you have configured your FLASK application to call chatterbot athttp://intercongreso.vps.co.ve/get?msg=Test which returns a 404/Document not found. So you surely have a misconfiguration there. I would assume the URL should be http://intercongreso.vps.co.ve/tonib/get?msg=Test instead (which returns a 200).

AnAnalogGuy avatar Apr 02 '21 08:04 AnAnalogGuy

can you tell me how to do that?...

I don't see misconfiguration....

intercontoni avatar Apr 02 '21 15:04 intercontoni

I create whit python setup app cpanel... I install whit pip install chatterbot, flask, spacy, etc...

And copy and paste the chatbot.py web_app.py and chatbot_training.py

I don't configure nothing.... I don't know how to make this...

intercontoni avatar Apr 02 '21 16:04 intercontoni

Your problem is not related to chatterbot, it's a flask related issue. And it seems you are expecting this to be a runs-out-of-the-box application, which it is not. Meaning, you need to acquire a basic understanding of web technologies/programming.

Related to your problem: I'm not 100% sure, but maybe this helps.

@app.route("/tonib/") def home(): return render_template("index.html")

@app.route("/tonib/get") def get_bot_response(): userText = request.args.get('msg') return str(chatbot.get_response(userText))

AnAnalogGuy avatar Apr 02 '21 17:04 AnAnalogGuy

Not because I have the folder tonib... in the folder tonib have the files .py

If I put

@app.route("/tonib/") def home(): return render_template("index.html")

@app.route("/tonib/get") def get_bot_response(): userText = request.args.get('msg') return str(chatbot.get_response(userText))

I have this...

Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

I need go to the address http://intercongreso.vps.co.ve/tonib/tonib but bit whotk... os the same... not response nothing

intercontoni avatar Apr 02 '21 18:04 intercontoni

This appears to be an old issue, I'm going to close it off.

Looking at the code provided I don't immediately see what the issue was, but I'd recommend moving the .train() call to a different file (such as a command https://click.palletsprojects.com/en/stable/)

gunthercox avatar Oct 13 '25 17:10 gunthercox