Spaces:
Sleeping
Sleeping
File size: 1,827 Bytes
785ef44 3163b7e 785ef44 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from langchain_groq import ChatGroq
from langchain_core.prompts import PromptTemplate
import streamlit as st
import os
groq_api_key = st.secrets["API_KEY"]
os.environ["GROQ_API_KEY"] = groq_api_key
chat = ChatGroq(temperature=0, model_name="mixtral-8x7b-32768")
template = """
You are an expert in creating engaging and funny quiz questions for various audiences.
Your task is to generate math quiz questions around the given topic for the host to use.
Make sure the questions are engaging, funny, and tailored to the audience's expertise level and role.
**ROLE**: {role}
**TOPIC**: {topic}
**AUDIENCE EXPERTISE**: {audience_expertise}
**NUMBER OF QUESTIONS**: {num_questions}
-Generate the quiz questions and provide them with the correct answers.
-Generate mcq types questions with 4 options each.
"""
prompt = PromptTemplate(template=template)
st.title("Math Quiz Bot")
# Collect user input for the quiz parameters
role = st.selectbox("Select the audience role:", ["Student", "Teacher", "Engineer", "Data Scientist", "Data Analyst"])
topic = st.selectbox("Select the topic:", ["Algebra", "Calculus", "Geometry", "Statistics"])
audience_expertise = st.selectbox("Select the audience expertise level:", ["Beginner", "Intermediate", "Expert"])
num_questions = st.number_input("Enter the number of questions:", min_value=1, max_value=50)
if st.button("Generate Quiz"):
# Format the prompt with the collected details
input_prompt = prompt.format(
topic=topic,
role=role,
audience_expertise=audience_expertise,
num_questions=num_questions
)
st.write("**Generated Prompt:**")
st.write(input_prompt)
# Invoke the chat model and get the response
response = chat.invoke(input_prompt)
st.write("**Generated Quiz Questions:**")
st.write(response.content)
|