Spaces:
Build error
Build error
Create app.py
Browse filesfrom flask import Flask, request, jsonify
from transformers import pipeline
app = Flask(__name__)
@app
.route('/generate', methods=['POST'])
def generate():
data = request.get_json()
text = data['text']
# Utiliza un modelo de Hugging Face
generator = pipeline("text-generation")
response = generator(text, max_length=50, do_sample=False)[0]['generated_text']
return jsonify({"response": response})
if __name__ == '__main__':
app.run(debug=True)