app.py
unknown
plain_text
2 years ago
1.0 kB
5
Indexable
from flask import Flask, render_template, request import openai import config app = Flask(__name__) app.static_folder = 'static' app.config.from_object(config.config['development']) ### Initialise the OPENAI library with the key saved in the CONFIG file openai.api_key = app.config['OPENAI_KEY'] def chatbot_response(promt): completion = openai.Completion.create( engine = 'text-davinci-003', prompt = promt, max_tokens = 1024, n = 1, temperature = 0.5, ) response = completion.choices[0].text return response.strip() @app.route("/") def home(): return render_template("index.html") @app.route("/get") def get_bot_response(): userText = request.args.get('msg') return chatbot_response(userText) if __name__ == "__main__": app.run()
Editor is loading...