from transformers import pipeline import streamlit as st classifier = pipeline("text-classification", model="rxh1/Finetune_2") text2text = pipeline("text2text-generation", model="facebook/blenderbot_small-90M") # Streamlit application title st.title("Text Sentiment Classification and Response Generation") st.write("Create auto reply for three sentiment: positive, neutral, negative") # Text input for user to enter the text to classify text = st.text_area("Enter the text to reply", "") # Perform text classification when the user clicks the "Classify" button if st.button("Reply"): # Perform text classification on the input text result = classifier(text)[0] # Display the classification result prediction = result['label'] st.write("Text:", text) st.write("Sentiment:", prediction) # Generate a response based on the classification result if prediction == "negative": answer = text2text(f"You are the owner of Starbucks and I am the customer and my feeling sentiment is bad.")[0]["generated_text"] elif prediction == "neutral": answer = text2text(f"You are the owner of Starbucks and I am the customer and my feeling sentiment is peaceful.")[0]["generated_text"] else: answer = text2text(f"You are the owner of Starbucks and I am the customer and my feeling sentiment is good.")[0]["generated_text"] st.write("Response:", answer)