Spaces:
Runtime error
Runtime error
Peiiiiiiiiru
commited on
Commit
•
c5c4f71
1
Parent(s):
9044537
Delete app.py
Browse files
app.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
from flask import Flask, render_template, request, jsonify
|
2 |
-
from transformers import pipeline
|
3 |
-
import os
|
4 |
-
|
5 |
-
app = Flask(__name__)
|
6 |
-
|
7 |
-
# 設置 Hugging Face Cache 路徑
|
8 |
-
os.environ["HF_HOME"] = "./cache"
|
9 |
-
|
10 |
-
# 加載 Hugging Face 模型
|
11 |
-
emotion_analysis = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
|
12 |
-
|
13 |
-
@app.route("/")
|
14 |
-
def home():
|
15 |
-
return {"message": "Welcome to the Emotional Assistant!"}
|
16 |
-
|
17 |
-
@app.route("/analyze_emotion", methods=["POST"])
|
18 |
-
def analyze_emotion():
|
19 |
-
user_input = request.json.get("message", "")
|
20 |
-
if not user_input:
|
21 |
-
return jsonify({"error": "No input provided"}), 400
|
22 |
-
|
23 |
-
emotions = emotion_analysis(user_input)
|
24 |
-
return jsonify({"result": emotions})
|
25 |
-
|
26 |
-
if __name__ == "__main__":
|
27 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|