Chad commited on
Commit ·
8d46470
1
Parent(s): a3728af
45672uwwewewewedwdwdwd
Browse files
app.py
CHANGED
|
@@ -45,24 +45,25 @@ def generate_reply(user_input, chat_history):
|
|
| 45 |
return chat_history, chat_history, ""
|
| 46 |
|
| 47 |
def generate_quiz(subject, num_questions):
|
| 48 |
-
|
| 49 |
try:
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
except Exception as error:
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
|
| 67 |
def toggle_language(language):
|
| 68 |
"""Toggle UI elements between English and French."""
|
|
|
|
| 45 |
return chat_history, chat_history, ""
|
| 46 |
|
| 47 |
def generate_quiz(subject, num_questions):
|
| 48 |
+
"""Generate a history quiz with multiple-choice questions."""
|
| 49 |
try:
|
| 50 |
+
prompt = f"Generate {num_questions} multiple-choice history questions about {subject}. "
|
| 51 |
+
prompt += "For each question, provide the question text, four options labeled A, B, C, and D, and at the end of all questions, list the correct answers in the format: 'Correct Answers: X, Y, Z, ...'."
|
| 52 |
+
|
| 53 |
+
response = client.chat.completions.create(
|
| 54 |
+
model="llama3-70b-8192",
|
| 55 |
+
messages=[{"role": "user", "content": prompt}],
|
| 56 |
+
temperature=0.7,
|
| 57 |
+
max_completion_tokens=1024,
|
| 58 |
+
top_p=0.95,
|
| 59 |
+
stream=False,
|
| 60 |
+
stop=None,
|
| 61 |
+
)
|
| 62 |
+
quiz_content = response.choices[0].message.content or "Error generating quiz."
|
| 63 |
except Exception as error:
|
| 64 |
+
quiz_content = f"Error: {error}"
|
| 65 |
+
|
| 66 |
+
return quiz_content
|
| 67 |
|
| 68 |
def toggle_language(language):
|
| 69 |
"""Toggle UI elements between English and French."""
|