Spaces:
Runtime error
Runtime error
| 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) | |