Umesh-960 commited on
Commit
8bc6a58
·
verified ·
1 Parent(s): 073eb81

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirement.txt +2 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from google import genai
3
+ from google.genai import types
4
+ import gradio as gr
5
+ from google.colab import userdata
6
+
7
+ client=genai.Client(api_key=os.get("GEMINI_API_KEY"))
8
+
9
+ Question_type={
10
+ "MCQs":"Generate question of MCQs type based upon the content given.",
11
+ "Short Answer":"Generate question of short-answer type based upon the content given.",
12
+ "Interview":"Generate question of Interview type based upon the content given."
13
+ }
14
+ def question_generator(content,question_type):
15
+ system_prompt=Question_type[question_type]
16
+
17
+ response=client.models.generate_content(
18
+ model="gemini-2.5-flash",
19
+ config=types.GenerateContentConfig(
20
+ system_instruction=system_prompt,
21
+ temperature=0.7,
22
+ max_output_tokens=1000
23
+ ),
24
+ Contents=content
25
+ )
26
+ return response.text
27
+
28
+ demo=gr.Interface(
29
+ fn=question_generator,
30
+ inputs=[gr.Textbox(lines=4,placeholder="Paste Content/study material...",label="inputContent"),
31
+ gr.Dropdown(choices=list(Question_type.keys()),label="question_type",value="MCQs")],
32
+ outputs=gr.Textbox(lines=12,label="Generated Questions"),
33
+ title="Question Generator",
34
+ description="Paste the Content/Study material and get the questions of the selected type."
35
+ )
36
+
37
+ demo.launch(debug=True)
requirement.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ google-genai