Exemplo n.º 1
0
from flask import Flask
app = Flask(__name__)
from flask import request

import chatbot as cb
cb.init()

@app.route('/')
def hello():
    cb.init2()
    cb.newReq()
    return "Hello World!"




@app.route('/chatbot2/', methods=["POST"])
def chat2():
    query = request.form['query']
    resp= cb.getChatResponse(query)
    return str(resp)


@app.route('/chatbot/', methods=["POST"])
def chat():
    query = request.form['query']
    resp= cb.request2(query)
    return str(resp)


Exemplo n.º 2
0
def hi():
    return chatbot.init()
Exemplo n.º 3
0
def bot(uname):
    init(API, [uname])
    return render_template('base.html')
Exemplo n.º 4
0
@app.route('/message', methods=['POST'])
@cross_origin()
def meassage():
    response = jsonify({
        "text": get_response(request.get_json()['text']),
        "time": datetime.now()
    })
    return response


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--engine',
                        type=str,
                        default='chatterbot',
                        help='chatterbot or chatbotrnn')
    parser.add_argument('--host',
                        type=str,
                        default='127.0.0.1',
                        help='host name for web server')
    parser.add_argument('--port',
                        type=int,
                        default=5000,
                        help='port number for web server')
    args = parser.parse_args()

    get_response = init(args.engine)

    app.run(host=args.host, port=args.port)
    socketio.run(app)
Exemplo n.º 5
0
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import chatbot
from evaluate import evaluateExample

speakers = {
    'cartman': '771434365:AAE8bpXZ6QMizyZxmvr6Mke6pOUFW0suN9E',
    'stan': '797666745:AAG5L9qHQgQIERXFf47mD1QdatLEfXH0p2c',
    'kyle': '798154398:AAGHAUZ8l-Zi_bMr8KrRwkZ1svju1_fW2S8',
    'randy': '764465736:AAHeOYQMHStGNPZ1gNaPl2dZEiuorvBi_fI',
    'butters': '789795577:AAHOF3l49Ij-pqsAkEp0Xw84bMTn1ui4lxo',
    '<none>': '773092951:AAHMltKlernAmXHvO_TQ3B6mzkY1mv61rQc'
}

searcher, word_map, person_map = chatbot.init()


class TeleBot:
    def __init__(self, speaker, token):
        self.speaker = speaker
        self.token = token

    def run(self):
        updater = Updater(token=self.token)
        dispatcher = updater.dispatcher
        speaker_id = person_map.get_index(self.speaker)

        def start(bot, update):
            bot.send_message(chat_id=update.message.chat_id,
                             text=evaluateExample("", searcher, word_map,
                                                  speaker_id))