-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_chatterbot_response.py
42 lines (39 loc) · 1.04 KB
/
get_chatterbot_response.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import chatterbot
# import asyncio
# import concurrent.futures
# import os
# import re
# import subprocess
import time
# from sys import version
# from threading import Thread
import flask
from flask import Flask
# import discord
from chatterbot import ChatBot
# from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer
# from dotenv import load_dotenv
import sys
# statement = sys.argv[1]
readOnlyBot = ChatBot(
'Fred',
read_only=True,
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.BestMatch'
],
database_uri='sqlite:///database.sqlite3'
)
# print(readOnlyBot.get_response(statement))
app = Flask(__name__)
@app.route('/', methods = ['GET'])
def index():
# print(flask.request.args.get('input'))
t1=time.time()
a = readOnlyBot.get_response(flask.request.args.get('input'))
print(time.time()-t1)
return str(a)
if __name__ == '__main__':
app.run(port = 5000)