Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,11 @@ from transformers import (
|
|
| 13 |
)
|
| 14 |
import os
|
| 15 |
from huggingface_hub import snapshot_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# ββββββββββββββββββββββ konfiguracja ββββββββββββββββββββββ
|
| 18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -140,6 +145,8 @@ app = FastAPI()
|
|
| 140 |
|
| 141 |
@app.post("/analyze", response_model=AnalysisResult)
|
| 142 |
def analyze_comment(comment: Comment):
|
|
|
|
|
|
|
| 143 |
text_pl = comment.text
|
| 144 |
text_en = translate_pl_to_en([text_pl])[0]
|
| 145 |
aspects = extract_aspects(text_en)
|
|
@@ -163,4 +170,5 @@ def analyze_comment(comment: Comment):
|
|
| 163 |
asp_pl = aspect_aliases.get(asp, translate_en_to_pl([asp])[0].lower())
|
| 164 |
results.append(AspectSentiment(aspect=asp_pl, sentiment=sentiment_label))
|
| 165 |
|
| 166 |
-
|
|
|
|
|
|
| 13 |
)
|
| 14 |
import os
|
| 15 |
from huggingface_hub import snapshot_download
|
| 16 |
+
import logging
|
| 17 |
+
|
| 18 |
+
# Konfiguracja logowania
|
| 19 |
+
logging.basicConfig(level=logging.INFO)
|
| 20 |
+
logger = logging.getLogger(__name__)
|
| 21 |
|
| 22 |
# ββββββββββββββββββββββ konfiguracja ββββββββββββββββββββββ
|
| 23 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 145 |
|
| 146 |
@app.post("/analyze", response_model=AnalysisResult)
|
| 147 |
def analyze_comment(comment: Comment):
|
| 148 |
+
logger.info(f"Otrzymano zapytanie: {comment.text}")
|
| 149 |
+
|
| 150 |
text_pl = comment.text
|
| 151 |
text_en = translate_pl_to_en([text_pl])[0]
|
| 152 |
aspects = extract_aspects(text_en)
|
|
|
|
| 170 |
asp_pl = aspect_aliases.get(asp, translate_en_to_pl([asp])[0].lower())
|
| 171 |
results.append(AspectSentiment(aspect=asp_pl, sentiment=sentiment_label))
|
| 172 |
|
| 173 |
+
logger.info(f"WysΕano odpowiedΕΊ: {results} dla zapytania: {comment.text}")
|
| 174 |
+
return {"results": results}
|