import warnings warnings.filterwarnings("ignore") def whoIs(query, sessionID="general"): try: return wikipedia.summary(query) except: for newquery in wikipedia.search(query): try: return wikipedia.summary(newquery) except: pass return "I don't know about " + query call = multiFunctionCall({"whoIs": whoIs}) firstQuestion = "Hi, how are you?" chat = Chat(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Example.template"), reflections, call=call) chat.converse_http(firstQuestion) chat.converse_http(firstQuestion) chat.converse_http(firstQuestion) chat.converse_http(firstQuestion) chat.converse_http(firstQuestion) chat.converse_http(firstQuestion) #chat.save_template("test.template")
# for key in flights.keys(): # if key == fno: # if(flights[key].seats[sno].booked == 0): # flights[key].seats[sno].booked = 1 # print("Succesfully booked") # else: # print("This seat has already been taken") return str(seats[0][0]) call = multiFunctionCall({"showSeats":showSeats, "returnFlights":returnFlights, "getFlightDetails":getFlightDetails, "bookFlight":bookFlight}) chat = Chat(os.path.join(os.path.dirname(os.path.abspath(__file__)),"examples/flightRules.template"), reflections,call=call) chat.converse_http("Hi","") @app.route('/chat', methods = ["POST"]) def hello(): print(request.json) message = request.json['message'] print(message) return chat.converse_http(message),200 def whoIs(query,sessionID="general"): try: return wikipedia.summary(query) except: for newquery in wikipedia.search(query): try: