diff --git a/api/app.py b/api/app.py index 3fe575d..37ee932 100644 --- a/api/app.py +++ b/api/app.py @@ -32,16 +32,16 @@ supabase: Client = create_client(url, key) -tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") -model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") +tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english") +model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english") +#changed these for render storage situations sentiment_pipeline = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer) #LABEL_0 -> negative, LABEL_1 -> neutral, LABEL_2 -> positive label_mapping = { - "LABEL_0": "negative", - "LABEL_1": "neutral", - "LABEL_2": "positive" + "LABEL_0": "negative", + "LABEL_1": "positive" } @@ -159,5 +159,6 @@ def analyze_product_review( if __name__ == "__main__": - import uvicorn - uvicorn.run(app, host="0.0.0.0", port=8000) + import uvicorn + port = int(os.environ.get("PORT", 8000)) # fallback for local testing + uvicorn.run(app, host="0.0.0.0", port=port) diff --git a/api/requirements.txt b/api/requirements.txt index 35b113d..3f2473e 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,3 +4,5 @@ transformers>=4.51.0 torch supabase python-dotenv +gunicorn +uvicorn