BeyondJawad commited on
Commit
3a46943
Β·
verified Β·
1 Parent(s): 02e4de6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -10
app.py CHANGED
@@ -1,14 +1,46 @@
1
  import gradio as gr
 
 
2
 
3
- def chat(user_input):
4
- return f"πŸ‘‹ Hi! I'm SkillLinkAI β€” your study and job assistant.\nYou said: {user_input}"
 
5
 
6
- iface = gr.Interface(
7
- fn=chat,
8
- inputs="text",
9
- outputs="text",
10
- title="SkillLinkAI",
11
- description="Study smarter, find jobs, and get personalized AI help β€” all free!"
12
- )
 
 
 
 
 
 
 
 
13
 
14
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import requests
3
+ import pandas as pd
4
 
5
+ # --- Job Data Source (Google Sheet optional) ---
6
+ # You can later replace this with your own Google Sheet CSV link
7
+ JOB_SOURCE = "https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv" # sample placeholder
8
 
9
+ # --- Core Chat Function ---
10
+ def chat_with_ai(user_input, mode):
11
+ # Mode-based responses
12
+ if mode == "Study Help":
13
+ return f"πŸ“˜ StudyMate AI:\nHere's a helpful summary for your query:\n\nβ†’ {user_input}\n\nπŸ’‘Tip: Try asking 'Explain physics in simple Urdu'."
14
+ elif mode == "Job Finder":
15
+ try:
16
+ df = pd.read_csv(JOB_SOURCE)
17
+ results = df.sample(3)[['State', 'Rank']].to_dict('records')
18
+ job_list = "\n".join([f"- {r['State']} | Rank: {r['Rank']}" for r in results])
19
+ return f"πŸ’Ό StudyMate Job Finder:\nBased on your skill '{user_input}', here are sample job regions:\n\n{job_list}\n\n(Real data will appear once you connect your Google Sheet)"
20
+ except Exception as e:
21
+ return f"⚠️ Error fetching job data: {e}"
22
+ else:
23
+ return f"πŸ€– StudyMate AI: {user_input}"
24
 
25
+ # --- UI Layout ---
26
+ with gr.Blocks(css="""
27
+ body {background: radial-gradient(circle at top left, rgba(255,255,255,0.3), rgba(0,0,0,0.7));}
28
+ .gradio-container {backdrop-filter: blur(12px); border-radius: 20px; padding: 25px;}
29
+ textarea, input {border-radius: 10px !important;}
30
+ """) as demo:
31
+ gr.Markdown("## 🧠 StudyMate AI β€” Learn, Grow & Get Hired\nWelcome to your smart AI assistant for study and skill-based jobs. 🌍")
32
+
33
+ with gr.Row():
34
+ mode = gr.Radio(["Study Help", "Job Finder"], label="Select Mode", value="Study Help")
35
+
36
+ with gr.Row():
37
+ user_input = gr.Textbox(label="Ask StudyMate AI", placeholder="e.g., How can I improve my English speaking?")
38
+
39
+ output = gr.Textbox(label="AI Response", lines=10)
40
+
41
+ submit = gr.Button("Ask ✨")
42
+ submit.click(fn=chat_with_ai, inputs=[user_input, mode], outputs=output)
43
+
44
+ gr.Markdown("### πŸ”Ή Features Coming Soon\n- Post jobs directly inside StudyMate\n- Real-time student community help\n- Urdu/Sindhi language support\n\nπŸ’¬ *Developed by Jawad*")
45
+
46
+ demo.launch()