Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ transformers>=4.51.0
torch
supabase
python-dotenv
gunicorn
uvicorn
Loading