Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,19 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
return qa_result["answer"]
|
12 |
|
13 |
-
|
14 |
-
st.title("Question & Answer Chatbot (Limited Functionality)")
|
15 |
-
st.write("This chatbot uses a pre-trained model from Hugging Face Hub. It might not have the same capabilities as a large language model.")
|
16 |
|
17 |
-
|
18 |
-
if user_query:
|
19 |
-
answer = answer_question(user_query)
|
20 |
-
st.write(f"Answer: {answer}")
|
21 |
|
22 |
-
if
|
23 |
-
|
|
|
|
1 |
+
# app.py
|
2 |
import streamlit as st
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
# Load sentiment analysis pipeline
|
6 |
+
classifier = pipeline("sentiment-analysis")
|
7 |
|
8 |
+
def analyze_sentiment(text):
|
9 |
+
"""Analyzes the sentiment of a given text."""
|
10 |
+
result = classifier(text)
|
11 |
+
return result[0]['label'], result[0]['score']
|
|
|
12 |
|
13 |
+
st.title("Sentiment Analysis App")
|
|
|
|
|
14 |
|
15 |
+
text = st.text_area("Enter your text here:")
|
|
|
|
|
|
|
16 |
|
17 |
+
if st.button("Analyze"):
|
18 |
+
label, score = analyze_sentiment(text)
|
19 |
+
st.success(f"Sentiment: {label}, Score: {score}")
|