gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.11k stars 4.45k forks source link

Unable to get a response. #2135

Open intercontoni opened 3 years ago

intercontoni commented 3 years ago

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 commented 3 years ago

Any help?

Pro100rus32 commented 3 years ago

ChatterBot is no longer supported.

AnAnalogGuy commented 3 years ago

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

intercontoni commented 3 years ago

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)
AnAnalogGuy commented 3 years ago

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).

intercontoni commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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, 
AnAnalogGuy commented 3 years ago

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).

intercontoni commented 3 years ago

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

I don't see misconfiguration....

intercontoni commented 3 years ago

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...

AnAnalogGuy commented 3 years ago

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))

intercontoni commented 3 years ago

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