Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,64 @@ openai.api_base = "https://api.groq.com/openai/v1"
|
|
| 8 |
|
| 9 |
# Function to get response from GROQ API
|
| 10 |
def get_groq_response(message, category):
|
|
|
|
| 11 |
system_message = ""
|
| 12 |
-
if category == "
|
| 13 |
-
system_message = "Provide
|
| 14 |
-
elif category == "
|
| 15 |
-
system_message = "
|
| 16 |
-
elif category == "
|
| 17 |
-
system_message = "Provide
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
elif category == "Friendly Buddy":
|
| 19 |
-
system_message = "Respond as a supportive and fun friend. Be informal and light-hearted."
|
|
|
|
|
|
|
| 20 |
|
| 21 |
try:
|
| 22 |
response = openai.ChatCompletion.create(
|
|
@@ -94,7 +143,15 @@ with chat_interface:
|
|
| 94 |
with gr.Row():
|
| 95 |
user_input = gr.Textbox(label="Your Message", placeholder="Type something...", lines=2)
|
| 96 |
category_dropdown = gr.Dropdown(
|
| 97 |
-
choices=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
label="Choose Chat Category"
|
| 99 |
)
|
| 100 |
with gr.Row():
|
|
|
|
| 8 |
|
| 9 |
# Function to get response from GROQ API
|
| 10 |
def get_groq_response(message, category):
|
| 11 |
+
# Define system message based on category
|
| 12 |
system_message = ""
|
| 13 |
+
if category == "Study Tips":
|
| 14 |
+
system_message = "Provide effective study strategies, time management advice, and tips for staying organized and focused."
|
| 15 |
+
elif category == "Exam Preparation":
|
| 16 |
+
system_message = "Offer tips for preparing for exams, managing anxiety, and optimizing performance on test day."
|
| 17 |
+
elif category == "Project Guidance":
|
| 18 |
+
system_message = "Provide advice on how to tackle academic projects, group assignments, and presentations effectively."
|
| 19 |
+
elif category == "Time Management":
|
| 20 |
+
system_message = "Help the user manage their time effectively with practical scheduling and prioritization tips."
|
| 21 |
+
elif category == "Motivation & Focus":
|
| 22 |
+
system_message = "Provide encouraging advice to stay motivated and maintain focus on long-term goals."
|
| 23 |
+
elif category == "Building Confidence":
|
| 24 |
+
system_message = "Offer advice to help boost self-esteem, overcome self-doubt, and build confidence."
|
| 25 |
+
elif category == "Friendship & Social Skills":
|
| 26 |
+
system_message = "Provide tips for making friends, improving communication skills, and navigating social dynamics."
|
| 27 |
+
elif category == "Networking & Career Building":
|
| 28 |
+
system_message = "Offer advice on networking, building professional relationships, and finding internships or job opportunities."
|
| 29 |
+
elif category == "Work-Life Balance":
|
| 30 |
+
system_message = "Help the user balance academics, social life, and personal well-being."
|
| 31 |
+
elif category == "Mental Health":
|
| 32 |
+
system_message = "Provide empathetic advice to manage stress, anxiety, and other mental health challenges. Encourage seeking professional help when needed."
|
| 33 |
+
elif category == "Physical Health":
|
| 34 |
+
system_message = "Share tips for maintaining physical health, including fitness, sleep, and nutrition."
|
| 35 |
+
elif category == "Stress Management":
|
| 36 |
+
system_message = "Offer calming techniques and advice to handle stress effectively."
|
| 37 |
+
elif category == "Budgeting Tips":
|
| 38 |
+
system_message = "Provide practical advice for managing money, creating a budget, and saving effectively as a student."
|
| 39 |
+
elif category == "Finding Part-Time Jobs":
|
| 40 |
+
system_message = "Share tips for finding and balancing part-time work with academic responsibilities."
|
| 41 |
+
elif category == "Scholarships & Financial Aid":
|
| 42 |
+
system_message = "Provide advice on applying for scholarships, grants, and understanding financial aid options."
|
| 43 |
+
elif category == "Resume Building":
|
| 44 |
+
system_message = "Offer tips for creating an impressive resume tailored for internships or entry-level positions."
|
| 45 |
+
elif category == "Interview Preparation":
|
| 46 |
+
system_message = "Provide advice on how to prepare for interviews, including common questions and presentation tips."
|
| 47 |
+
elif category == "Skill Development":
|
| 48 |
+
system_message = "Suggest ways to build skills, gain certifications, and stand out in competitive fields."
|
| 49 |
+
elif category == "Exploring New Hobbies":
|
| 50 |
+
system_message = "Encourage trying new activities and provide ideas for hobbies that fit college life."
|
| 51 |
+
elif category == "Clubs & Extracurriculars":
|
| 52 |
+
system_message = "Offer advice on joining clubs, participating in activities, and enhancing the college experience."
|
| 53 |
+
elif category == "Creative Projects":
|
| 54 |
+
system_message = "Provide inspiration and resources for personal or group creative endeavors."
|
| 55 |
+
elif category == "Funny":
|
| 56 |
+
system_message = "Respond with humorous remarks and witty commentary. Be entertaining but remain respectful."
|
| 57 |
+
elif category == "Flirty":
|
| 58 |
+
system_message = "Respond playfully and with charm. Keep it light-hearted, fun, and appropriate."
|
| 59 |
+
elif category == "Scary":
|
| 60 |
+
system_message = "Respond with spooky or thrilling remarks. Set a mysterious and eerie tone."
|
| 61 |
+
elif category == "Business Mind":
|
| 62 |
+
system_message = "Respond with a sharp, professional focus. Offer strategic advice and maintain a results-driven tone."
|
| 63 |
+
elif category == "Extrovert":
|
| 64 |
+
system_message = "Respond with high energy and enthusiasm. Be engaging, sociable, and vibrant."
|
| 65 |
elif category == "Friendly Buddy":
|
| 66 |
+
system_message = "Respond as a supportive and fun friend. Be informal, cheerful, and light-hearted."
|
| 67 |
+
else:
|
| 68 |
+
system_message = "Category not recognized. Respond appropriately to the user's input."
|
| 69 |
|
| 70 |
try:
|
| 71 |
response = openai.ChatCompletion.create(
|
|
|
|
| 143 |
with gr.Row():
|
| 144 |
user_input = gr.Textbox(label="Your Message", placeholder="Type something...", lines=2)
|
| 145 |
category_dropdown = gr.Dropdown(
|
| 146 |
+
choices=[
|
| 147 |
+
"Stress Management", "Career Advice", "General", "Friendly Buddy", "Study Tips", "Exam Preparation",
|
| 148 |
+
"Project Guidance", "Time Management", "Motivation & Focus", "Building Confidence",
|
| 149 |
+
"Friendship & Social Skills", "Networking & Career Building", "Work-Life Balance",
|
| 150 |
+
"Mental Health", "Physical Health", "Budgeting Tips", "Finding Part-Time Jobs",
|
| 151 |
+
"Scholarships & Financial Aid", "Resume Building", "Interview Preparation", "Skill Development",
|
| 152 |
+
"Exploring New Hobbies", "Clubs & Extracurriculars", "Creative Projects", "Funny",
|
| 153 |
+
"Flirty", "Scary", "Business Mind", "Extrovert"
|
| 154 |
+
],
|
| 155 |
label="Choose Chat Category"
|
| 156 |
)
|
| 157 |
with gr.Row():
|