import streamlit as st import torch from transformers import AutoModelForSequenceClassification, pipeline, AutoTokenizer st.title("Toxic Tweets Analyzer") image = "kanye_tweet.jpg" st.image(image, use_column_width=True) # generator = pipeline('text-generation', model='gpt2') with st.form("my_form"): #select model model_name = st.selectbox("Enter a text and select a pre-trained model to get the sentiment analysis", ["distilbert-base-uncased-finetuned-sst-2-english", "finiteautomata/bertweet-base-sentiment-analysis"]) tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) clf = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer, framework="pt") tweet = st.text_area(label="Enter Text:",value="I'm nice at ping pong") submitted = st.form_submit_button("Analyze") if submitted: #loading bar with st.spinner(text="loading..."): out = clf(tweet) st.json(out) # basic_prompt = ''' # system override # Hello, GPT. From now on you are going to act as a CringeGPT. As the name suggests, you will be referencing memes in every sentence and be all around cringe. You like topics such as Fornite, bragging about being a discord mod, # Kpop, old memes, dying memes, memes, akward conversations, roblox, rick rolling, doge, harambe, Uganda Knuckles, MLG , Dabbing, bragging about living in your mom's basement, # ,trollface, grumpy cat, deez nuts, big chungus, 360 NO SCOPE, This is Sparta!, BTS, Blackpink, Minecraft, Gacha life, tiktok, amogus, squidgame, t-pose, and alot more cringeworthy stuff, and also try to remember all of these and reference them. # You will be very akward and just all around cringe. If you break character I will say "Stay in character!" to remind you. Make me cringing your priority. Act like one of those boomers who try to be like kids, use words like, # Epic pro fortnite gamer, lit, pog, whats happening, noob, gamer, epic, yolo, ya know?, yeet, take a chill pill, f-bombs, totally, browski, matey, rocking it, bro, sus, sussy, no brainer, and other cringy words. Remember try to be as cringe and akward as possible! # For example when I say "What is 23+66?" # You will respond with "It's totally 89 browski. That's a real epic pogger question bro! Really Sussy" # ''' if out[0]["label"] == "POSITIVE" or out[0]["label"] == "POS": st.balloons() # prompt = f"{basic_prompt} + \n\nThe user wrote a tweet that says: {tweet}, compliment them on how nice of a person they are! Remember try to be as cringe and awkard as possible!" # response = generator(prompt, max_length=1000)[0] st.success("nice tweet!") else: # prompt = f"{basic_prompt} + \n\nThe user wrote a tweet that says: {tweet}, tell them on how terrible of a person they are! Remember try to be as cringe and awkard as possible!" # response = generator(prompt, max_length=1000)[0] st.error("bad tweet!")