Spaces:
Sleeping
Sleeping
Update sentiment.py
Browse files- sentiment.py +1 -2
sentiment.py
CHANGED
@@ -32,7 +32,7 @@ def convert_confidence(score):
|
|
32 |
def analyze_sentiment(text, model_id=None):
|
33 |
global CURRENT_MODEL, API_URL
|
34 |
|
35 |
-
#
|
36 |
if model_id and model_id != CURRENT_MODEL:
|
37 |
CURRENT_MODEL = model_id
|
38 |
API_URL = f"https://api-inference.huggingface.co/models/{CURRENT_MODEL}"
|
@@ -52,4 +52,3 @@ def analyze_sentiment(text, model_id=None):
|
|
52 |
|
53 |
except Exception as e:
|
54 |
return f"❌ **錯誤**: {str(e)}", 0.0
|
55 |
-
|
|
|
32 |
def analyze_sentiment(text, model_id=None):
|
33 |
global CURRENT_MODEL, API_URL
|
34 |
|
35 |
+
# **只在模型變更時更新 API URL**
|
36 |
if model_id and model_id != CURRENT_MODEL:
|
37 |
CURRENT_MODEL = model_id
|
38 |
API_URL = f"https://api-inference.huggingface.co/models/{CURRENT_MODEL}"
|
|
|
52 |
|
53 |
except Exception as e:
|
54 |
return f"❌ **錯誤**: {str(e)}", 0.0
|
|