from transformers import pipeline, set_seed
from flask import Flask, jsonify, request, render_template

app = Flask(__name__)
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/get_answer', methods=['POST'])
def get_answer():
    set_seed(42)
    question = request.form['question']
    answer = generator(question, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text']
    return jsonify({'answer': answer})

if __name__ == '__main__':
    app.run(debug=True)
{}
region:us
TAGS
#region-us 

from transformers import pipeline, set_seed
from flask import Flask, jsonify, request, render_template

app = Flask(__name__)
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')

@URL('/')
def home():
    return render_template('URL')

@URL('/get_answer', methods=['POST'])
def get_answer():
    set_seed(42)
    question = URL['question']
    answer = generator(question, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text']
    return jsonify({'answer': answer})

if __name__ == '__main__':
    URL(debug=True)
TAGS
#region-us 
