Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,22 @@
|
|
1 |
import streamlit as st
|
2 |
-
import
|
3 |
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
payload = {"inputs": prompt}
|
16 |
-
response = requests.post(API_URL, headers=headers, json=payload)
|
17 |
-
return response.json()
|
18 |
-
|
19 |
-
if st.button("Generate Question"):
|
20 |
-
if topic:
|
21 |
-
prompt = f"generate question: {topic}"
|
22 |
-
output = query(prompt)
|
23 |
-
question = output[0]['generated_text']
|
24 |
-
st.session_state['question'] = question
|
25 |
-
st.write(f"**Question:** {question}")
|
26 |
-
st.text_input("Your Answer", key="answer")
|
27 |
-
|
28 |
-
if 'question' in st.session_state and st.button("Check Answer"):
|
29 |
-
st.write("Answer checking is coming soon... (can integrate GPT here for answer matching)")
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load question generation pipeline
|
5 |
+
qg_pipeline = pipeline("text2text-generation", model="iarfmoose/t5-base-question-generator")
|
6 |
|
7 |
+
st.title("AI-Powered Quiz Generator")
|
8 |
+
text = st.text_area("Enter a topic or paragraph to generate quiz questions:")
|
9 |
|
10 |
+
if st.button("Generate Quiz"):
|
11 |
+
with st.spinner("Generating questions..."):
|
12 |
+
output = qg_pipeline(f"generate questions: {text}", max_length=512, do_sample=True, temperature=0.7)
|
13 |
+
questions = output[0]['generated_text'].split('\n')
|
14 |
+
|
15 |
+
score = 0
|
16 |
+
for i, question in enumerate(questions):
|
17 |
+
if question.strip():
|
18 |
+
st.write(f"**Q{i+1}: {question}**")
|
19 |
+
answer = st.radio("Your Answer:", ['Option A', 'Option B', 'Option C', 'Option D'], key=i)
|
20 |
+
# You can set correct answers with additional logic
|
21 |
|
22 |
+
st.success("Quiz complete! (Scoring can be added based on correct options)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|