Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,9 +30,15 @@ suggested_questions = [
|
|
30 |
"What was the revenue growth of"
|
31 |
]
|
32 |
|
33 |
-
#
|
34 |
-
st.
|
35 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# Session state for input question
|
38 |
if "partial_question" not in st.session_state:
|
@@ -43,49 +49,37 @@ def update_input(selected_question):
|
|
43 |
st.session_state.partial_question = selected_question
|
44 |
st.rerun()
|
45 |
|
46 |
-
# Display suggested partial questions
|
47 |
-
st.
|
48 |
-
cols = st.columns(5)
|
49 |
for i, question in enumerate(suggested_questions):
|
50 |
-
if
|
51 |
update_input(question)
|
52 |
|
53 |
# Text input box
|
|
|
54 |
partial_question = st.text_input("Enter a partial question:", st.session_state.partial_question)
|
55 |
|
56 |
-
#
|
57 |
-
if st.button("Complete Question"):
|
58 |
if partial_question.strip():
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
else:
|
73 |
-
st.warning("Please enter a partial question.")
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
30 |
"What was the revenue growth of"
|
31 |
]
|
32 |
|
33 |
+
# Sidebar Settings
|
34 |
+
st.sidebar.header("π§ Settings")
|
35 |
+
max_length = st.sidebar.slider("Max Length", 30, 100, 60, step=5)
|
36 |
+
num_return_sequences = st.sidebar.slider("Number of Completions", 1, 5, 3)
|
37 |
+
sampling = st.sidebar.checkbox("Enable Sampling", value=True)
|
38 |
+
|
39 |
+
# Main UI
|
40 |
+
st.title("π€ Question Completion Model")
|
41 |
+
st.write("Enter a partial question related to **financial statements, corporate governance, or company reports**, and the model will intelligently complete it!")
|
42 |
|
43 |
# Session state for input question
|
44 |
if "partial_question" not in st.session_state:
|
|
|
49 |
st.session_state.partial_question = selected_question
|
50 |
st.rerun()
|
51 |
|
52 |
+
# Display suggested partial questions in sidebar
|
53 |
+
st.sidebar.subheader("π‘ Suggested Partial Questions")
|
|
|
54 |
for i, question in enumerate(suggested_questions):
|
55 |
+
if st.sidebar.button(question, key=f"suggested_{i}"):
|
56 |
update_input(question)
|
57 |
|
58 |
# Text input box
|
59 |
+
st.subheader("βοΈ Enter Partial Question")
|
60 |
partial_question = st.text_input("Enter a partial question:", st.session_state.partial_question)
|
61 |
|
62 |
+
# Generate button
|
63 |
+
if st.button("π Complete Question"):
|
64 |
if partial_question.strip():
|
65 |
+
with st.spinner("β³ Generating completed questions... Please wait!"):
|
66 |
+
outputs = question_completion_pipeline(
|
67 |
+
partial_question,
|
68 |
+
max_length=max_length,
|
69 |
+
num_return_sequences=num_return_sequences,
|
70 |
+
do_sample=sampling,
|
71 |
+
truncation=True
|
72 |
+
)
|
73 |
+
|
74 |
+
st.subheader("β
Completed Questions")
|
75 |
+
completed_texts = [output["generated_text"] for output in outputs]
|
76 |
+
|
77 |
+
# Display completed questions inside an expander
|
78 |
+
with st.expander("π View Generated Questions"):
|
79 |
+
for idx, completed_question in enumerate(completed_texts):
|
80 |
+
st.markdown(f"**{idx+1}. {completed_question}**")
|
81 |
+
|
82 |
+
# Copy option
|
83 |
+
st.text_area("π Copy Completed Questions:", "\n".join(completed_texts), height=150)
|
84 |
else:
|
85 |
+
st.warning("β οΈ Please enter a partial question.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|