Spaces:
Configuration error
Configuration error
Upload 4 files
Browse filesFiles changed (4)
- README.md+32-12
- main-raw.pyAdded+21
- main.pyAdded+35
- requirements.txtAdded+2
123456789101112---title: Gptbotemoji: 🏃colorFrom: redcolorTo: indigosdk: gradiosdk_version: 4.38.1app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132# ChatbotAI Based Chatbot### RequirementsPython = 2.x.xFlaskAimlpip## Installation1. Clone and navigate to chatbot directory.2. Install the required packages.```bashpip install -r requirements.txt```3. Run the python server.```bashpython main.py```4. Open **http://127.0.0.1:5000** in your browser.5. You're done and let's chat with your Robot via browser.## Screenshot## Author[Sohel Amin](http://www.sohelamin.com)
123456789101112131415161718192021import aimlimport 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 usewhile 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_response1234567891011121314151617181920212223242526272829303132333435from flask import Flask, render_template, request, jsonifyimport aimlimport os
app = Flask(__name__)
@app.route("/")def hello(): return render_template('chat.html')
@app.route("/ask", methods=['POST'])def ask(): message = request.form['messageText'].encode('utf-8').strip()
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: if message == "quit": exit() elif message == "save": kernel.saveBrain("bot_brain.brn") else: bot_response = kernel.respond(message) # print bot_response return jsonify({'status':'OK','answer':bot_response})
if __name__ == "__main__": app.run(host='0.0.0.0', debug=True)12flask>=0.12.3aiml==0.8.6README.md+32-12
main-raw.pyAdded+21
main.pyAdded+35
requirements.txtAdded+2