Spaces:
Sleeping
Sleeping
jvroo
commited on
Commit
·
6103c26
1
Parent(s):
2091aa4
Remote Inference Fix
Browse files
app.py
CHANGED
|
@@ -28,12 +28,12 @@ def local_sentiment_analysis(review):
|
|
| 28 |
def remote_sentiment_analysis(review):
|
| 29 |
try:
|
| 30 |
# Make a request to the Hugging Face Inference API for text classification
|
| 31 |
-
response = remote_inference_client.text_classification(review)
|
| 32 |
sentiment = response[0]['label']
|
| 33 |
score = response[0]['score']
|
| 34 |
-
return
|
| 35 |
except Exception as e:
|
| 36 |
-
return f"Error: {str(e)}"
|
| 37 |
|
| 38 |
# Function to analyze sentiment and return the result as a string and plot
|
| 39 |
def analyze_sentiment(review, mode):
|
|
|
|
| 28 |
def remote_sentiment_analysis(review):
|
| 29 |
try:
|
| 30 |
# Make a request to the Hugging Face Inference API for text classification
|
| 31 |
+
response = remote_inference_client.text_classification(review, model=remote_model)
|
| 32 |
sentiment = response[0]['label']
|
| 33 |
score = response[0]['score']
|
| 34 |
+
return sentiment, score
|
| 35 |
except Exception as e:
|
| 36 |
+
return f"Error: {str(e)}", 0.0 # Ensure it returns two values
|
| 37 |
|
| 38 |
# Function to analyze sentiment and return the result as a string and plot
|
| 39 |
def analyze_sentiment(review, mode):
|