Spaces:
Runtime error
Runtime error
File size: 1,249 Bytes
874cda9 a62ed30 874cda9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import os
from google import genai
from google.genai import types
import gradio as gr
client=genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
Question_type={
"MCQs":"Generate question of MCQs type based upon the content given.",
"Short Answer":"Generate question of short-answer type based upon the content given.",
"Interview":"Generate question of Interview type based upon the content given."
}
def question_generator(content,question_type):
system_prompt=Question_type[question_type]
response=client.models.generate_content(
model="gemini-2.0-flash",
config=types.GenerateContentConfig(
system_instruction=system_prompt,
temperature=0.7,
max_output_tokens=1000
),
contents=content
)
return response.text
demo=gr.Interface(
fn=question_generator,
inputs=[gr.Textbox(lines=4,placeholder="Paste Content/study material...",label="inputContent"),
gr.Dropdown(choices=list(Question_type.keys()),label="question_type",value="MCQs")],
outputs=gr.Textbox(lines=12,label="Generated Questions"),
title="Question Generator",
description="Paste the Content/Study material and get the questions of the selected type."
)
demo.launch(debug=True)
|