Justin Grammens
commited on
Commit
·
7a39102
1
Parent(s):
fe62f5d
updared with new questions
Browse files
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.
|
19 |
-
2.
|
20 |
-
3.
|
21 |
-
4.
|
22 |
-
5.
|
23 |
-
6.
|
24 |
-
7.
|
25 |
-
8.
|
26 |
-
9.
|
27 |
-
10.
|
28 |
-
11.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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[
|
52 |
-
|
|
|
|
|
|
|
|
|
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 |
-
|
72 |
-
|
73 |
-
|
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.
|
82 |
-
gr.Textbox(label="
|
83 |
-
gr.Textbox(label="
|
84 |
-
gr.Textbox(label="I
|
85 |
-
gr.Textbox(label="I
|
86 |
-
gr.Textbox(label="
|
87 |
-
gr.Textbox(label="I
|
88 |
-
gr.Textbox(label="
|
89 |
-
gr.Textbox(label="
|
90 |
-
|
91 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 I’m 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 |
+
"""
|