Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -55,13 +55,13 @@ def generate_question_with_chatgpt(context):
|
|
55 |
response = requests.post(CHATGPT_API_ENDPOINT, json=data, headers=headers)
|
56 |
result = response.json()
|
57 |
|
58 |
-
|
59 |
# Extract the generated question from the response
|
60 |
generated_question = result["choices"][0]["message"]["content"]
|
61 |
|
62 |
# Decode the byte string to Unicode string
|
63 |
generated_question = generated_question.decode("utf-8")
|
64 |
-
|
65 |
|
66 |
def main():
|
67 |
# Title of the Application
|
@@ -74,7 +74,7 @@ def main():
|
|
74 |
topic = st.text_input("Enter the Topic in which the quiz has to be generated")
|
75 |
|
76 |
# Button to trigger QUIZ generation
|
77 |
-
if st.button("Generate
|
78 |
if pdf_file:
|
79 |
text = extract_text_from_pdf(pdf_file)
|
80 |
mcqs = generate_mcqs_on_topic(text, topic, num_mcqs)
|
|
|
55 |
response = requests.post(CHATGPT_API_ENDPOINT, json=data, headers=headers)
|
56 |
result = response.json()
|
57 |
|
58 |
+
if 'choices' in result:
|
59 |
# Extract the generated question from the response
|
60 |
generated_question = result["choices"][0]["message"]["content"]
|
61 |
|
62 |
# Decode the byte string to Unicode string
|
63 |
generated_question = generated_question.decode("utf-8")
|
64 |
+
return generated_question
|
65 |
|
66 |
def main():
|
67 |
# Title of the Application
|
|
|
74 |
topic = st.text_input("Enter the Topic in which the quiz has to be generated")
|
75 |
|
76 |
# Button to trigger QUIZ generation
|
77 |
+
if st.button("Generate Quiz"):
|
78 |
if pdf_file:
|
79 |
text = extract_text_from_pdf(pdf_file)
|
80 |
mcqs = generate_mcqs_on_topic(text, topic, num_mcqs)
|