Justin Grammens commited on
Commit
7a39102
·
1 Parent(s): fe62f5d

updared with new questions

Browse files
Files changed (1) hide show
  1. app.py +114 -33
app.py CHANGED
@@ -15,22 +15,36 @@ template = """
15
  Turn these questions and answers into a five-paragraph essay about my approach to leadership. Please write the essay in the first person, using a conversational and engaging style, as if talking with a friend. Use simple, relatable language and avoid formalities. If needed, you may add a little text to add texture and depth to answers as long as it aligns with the research on effective leadership. Likewise, add personal touches and insights to make it feel genuine and approachable.
16
 
17
  Questions and Answers:
18
- 1. Three words that describe the culture: {q1}
19
- 2. How personal values align with work: {q2}
20
- 3. What drives me to come to work each day: {q3}
21
- 4. Areas I'm working on to be a better leader: {q4}
22
- 5. How I stay connected with daily operations: {q5}
23
- 6. What I want for the people I lead: {q6}
24
- 7. How I show dignity and respect: {q7}
25
- 8. How people perceive me: {q8}
26
- 9. How others describe my management style: {q9}
27
- 10. Three things you need to excel with me: {q10}
28
- 11. What people should always feel free to do: {q11}
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  """
30
 
31
  # Create a LangChain prompt template object
32
  prompt = PromptTemplate(
33
- input_variables=["q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11"],
 
34
  template=template,
35
  )
36
 
@@ -42,14 +56,26 @@ def stream_leadership_essay(*answers):
42
  yield "All fields are required.", "All fields are required."
43
  return
44
 
45
- if (answers[11] != secretcode):
 
 
 
 
 
 
 
46
  yield "Invalid secret code. Please try again.", "Invalid secret code. Please try again."
47
  return
 
48
 
49
  # Format the prompt with the answers
50
  filled_prompt = prompt.format(
51
- q1=answers[0], q2=answers[1], q3=answers[2], q4=answers[3], q5=answers[4],
52
- q6=answers[5], q7=answers[6], q8=answers[7], q9=answers[8], q10=answers[9], q11=answers[10]
 
 
 
 
53
  )
54
 
55
  # Send the prompt as a HumanMessage and stream the response
