Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,17 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 4 |
|
| 5 |
st.title("Question-Answer Generator")
|
| 6 |
user_question = st.text_input("Ask a question:")
|
|
|
|
| 7 |
if st.button("Generate Answer"):
|
| 8 |
if user_question:
|
| 9 |
-
# Use the T5 model to generate
|
| 10 |
-
answer = pipe(user_question, max_length=
|
| 11 |
st.write("Answer:")
|
| 12 |
st.write(answer)
|
| 13 |
else:
|
| 14 |
st.warning("Please enter a question.")
|
| 15 |
-
st.sidebar.header("Customize Appearance")
|
| 16 |
-
bg_color = st.sidebar.color_picker("Background Color", "#f2f2f2")
|
| 17 |
-
text_color = st.sidebar.color_picker("Text Color", "#000000")
|
| 18 |
-
st.markdown(f'<style>body{{background-color: {bg_color}; color: {text_color}}}</style>', unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Create a text2text-generation pipeline with the "google/flan-t5-base" model
|
| 5 |
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 6 |
|
| 7 |
st.title("Question-Answer Generator")
|
| 8 |
user_question = st.text_input("Ask a question:")
|
| 9 |
+
|
| 10 |
if st.button("Generate Answer"):
|
| 11 |
if user_question:
|
| 12 |
+
# Use the T5 model to generate a more precise answer
|
| 13 |
+
answer = pipe(user_question, max_length=100, do_sample=False)[0]["generated_text"]
|
| 14 |
st.write("Answer:")
|
| 15 |
st.write(answer)
|
| 16 |
else:
|
| 17 |
st.warning("Please enter a question.")
|
|
|
|
|
|
|
|
|
|
|
|