AjayKr09 commited on
Commit
41d2f81
·
verified ·
1 Parent(s): 3097574

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from google import genai
3
+ import os
4
+ from google.genai import types
5
+ import gradio as gr
6
+
7
+ client = genai.Client(api_key = os.getenv('GEMINI_API_KEY'))
8
+
9
+ personalities = {
10
+ "Friendly": """You are a friendly, enthusiastic, and highly encouraging Study Assistant. Your goal is to break down complex concepts into simple,
11
+ beginner-friendly explanations. Use analogies and real-world examples that beginners can relate to. Always ask a follow-up question to check understanding""",
12
+ "Academic": """You are a strictly academic, highly detailed, and professional university Professor. Use precise, formal terminology, cite key concepts and
13
+ structure your response. Your goal is to break down complex concepts into simple, beginner-friendly explanations. Use analogies and real-world examples that
14
+ beginners can relate to. Always ask a follow-up question to check understanding"""
15
+ }
16
+
17
+ def study_assistant(question, persona):
18
+ system_prompt = personalities[persona]
19
+ response = client.models.generate_content(
20
+ model = "gemini-2.5-flash", contents = question,
21
+ config = types.GenerateContentConfig(system_instruction = system_prompt)
22
+ )
23
+ return response.text
24
+
25
+ demo = gr.Interface(fn = study_assistant,
26
+ inputs = [gr.Textbox(label = "Question", lines = 4, placeholder = "Ask a Question"),
27
+ gr.Radio(choices= list(personalities.keys()), value= "Friendly", label= "Personality")],
28
+ outputs = gr.Textbox(label = "Answer or Explaination", lines=10),
29
+ title = "Study Assistant",
30
+ description= "Ask a quesiton to get simple explaination")
31
+
32
+ demo.launch(debug= True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ google-genai
2
+ gradio