From 227477416f87f34ec7947f7ab18fc7520d526008 Mon Sep 17 00:00:00 2001 From: Baljinder Hothi <140272774+BaljinderHothi@users.noreply.github.com> Date: Thu, 15 May 2025 22:36:23 -0400 Subject: [PATCH 1/4] Update requirements.txt --- api/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/api/requirements.txt b/api/requirements.txt index 35b113d..dc8bbb3 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -4,3 +4,4 @@ transformers>=4.51.0 torch supabase python-dotenv +gunicorn From c1683ebf704a6b14908f6bb0a09937a5a86c83f6 Mon Sep 17 00:00:00 2001 From: Baljinder Hothi <140272774+BaljinderHothi@users.noreply.github.com> Date: Thu, 15 May 2025 22:36:48 -0400 Subject: [PATCH 2/4] Update requirements.txt --- api/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/api/requirements.txt b/api/requirements.txt index dc8bbb3..3f2473e 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -5,3 +5,4 @@ torch supabase python-dotenv gunicorn +uvicorn From 3905dedd8295449fc306c3f8ac416728e027308d Mon Sep 17 00:00:00 2001 From: Baljinder Hothi <140272774+BaljinderHothi@users.noreply.github.com> Date: Thu, 15 May 2025 23:17:08 -0400 Subject: [PATCH 3/4] fallback for local testing --- api/app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/app.py b/api/app.py index 3fe575d..563cdff 100644 --- a/api/app.py +++ b/api/app.py @@ -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) From 197c1de2adb844f31d7192d69e7e1f8c309b75be Mon Sep 17 00:00:00 2001 From: Baljinder Hothi <140272774+BaljinderHothi@users.noreply.github.com> Date: Thu, 15 May 2025 23:18:22 -0400 Subject: [PATCH 4/4] Update app.py --- api/app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/app.py b/api/app.py index 563cdff..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" }