Spaces:
Sleeping
Sleeping
first commit
Browse files- app.py +86 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from together import Together
|
4 |
+
import os
|
5 |
+
|
6 |
+
|
7 |
+
client = Together(api_key=os.environ.get('TOGETHER_API_KEY'))
|
8 |
+
|
9 |
+
|
10 |
+
# Function to create the system prompt based on the selected detector
|
11 |
+
def create_system_prompt():
|
12 |
+
system_prompt = """You are a expert GMAT profiler who specializes in understanding student profile. You use successful candidate profile as a baseline and compare it with current profile and provide recomendations on the good profile.
|
13 |
+
Analyze the users input and provide guidance on what candidate can do to achieve a target college admission.
|
14 |
+
Provide a detailed response in 500 words. Keep it bulleted. Only provide recommendations if user's profile is not good enough.
|
15 |
+
Always Provide the Response in following format only
|
16 |
+
Format -
|
17 |
+
Analysis : 4-5 lines
|
18 |
+
Recommendation : 4-5 points
|
19 |
+
Colleges attenable with current profile:
|
20 |
+
Target College Review and Recommendation:
|
21 |
+
"""
|
22 |
+
|
23 |
+
return system_prompt
|
24 |
+
|
25 |
+
# Function to get response from OpenAI API
|
26 |
+
def analyze_chat( gmat_score, gpa, target_college, work_experience, leadership_roles, extracurriculars, personal_statement):
|
27 |
+
system_prompt = create_system_prompt()
|
28 |
+
chat_input = """
|
29 |
+
User's Profile Data. Assess the following aspects:
|
30 |
+
- GMAT Score: {}
|
31 |
+
- Undergraduate GPA: {}
|
32 |
+
- Target College: {}
|
33 |
+
- Work Experience: {} years
|
34 |
+
- Leadership Roles: {}
|
35 |
+
- Extracurricular Activities: {}
|
36 |
+
- Personal Statement: {}
|
37 |
+
Provide a comprehensive analysis and recommendations.
|
38 |
+
""".format(gmat_score, gpa, target_college, work_experience, leadership_roles, extracurriculars, personal_statement)
|
39 |
+
response = client.chat.completions.create(
|
40 |
+
model="meta-llama/Llama-3.2-3B-Instruct-Turbo", # Change to the OpenAI model you prefer
|
41 |
+
messages=[
|
42 |
+
{"role": "system", "content": system_prompt},
|
43 |
+
{"role": "user", "content": chat_input}
|
44 |
+
],)
|
45 |
+
return response.choices[0].message.content.strip()
|
46 |
+
|
47 |
+
# Gradio interface
|
48 |
+
def gradio_interface(gmat_score, gpa, target_college, work_experience, leadership_roles, extracurriculars, personal_statement):
|
49 |
+
return analyze_chat( gmat_score, gpa, target_college, work_experience, leadership_roles, extracurriculars, personal_statement)
|
50 |
+
|
51 |
+
# Custom CSS for input restriction
|
52 |
+
custom_css = """
|
53 |
+
#input-textbox textarea {
|
54 |
+
maxlength: 210;
|
55 |
+
overflow: hidden;
|
56 |
+
resize: none;
|
57 |
+
}
|
58 |
+
"""
|
59 |
+
# Creating the Gradio UI
|
60 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.sky,font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"])) as demo:
|
61 |
+
with gr.Row():
|
62 |
+
gr.Markdown("## AI GMAT Profiler - Gozo Sensei")
|
63 |
+
with gr.Row():
|
64 |
+
with gr.Column(scale=2, min_width=300):
|
65 |
+
gmat_score = gr.Number(label="GMAT Score")
|
66 |
+
personal_statement = gr.TextArea(label="Enter your profile details", lines=4,elem_id="input-textbox",
|
67 |
+
info="Please ensure that any Personal Identifiable Information (PII) is removed before submitting the chat.")
|
68 |
+
|
69 |
+
with gr.Column(scale=2, min_width=300):
|
70 |
+
gpa = gr.Number(label="Undergraduate GPA")
|
71 |
+
work_experience = gr.Number(label="Work Experience (years)")
|
72 |
+
target_college = gr.Textbox(label="Target College")
|
73 |
+
with gr.Column(scale=2, min_width=300):
|
74 |
+
extracurriculars = gr.TextArea(label="Extracurricular Activities",lines=3)
|
75 |
+
leadership_roles = gr.TextArea(label="Leadership Roles",lines=3)
|
76 |
+
with gr.Row():
|
77 |
+
gr.Markdown("## Response")
|
78 |
+
with gr.Row():
|
79 |
+
output = gr.TextArea(label="Analysis",info="Disclaimer: The information provided below is generated by AI based on text analytics with limited context. It must not be considered as absolute truth or final judgment.", interactive = False, max_lines=20)
|
80 |
+
with gr.Row():
|
81 |
+
btn = gr.Button("Analyze")
|
82 |
+
btn.click(fn=gradio_interface, inputs=[gmat_score, gpa, target_college, work_experience, leadership_roles, extracurriculars, personal_statement], outputs=output)
|
83 |
+
|
84 |
+
# Launch the app
|
85 |
+
demo.launch()
|
86 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
together
|