@@ -68,27 +94,44 @@ with gr.Blocks(
68
  gr.Markdown("# Personal Leadership Profile")
69
 
70
  gr.Markdown("""
71
- Like a great coach, great leaders have a solid understanding of their philosophy and consistently share it with others on the team. They passionately pursue excellence in their role. Leadership experts Jim Kouzes and Barry Posner said it this way - “Leading others begins with leading yourself, and you can’t do that until you will be able to answer that fundamental question about who you are. So, ‘who are you?’"
72
-
73
- According to 40 years of research by Kouzes and Posner, the most influential leaders have a clear Personal Leadership Profile (PLP) and communicate it often. Whether you’re a seasoned leader or just getting started in a leadership role, a PLP will allow you to articulate your values, goals, and the type of leader you aspire to be. The result is a strategic tool to help you improve your culture.
74
-
75
- Based on your answers, we will build a “draft” for you to revise, build upon, and use as a roadmap.
76
-
77
- Thank you for completing the PLP questions. It will be a cornerstone of your continued development.
78
  """)
79
 
80
  inputs = [
81
- gr.Textbox(label="Three words that describe the culture we are building include..."),
82
- gr.Textbox(label="My personal values align with our work in the following ways..."),
83
- gr.Textbox(label="Here’s what drives me to get up and come to work each day..."),
84
- gr.Textbox(label="I’m working on the following areas to be a better leader for my team."),
85
- gr.Textbox(label="I stay connected with the daily realities of our operations by..."),
86
- gr.Textbox(label="Here’s what I want for the people I lead and work with. I want them to..."),
87
- gr.Textbox(label="I take these actions to show dignity and respect to those I work with."),
88
- gr.Textbox(label="At times, people can perceive me as..."),
89
- gr.Textbox(label="Others have described my management style as..."),
90
- gr.Textbox(label="To excel with me, you need to do three things..."),
91
- gr.Textbox(label="When working with me, always feel free to..."),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  gr.Textbox(label="Enter the password to generate the essay")
93
  ]
94
 
@@ -112,4 +155,42 @@ with gr.Blocks(
112
  # Launch the Gradio app
113
  demo.launch()
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
 
 
 
 
15
  Turn these questions and answers into a five-paragraph essay about my approach to leadership. Please write the essay in the first person, using a conversational and engaging style, as if talking with a friend. Use simple, relatable language and avoid formalities. If needed, you may add a little text to add texture and depth to answers as long as it aligns with the research on effective leadership. Likewise, add personal touches and insights to make it feel genuine and approachable.
16
 
17
  Questions and Answers:
18
+ 1. Treating others with dignity and respect is critical. I strive to accomplish this by: {q1}
19
+ 2. A few of my core values are: {q2}
20
+ 3. I believe in continuous learning. Here’s how I stay committed to my development: {q3}
21
+ 4. When Im at my best, I: {q4}
22
+ 5. Under stress, you may notice that I: {q5}
23
+ 6. I gain energy and inspiration from: {q6}
24
+ 7. A personal motto or philosophy I live by is: {q7}
25
+ 8. My favorite quote about leadership is ___ because of ____ : {q8}
26
+ 9. Others have described my leadership or management style as: {q9}
27
+ 10. People who work for me are most successful when they: {q10}
28
+ 11. People sometimes perceive me as: {q11}
29
+ 12. To gain my trust and respect, you should: {q12}
30
+ 13. You have my full permission to: {q13}
31
+ 14. “Hot-button” behaviors that frustrate me include: {q14}
32
+ 15. Here’s how I like to give and receive feedback: {q15}
33
+ 16. If we encounter a disagreement, I prefer to resolve it by: {q16}
34
+ 17. Three things you should know about our department’s culture are: {q17}
35
+ 18. Three things that define the culture of our organization include: {q18}
36
+ 19. I love our work because we: {q19}
37
+ 20. The type of environment we strive to create for our team is: {q20}
38
+ 21. Key principles or practices that make our department unique are: {q21}
39
+ 22. Our team’s mission and what it means to us day-to-day is: {q22}
40
+ 23. The kind of reputation we aim to build as a department/organization is: {q23}
41
+ 24. We define success in our department by: {q24}
42
  """
43
 
44
  # Create a LangChain prompt template object
45
  prompt = PromptTemplate(
46
+ input_variables=["q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10",
47
+ "q11", "q12", "q13", "q14", "q15", "q16", "q17", "q18", "q19", "q20", "q21", "q22", "q23", "q24"],
48
  template=template,
49
  )
50
 
 
56
  yield "All fields are required.", "All fields are required."
57
  return
58
 
59
+ print("UPDATED")
60
+ print(answers[28])
61
+ # Check if the email is valid
62
+ if "@" not in answers[28]:
63
+ yield "Invalid email address. Please enter a valid email address.", "Invalid email address. Please enter a valid email address."
64
+ return
65
+
66
+ if (answers[29] != secretcode):
67
  yield "Invalid secret code. Please try again.", "Invalid secret code. Please try again."
68
  return
69
+
70
 
71
  # Format the prompt with the answers
72
  filled_prompt = prompt.format(
73
+ q1=answers[1], q2=answers[2], q3=answers[3], q4=answers[4],
74
+ q5=answers[5], q6=answers[6], q7=answers[7], q8=answers[8],
75
+ q9=answers[10], q10=answers[11],q11=answers[12], q12=answers[13],
76
+ q13=answers[13], q14=answers[14], q15=answers[15], q16=answers[16],
77
+ q17=answers[17], q18=answers[19], q19=answers[20], q20=answers[21],
78
+ q21=answers[22], q22=answers[23], q23=answers[24], q24=answers[25]
79
  )
80
 
81
  # Send the prompt as a HumanMessage and stream the response
 
94
  gr.Markdown("# Personal Leadership Profile")
95
 
96
  gr.Markdown("""
97
+ Please choose ten of the following questions to answer. Each response must be at least 40 characters.
98
+ Based on your answers, we will build a “draft” for you to revise, build upon, and use as a roadmap.
99
+ Thank you for completing the PLP questions - It will be a cornerstone of your continued development.
 
 
 
 
100
  """)
101
 
102
  inputs = [
103
+ gr.Markdown("### About Me"),
104
+ gr.Textbox(label="Treating others with dignity and respect is critical. I strive to accomplish this by..."),
105
+ gr.Textbox(label="A few of my core values are..."),
106
+ gr.Textbox(label="I believe in continuous learning. Here’s how I stay committed to my development..."),
107
+ gr.Textbox(label="When I’m at my best, I..."),
108
+ gr.Textbox(label="Under stress, you may notice that I..."),
109
+ gr.Textbox(label="I gain energy and inspiration from..."),
110
+ gr.Textbox(label="A personal motto or philosophy I live by is..."),
111
+ gr.Textbox(label="My favorite quote about leadership is ______ because _______"),
112
+
113
+ gr.Markdown("### About Working With Me:"),
114
+ gr.Textbox(label="Others have described my leadership or management style as..."),
115
+ gr.Textbox(label="People who work for me are most successful when they..."),
116
+ gr.Textbox(label="People sometimes perceive me as..."),
117
+ gr.Textbox(label="To gain my trust and respect, you should..."),
118
+ gr.Textbox(label="You have my full permission to..."),
119
+ gr.Textbox(label="\"Hot-button\" behaviors that frustrate me include..."),
120
+ gr.Textbox(label="Here’s how I like to give and receive feedback..."),
121
+ gr.Textbox(label="If we encounter a disagreement, I prefer to resolve it by..."),
122
+
123
+ gr.Markdown("### About Our Department/Organization:"),
124
+ gr.Textbox(label="Three things you should know about our department’s culture are..."),
125
+ gr.Textbox(label="Three things that define the culture of our organization include..."),
126
+ gr.Textbox(label="I love our work because we..."),
127
+ gr.Textbox(label="The type of environment we strive to create for our team is..."),
128
+ gr.Textbox(label="Key principles or practices that make our department unique are..."),
129
+ gr.Textbox(label="Our team’s mission and what it means to us day-to-day is..."),
130
+ gr.Textbox(label="The kind of reputation we aim to build as a department/organization is..."),
131
+ gr.Textbox(label="We define success in our department by..."),
132
+
133
+ gr.Markdown("### Validation Input:"),
134
+ gr.Textbox(label="Enter the email address of where to send the essay"),
135
  gr.Textbox(label="Enter the password to generate the essay")
136
  ]
137
 
 
155
  # Launch the Gradio app
156
  demo.launch()
157
 
158
+ # Automated testing function
159
+ """
160
+ def test_form_submission():
161
+ mock_data = [
162
+ "I treat others with dignity and respect by listening to their concerns.",
163
+ "My core values are integrity, honesty, and empathy.",
164
+ "I stay committed to my development by reading books and attending workshops.",
165
+ "When I’m at my best, I am focused and productive.",
166
+ "Under stress, you may notice that I become quiet and introspective.",
167
+ "I gain energy and inspiration from nature and music.",
168
+ "A personal motto I live by is 'Never give up.'",
169
+ "My favorite quote about leadership is 'Leadership is not about being in charge. It is about taking care of those in your charge.' because it emphasizes the importance of caring for others.",
170
+ "Others have described my leadership style as supportive and empowering.",
171
+ "People who work for me are most successful when they are proactive and communicative.",
172
+ "People sometimes perceive me as reserved and thoughtful.",
173
+ "To gain my trust and respect, you should be honest and reliable.",
174
+ "You have my full permission to provide constructive feedback.",
175
+ "Hot-button behaviors that frustrate me include dishonesty and lack of accountability.",
176
+ "Here’s how I like to give and receive feedback: I prefer direct and constructive feedback.",
177
+ "If we encounter a disagreement, I prefer to resolve it by having an open and honest conversation.",
178
+ "Three things you should know about our department’s culture are...",
179
+ "Three things that define the culture of our organization include...",
180
+ "I love our work because we...",
181
+ "The type of environment we strive to create for our team is...",
182
+ "Key principles or practices that make our department unique are...",
183
+ "Our team’s mission and what it means to us day-to-day is...",
184
+ "The kind of reputation we aim to build as a department/organization is...",
185
+ "We define success in our department by...",
186
+ "PLP"
187
+ ]
188
+
189
+ # Simulate form submission
190
+ result_generator = stream_leadership_essay(*mock_data)
191
+ for result in result_generator:
192
+ print(result)
193
 
194
+ # Run the test
195
+ test_form_submission()
196
+ """