File size: 962 Bytes
7a2beb4
 
 
 
 
 
 
 
 
 
 
 
 
ff5c386
 
 
 
7a2beb4
5f67612
7a2beb4
 
 
 
 
 
 
 
 
 
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
import google.generativeai as genai
import gradio as gr

api_key = "AIzaSyAMfftpsTHFJx-4xhoOAKCM-Uc42SKOb98"

model = genai.GenerativeModel('gemini-pro')
genai.configure(api_key = api_key)
chat = model.start_chat(history=[])
temp = chat.send_message(f"""
    You are an expert quiz designer based on lecture notes LLM. Your task is to take notes of a lecture, and 
    turn them into notes.""")

def generate_quiz(prompt):
    input = prompt + """\n\nGenerate 5 questions from this , each of 4 OPTIONS ONLY ALWAYS PLEASE , NEVER EVERY GENERATE A QUESTION OF 2 OPTIONS.
PLEASE PLEASE PLEASE GIVE ME A JSON OUTPUT of this format:
[{questionText, questionOptions[](array of 4 strings), questionAnswerIndex}]"""

    output = chat.send_message(input)
    return output.text[8:-3]

iface = gr.Interface(
    fn= generate_quiz,
    inputs= "text",
    outputs= "text",
    title="Aeravat  Quiz Generation",
)
    
# Launch the Gradio interface
iface.launch(share=True)