Wendgan commited on
Commit
b846f85
·
verified ·
1 Parent(s): 79d9148

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -2,7 +2,11 @@ import os
2
  import gradio as gr
3
  import google.generativeai as genai
4
 
5
- GOOGLE_API_KEY = os.environ.get("AIzaSyCqh6P7W0kX7Hkeo-j280RBZLk6ddxx9CU")
 
 
 
 
6
  genai.configure(api_key=GOOGLE_API_KEY)
7
 
8
  model = genai.GenerativeModel("gemini-1.5-flash")
@@ -21,14 +25,14 @@ Question: {question}
21
  response = model.generate_content(prompt)
22
  return response.text
23
  except Exception as e:
24
- return f" Error: {e}"
25
 
26
  iface = gr.Interface(
27
  fn=generate_distractors,
28
  inputs=gr.Textbox(label="MCQ Question", placeholder="e.g., What is the capital of France?"),
29
  outputs=gr.Textbox(label="Response"),
30
  title="Confusing Distractor Generator",
31
- description="Enter a multiple-choice question. This app uses Gemini to generate one correct answer, three distractors, and explanations."
32
  )
33
 
34
  if __name__ == "__main__":
 
2
  import gradio as gr
3
  import google.generativeai as genai
4
 
5
+ GOOGLE_API_KEY = os.environ.get("AIzaSyDSCQ1RkrsQr4tSES7KlR1uq2O31yPRSHY")
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-1.5-flash")
 
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__":