louiecerv commited on
Commit
23eb09c
·
1 Parent(s): ece37d1
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def generate_prompt(topic, difficulty, num_questions):
4
+ """Generates an AI prompt based on user input."""
5
+ prompt = (
6
+ f"Generate {num_questions} quiz questions on the topic '{topic}' "
7
+ f"with a difficulty level of '{difficulty}'."
8
+ )
9
+ return prompt
10
+
11
+ def get_ai_response(prompt):
12
+ """Dummy function to simulate getting a response from an AI model."""
13
+ response = f"Here are your generated questions based on the prompt: {prompt}"
14
+ return response
15
+
16
+ # Streamlit App
17
+ st.title("AI Quiz Question Generator")
18
+
19
+ # Step 1: Prompt user for a topic
20
+ topic = st.text_input("Enter a topic:", "")
21
+
22
+ # Step 2: Prompt for difficulty level
23
+ difficulty_levels = ["Easy", "Medium", "Hard"]
24
+ difficulty = st.selectbox("Select difficulty level:", difficulty_levels)
25
+
26
+ # Step 3: Prompt for the number of questions
27
+ num_questions = st.selectbox("Select the number of questions:", [5, 10, 15])
28
+
29
+ # Generate AI prompt
30
+ if st.button("Generate AI Prompt"):
31
+ if topic.strip():
32
+ ai_prompt = generate_prompt(topic, difficulty, num_questions)
33
+ st.write(f"Generated Prompt: {ai_prompt}")
34
+ else:
35
+ st.warning("Please enter a topic before generating a prompt.")
36
+
37
+ # Get AI response
38
+ if st.button("Get Response"):
39
+ if topic.strip():
40
+ ai_prompt = generate_prompt(topic, difficulty, num_questions)
41
+ ai_response = get_ai_response(ai_prompt)
42
+ st.write(ai_response)
43
+ else:
44
+ st.warning("Please generate a prompt first before getting a response.")