Spaces:
Runtime error
Runtime error
import streamlit as st | |
def generate_prompt(topic, difficulty, num_questions): | |
"""Generates an AI prompt based on user input.""" | |
prompt = ( | |
f"Generate {num_questions} quiz questions on the topic '{topic}' " | |
f"with a difficulty level of '{difficulty}'." | |
) | |
return prompt | |
def get_ai_response(prompt): | |
"""Dummy function to simulate getting a response from an AI model.""" | |
response = f"Here are your generated questions based on the prompt: {prompt}" | |
return response | |
# Streamlit App | |
st.title("AI Quiz Question Generator") | |
# Step 1: Prompt user for a topic | |
topic = st.text_input("Enter a topic:", "") | |
# Step 2: Prompt for difficulty level | |
difficulty_levels = ["Easy", "Medium", "Hard"] | |
difficulty = st.selectbox("Select difficulty level:", difficulty_levels) | |
# Step 3: Prompt for the number of questions | |
num_questions = st.selectbox("Select the number of questions:", [5, 10, 15]) | |
# Generate AI prompt | |
if st.button("Generate AI Prompt"): | |
if topic.strip(): | |
ai_prompt = generate_prompt(topic, difficulty, num_questions) | |
st.write(f"Generated Prompt: {ai_prompt}") | |
else: | |
st.warning("Please enter a topic before generating a prompt.") | |
# Get AI response | |
if st.button("Get Response"): | |
if topic.strip(): | |
ai_prompt = generate_prompt(topic, difficulty, num_questions) | |
ai_response = get_ai_response(ai_prompt) | |
st.write(ai_response) | |
else: | |
st.warning("Please generate a prompt first before getting a response.") |