Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import gradio as gr
|
| 3 |
-
import google.generativeai as genai
|
| 4 |
-
|
| 5 |
-
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
|
| 6 |
-
|
| 7 |
-
if not GOOGLE_API_KEY:
|
| 8 |
-
raise RuntimeError("GOOGLE_API_KEY not found. Please set it in Hugging Face Secrets.")
|
| 9 |
-
|
| 10 |
-
genai.configure(api_key=GOOGLE_API_KEY)
|
| 11 |
-
|
| 12 |
-
model = genai.GenerativeModel("gemini-2.0-flash")
|
| 13 |
-
|
| 14 |
-
def generate_distractors(question):
|
| 15 |
-
try:
|
| 16 |
-
prompt = f"""
|
| 17 |
-
You are a multiple-choice question assistant.
|
| 18 |
-
Generate:
|
| 19 |
-
1. The correct answer
|
| 20 |
-
2. Three confusing but incorrect distractors
|
| 21 |
-
3. One-line explanation for each distractor
|
| 22 |
-
|
| 23 |
-
Question: {question}
|
| 24 |
-
"""
|
| 25 |
-
response = model.generate_content(prompt)
|
| 26 |
-
return response.text
|
| 27 |
-
except Exception as e:
|
| 28 |
-
return f" Error: {e}"
|
| 29 |
-
|
| 30 |
-
iface = gr.Interface(
|
| 31 |
-
fn=generate_distractors,
|
| 32 |
-
inputs=gr.Textbox(label="MCQ Question", placeholder="e.g., What is the capital of France?"),
|
| 33 |
-
outputs=gr.Textbox(label="Response"),
|
| 34 |
-
title="Confusing Distractor Generator",
|
| 35 |
-
description="Enter a question. Generates one correct answer and three confusing distractors with explanations."
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
if __name__ == "__main__":
|
| 39 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|