gptbot / main-raw.py
devopsrobo's picture
Upload 4 files
317c7cc verified
raw
history blame contribute delete
572 Bytes
import aiml
import os
kernel = aiml.Kernel()
if os.path.isfile("bot_brain.brn"):
kernel.bootstrap(brainFile = "bot_brain.brn")
else:
kernel.bootstrap(learnFiles = os.path.abspath("aiml/std-startup.xml"), commands = "load aiml b")
kernel.saveBrain("bot_brain.brn")
# kernel now ready for use
while True:
message = raw_input("Enter your message to the bot: ")
if message == "quit":
exit()
elif message == "save":
kernel.saveBrain("bot_brain.brn")
else:
bot_response = kernel.respond(message)
print bot_response