sekuxrious commited on
Commit
09f4295
·
verified ·
1 Parent(s): 54131ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -52
app.py CHANGED
@@ -1,24 +1,46 @@
1
  import gradio as gr
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  def generate_cv(
4
  email,
5
  date_of_birth,
6
  mbti,
7
- sustainable_dev_goals,
8
- via_strength_1,
9
- via_strength_2,
10
- via_strength_3,
11
- via_strength_4,
12
- via_strength_5,
13
  disc_d,
14
  disc_i,
15
  disc_s,
16
  disc_c,
17
- big5_extroversion,
18
- big5_emotional_stability,
19
- big5_agreeableness,
20
  big5_conscientiousness,
21
- big5_intellect,
 
 
22
  past_project,
23
  influences,
24
  main_passions,
@@ -29,52 +51,55 @@ def generate_cv(
29
  vision
30
  ):
31
  """
32
- Generates a text-based CV with Markdown tables.
33
- Adjust the field order and names as needed.
 
34
  """
35
 
 
 
 
 
 
 
 
36
  cv_text = f"""
37
  # CV Template
38
 
39
  ## Essential Information
40
-
41
- | Field | Details |
42
- |---------------------------------|-------------------------------------------------|
43
- | **Email Address** | {email} |
44
- | **Date of Birth** | {date_of_birth} |
45
- | **16 Personalities (MBTI)** | {mbti} |
46
- | **Sustainable Development Goals** | {sustainable_dev_goals} |
47
- | **VIA Strengths (Top 5)** | 1. {via_strength_1}<br>2. {via_strength_2}<br>3. {via_strength_3}<br>4. {via_strength_4}<br>5. {via_strength_5} |
48
 
49
  ## Personality Profile
50
-
51
- | Field | Details |
52
- |-------------------|---------------------------------------------------------------------------------------------------------|
53
- | **DISC (D, I, S, C)** | D: {disc_d}%<br>I: {disc_i}%<br>S: {disc_s}%<br>C: {disc_c}% |
54
- | **Big Five (OCEAN)** | Extroversion: {big5_extroversion}%<br>Emotional Stability: {big5_emotional_stability}%<br>Agreeableness: {big5_agreeableness}%<br>Conscientiousness: {big5_conscientiousness}%<br>Intellect/Imagination: {big5_intellect}% |
55
 
56
  ## Interests & Passions
57
-
58
- | Field | Details |
59
- |-------------------------------------------------|------------------------------------------|
60
- | **Past Project or Workplace You Loved (Why)** | {past_project} |
61
- | **People, Books, Courses, or Resources That Shaped You (Why)** | {influences} |
62
- | **Main Passions and Topics of Interest** | {main_passions} |
63
 
64
  ## Collaboration Preferences
65
-
66
- | Field | Details |
67
- |--------------------------------------------------|-------------------------------------------------|
68
- | **Preferred Country & Town for Meetups** | {preferred_location} |
69
- | **Ideal Work Environment** | {ideal_work_environment} |
70
- | **Most Productive Time of Day/Night** | {productive_time} |
71
- | **Qualities in an Ideal Partner (Professional/Personal)** | {partner_qualities} |
72
- | **Vision for Future Collaboration or Partnership** | {vision} |
73
  """
74
  return cv_text.strip()
75
 
76
-
77
- # Create a Gradio interface that matches the function's parameter order
78
  demo = gr.Interface(
79
  fn=generate_cv,
80
  inputs=[
@@ -82,20 +107,16 @@ demo = gr.Interface(
82
  "text", # date_of_birth
83
  "text", # mbti
84
  "text", # sustainable_dev_goals
85
- "text", # via_strength_1
86
- "text", # via_strength_2
87
- "text", # via_strength_3
88
- "text", # via_strength_4
89
- "text", # via_strength_5
90
  "text", # disc_d
91
  "text", # disc_i
92
  "text", # disc_s
93
  "text", # disc_c
94
- "text", # big5_extroversion
95
- "text", # big5_emotional_stability
96
- "text", # big5_agreeableness
97
  "text", # big5_conscientiousness
98
- "text", # big5_intellect
 
 
99
  "text", # past_project
100
  "text", # influences
101
  "text", # main_passions
@@ -103,10 +124,10 @@ demo = gr.Interface(
103
  "text", # ideal_work_environment
104
  "text", # productive_time
105
  "text", # partner_qualities
106
- "text", # vision
107
  ],
108
  outputs="text",
109
- title="CV Template with Markdown Tables"
110
  )
111
 
112
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ def bulletify(text_string, prefix="- "):
4
+ """
5
+ Takes a comma-separated string (e.g. "Goal1, Goal2")
6
+ and returns multiple lines with the given prefix:
7
+ "- Goal1<br>- Goal2"
8
+ If text_string is empty, returns an empty string.
9
+ """
10
+ items = [x.strip() for x in text_string.split(",") if x.strip()]
11
+ if not items:
12
+ return ""
13
+ return "<br>".join(f"{prefix}{item}" for item in items)
14
+
15
+ def numbered_listify(text_string):
16
+ """
17
+ Takes a comma-separated string (e.g. "Strength1, Strength2")
18
+ and returns a numbered list:
19
+ "1. Strength1<br>2. Strength2"
20
+ """
21
+ items = [x.strip() for x in text_string.split(",") if x.strip()]
22
+ if not items:
23
+ return ""
24
+ lines = []
25
+ for i, item in enumerate(items, start=1):
26
+ lines.append(f"{i}. {item}")
27
+ return "<br>".join(lines)
28
+
29
  def generate_cv(
30
  email,
31
  date_of_birth,
32
  mbti,
33
+ sustainable_dev_goals, # e.g. "8. Decent Work, 9. Industry Innovation"
34
+ via_strengths, # e.g. "Creativity, Curiosity, Leadership, ..."
 
 
 
 
35
  disc_d,
36
  disc_i,
37
  disc_s,
38
  disc_c,
39
+ big5_openness, # a.k.a. "Big5 - Openness" or "Big5 - Extroversion," etc.
 
 
40
  big5_conscientiousness,
41
+ big5_extraversion,
42
+ big5_agreeableness,
43
+ big5_emotional_stability,
44
  past_project,
45
  influences,
46
  main_passions,
 
51
  vision
52
  ):
53
  """
54
+ Generates a text-based CV (Markdown tables) with bullet lists for multi-select fields.
55
+ NOTE: Make.com should combine multi-select choices into comma-separated strings
56
+ before sending here.
57
  """
58
 
59
+ # Convert multi-select fields into bullet/numbered lines:
60
+ sdg_bullets = bulletify(sustainable_dev_goals) # each item -> separate bullet
61
+ via_bullets = numbered_listify(via_strengths) # each item -> separate numbered line
62
+ productive_time_bullets = bulletify(productive_time) # if multiple time blocks
63
+
64
+ main_passions_bullets = bulletify(main_passions) # optional if multi-select
65
+
66
  cv_text = f"""
67
  # CV Template
68
 
69
  ## Essential Information
70
+ | Field | Details |
71
+ |-----------------------------------|--------------------------------------------------------------|
72
+ | **Email Address** | {email} |
73
+ | **Date of Birth** | {date_of_birth} |
74
+ | **16 Personalities (MBTI)** | {mbti} |
75
+ | **Sustainable Development Goals** | {sdg_bullets if sdg_bullets else "N/A"} |
76
+ | **VIA Strengths (Top 5)** | {via_bullets if via_bullets else "N/A"} |
 
77
 
78
  ## Personality Profile
79
+ | Field | Details |
80
+ |---------------------|-----------------------------------------------------------------------------------------------------|
81
+ | **DISC (D, I, S, C)** | D: {disc_d}%<br>I: {disc_i}%<br>S: {disc_s}%<br>C: {disc_c}% |
82
+ | **Big Five (OCEAN)** | Openness: {big5_openness}%<br>Conscientiousness: {big5_conscientiousness}%<br>Extraversion: {big5_extraversion}%<br>Agreeableness: {big5_agreeableness}%<br>Emotional Stability: {big5_emotional_stability}% |
 
83
 
84
  ## Interests & Passions
85
+ | Field | Details |
86
+ |------------------------------------------------------|----------------------------------------------|
87
+ | **Past Project or Workplace You Loved (Why)** | {past_project} |
88
+ | **People, Books, Courses, or Resources That Shaped You (Why)** | {influences} |
89
+ | **Main Passions & Topics of Interest** | {main_passions_bullets if main_passions_bullets else main_passions} |
 
90
 
91
  ## Collaboration Preferences
92
+ | Field | Details |
93
+ |---------------------------------------------------|-----------------------------------------------------|
94
+ | **Preferred Country & Town for Meetups** | {preferred_location} |
95
+ | **Ideal Work Environment** | {ideal_work_environment} |
96
+ | **Most Productive Time of Day/Night** | {productive_time_bullets if productive_time_bullets else productive_time} |
97
+ | **Qualities in an Ideal Partner (Professional/Personal)** | {partner_qualities} |
98
+ | **Vision for Future Collaboration or Partnership** | {vision} |
 
99
  """
100
  return cv_text.strip()
101
 
102
+ # GRADIO INTERFACE
 
103
  demo = gr.Interface(
104
  fn=generate_cv,
105
  inputs=[
 
107
  "text", # date_of_birth
108
  "text", # mbti
109
  "text", # sustainable_dev_goals
110
+ "text", # via_strengths
 
 
 
 
111
  "text", # disc_d
112
  "text", # disc_i
113
  "text", # disc_s
114
  "text", # disc_c
115
+ "text", # big5_openness
 
 
116
  "text", # big5_conscientiousness
117
+ "text", # big5_extraversion
118
+ "text", # big5_agreeableness
119
+ "text", # big5_emotional_stability
120
  "text", # past_project
121
  "text", # influences
122
  "text", # main_passions
 
124
  "text", # ideal_work_environment
125
  "text", # productive_time
126
  "text", # partner_qualities
127
+ "text" # vision
128
  ],
129
  outputs="text",
130
+ title="CV Template with Markdown Tables + Bullets"
131
  )
132
 
133
  demo.launch()