Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,22 +26,6 @@ def ask_question():
|
|
| 26 |
except Exception as e:
|
| 27 |
return jsonify({"error": str(e)}), 500
|
| 28 |
|
| 29 |
-
# Streaming route
|
| 30 |
-
@app.route('/stream', methods=['POST'])
|
| 31 |
-
def stream_answer():
|
| 32 |
-
data = request.get_json()
|
| 33 |
-
question = data.get('question', '').strip()
|
| 34 |
-
|
| 35 |
-
if not question:
|
| 36 |
-
return jsonify({"error": "Question is required"}), 400
|
| 37 |
-
|
| 38 |
-
def generate():
|
| 39 |
-
answer = generate_long_answer(question)
|
| 40 |
-
for word in answer.split():
|
| 41 |
-
yield f"data: {word}\n\n"
|
| 42 |
-
time.sleep(0.05) # 50ms delay per word
|
| 43 |
-
|
| 44 |
-
return Response(generate(), mimetype='text/event-stream')
|
| 45 |
|
| 46 |
if __name__ == '__main__':
|
| 47 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 26 |
except Exception as e:
|
| 27 |
return jsonify({"error": str(e)}), 500
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
if __name__ == '__main__':
|
| 31 |
app.run(host='0.0.0.0', port=7860)
|