Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
messages = [
|
6 |
-
{"role": "user", "content": "Who are you?"}
|
7 |
pipe = pipeline("text-generation", model="Leo022/Gemma_QA_For_Telegram_Bot")
|
8 |
|
9 |
# Create a Streamlit app
|
10 |
-
st.title("
|
11 |
|
12 |
# Create a text input for the user to enter their question
|
13 |
-
question = st.text_input("Enter your question")
|
14 |
|
15 |
# Create a button to submit the question
|
16 |
if st.button("Submit"):
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the text-generation pipeline
|
|
|
|
|
5 |
pipe = pipeline("text-generation", model="Leo022/Gemma_QA_For_Telegram_Bot")
|
6 |
|
7 |
# Create a Streamlit app
|
8 |
+
st.title("Gemma QA for Telegram Bot")
|
9 |
|
10 |
# Create a text input for the user to enter their question
|
11 |
+
question = st.text_input("Enter your question:")
|
12 |
|
13 |
# Create a button to submit the question
|
14 |
if st.button("Submit"):
|
15 |
+
if question.strip(): # Ensure the question is not empty
|
16 |
+
try:
|
17 |
+
# Use the pipeline to generate a response to the user's question
|
18 |
+
response = pipe(question, max_length=100, num_return_sequences=1)
|
19 |
+
# Display the response to the user
|
20 |
+
st.write("Response:", response[0]["generated_text"])
|
21 |
+
except Exception as e:
|
22 |
+
st.error(f"An error occurred: {e}")
|
23 |
+
else:
|
24 |
+
st.warning("Please enter a question before submitting.")
|