DSatishchandra commited on
Commit
58ce706
·
verified ·
1 Parent(s): 11ad1cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -43
app.py CHANGED
@@ -1,50 +1,71 @@
 
 
1
  from modules.profile_matcher import match_profiles
2
  from modules.interview_scheduler import suggest_slots
3
- from modules.kyc_processor import extract_text_from_id
4
  from modules.onboarding_trainer import generate_quiz
5
  from modules.performance_tracker import analyze_performance
6
  from modules.agent_motivation import personalized_nudge
7
- import gradio as gr
8
 
9
- def kyc_interface(uploaded_image):
 
 
 
 
 
 
 
 
 
 
 
 
10
  try:
11
- return extract_text_from_id(uploaded_image)
12
- except Exception as e:
13
- return f"Error: {str(e)}"
14
-
15
- # 1. Profile Matching
16
- print("\n[1] Profile Matching:")
17
- resume = "Experienced insurance agent with proven sales..."
18
- job = "Insurance Sales Agent"
19
- print("Match:", match_profiles(resume, job))
20
-
21
- # 2. Interview Scheduling
22
- print("\n[2] Interview Scheduling:")
23
- slots = suggest_slots({'2025-06-20': ['10:00 AM', '3:00 PM']})
24
- print("Suggested:", slots)
25
-
26
- # 4. Onboarding Quiz
27
- print("\n[4] AI Onboarding Quiz:")
28
- quiz = generate_quiz("Insurance Policy")
29
- print("Quiz:", quiz)
30
-
31
- # 5. Performance Tracking
32
- print("\n[5] Agent Performance Alerts:")
33
- agents = [{'name': 'Ravi', 'sales': 3}, {'name': 'Priya', 'sales': 8}]
34
- print("Alerts:", analyze_performance(agents))
35
-
36
- # 6. Motivation
37
- print("\n[6] Motivation Nudges:")
38
- print(personalized_nudge("Ravi", "10 client meetings"))
39
-
40
- def main():
41
- gr.Interface(
42
- fn=kyc_interface,
43
- inputs=gr.Image(type="filepath", label="Upload ID Document"),
44
- outputs="text",
45
- title="KYC Document OCR",
46
- description="Upload an image of an ID card for OCR-based text extraction."
47
- ).launch()
48
-
49
- if __name__ == "__main__":
50
- main()
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from modules.kyc_processor import extract_text_from_id
3
  from modules.profile_matcher import match_profiles
4
  from modules.interview_scheduler import suggest_slots
 
5
  from modules.onboarding_trainer import generate_quiz
6
  from modules.performance_tracker import analyze_performance
7
  from modules.agent_motivation import personalized_nudge
 
8
 
9
+ def run_kyc(image):
10
+ return extract_text_from_id(image)
11
+
12
+ def run_profile_match(resume, job_role):
13
+ return match_profiles(resume, job_role)
14
+
15
+ def run_schedule(availability):
16
+ return suggest_slots(eval(availability)) # input as a dict
17
+
18
+ def run_quiz(topic):
19
+ return generate_quiz(topic)
20
+
21
+ def run_performance(agent_data):
22
  try:
23
+ agents = eval(agent_data)
24
+ return "\n".join(analyze_performance(agents))
25
+ except:
26
+ return "Invalid data format. Use: [{'name': 'A', 'sales': 5}, ...]"
27
+
28
+ def run_motivation(name, goal):
29
+ return personalized_nudge(name, goal)
30
+
31
+ with gr.Blocks(title="Agent Recruitment & Management Suite") as demo:
32
+
33
+ with gr.Tab("KYC OCR"):
34
+ gr.Markdown("### Upload an ID Document for OCR")
35
+ image_input = gr.Image(type="filepath")
36
+ ocr_output = gr.Textbox(label="Extracted Text")
37
+ gr.Button("Extract").click(run_kyc, inputs=image_input, outputs=ocr_output)
38
+
39
+ with gr.Tab("Agent Profile Matcher"):
40
+ gr.Markdown("### Compare Resume with Job Role")
41
+ resume_input = gr.Textbox(label="Resume Text")
42
+ job_input = gr.Textbox(label="Job Role Description")
43
+ match_output = gr.Textbox(label="Match Result")
44
+ gr.Button("Check Match").click(run_profile_match, [resume_input, job_input], match_output)
45
+
46
+ with gr.Tab("Interview Scheduler"):
47
+ gr.Markdown("### Suggest Interview Slots")
48
+ schedule_input = gr.Textbox(label="Availability Dict (e.g. {'2025-06-21': ['10AM', '2PM']})")
49
+ schedule_output = gr.Textbox(label="Suggested Slots")
50
+ gr.Button("Suggest").click(run_schedule, schedule_input, schedule_output)
51
+
52
+ with gr.Tab("Training Quiz"):
53
+ gr.Markdown("### Generate Quiz for a Topic")
54
+ topic_input = gr.Textbox(label="Training Topic")
55
+ quiz_output = gr.JSON(label="Generated Quiz")
56
+ gr.Button("Generate Quiz").click(run_quiz, topic_input, quiz_output)
57
+
58
+ with gr.Tab("Performance Tracker"):
59
+ gr.Markdown("### Enter Agent Sales Data")
60
+ performance_input = gr.Textbox(label="Agent List (e.g. [{'name': 'A', 'sales': 3}])")
61
+ performance_output = gr.Textbox(label="Alerts")
62
+ gr.Button("Analyze").click(run_performance, performance_input, performance_output)
63
+
64
+ with gr.Tab("Motivational Nudge"):
65
+ gr.Markdown("### Send Motivation to Agent")
66
+ name_input = gr.Textbox(label="Agent Name")
67
+ goal_input = gr.Textbox(label="Goal (e.g. 10 meetings)")
68
+ nudge_output = gr.Textbox(label="Generated Nudge")
69
+ gr.Button("Motivate").click(run_motivation, [name_input, goal_input], nudge_output)
70
+
71
+ demo.launch()