Justin Grammens
commited on
Commit
·
9d76faa
1
Parent(s):
5cdff8a
updated text and remove the prompt sent to openai
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ secretcode = os.environ["SECRETCODE"]
|
|
15 |
from_email = os.environ["PLP_RETURN_EMAIL_ADDRESS"]
|
16 |
|
17 |
# Initialize the OpenAI model
|
18 |
-
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=.
|
19 |
|
20 |
# Define a reusable prompt template using LangChain
|
21 |
template = """
|
@@ -56,10 +56,11 @@ prompt = PromptTemplate(
|
|
56 |
)
|
57 |
|
58 |
def send_sendgrid_email(essay, email):
|
|
|
59 |
message = Mail(
|
60 |
from_email=from_email,
|
61 |
to_emails=email,
|
62 |
-
subject='
|
63 |
html_content=essay)
|
64 |
try:
|
65 |
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
|
@@ -111,7 +112,8 @@ def stream_leadership_essay(*answers):
|
|
111 |
essay = ""
|
112 |
for chunk in response_stream:
|
113 |
essay += chunk.content
|
114 |
-
yield essay, filled_prompt # Yield partial essay to the Gradio output in real-time
|
|
|
115 |
|
116 |
result = send_sendgrid_email(essay, answers[28])
|
117 |
print(result)
|
@@ -124,9 +126,9 @@ with gr.Blocks(
|
|
124 |
gr.Markdown("# Personal Leadership Profile")
|
125 |
|
126 |
gr.Markdown("""
|
127 |
-
|
128 |
-
Based on your answers, we will build a “draft” for you to revise, build upon, and use as a roadmap.
|
129 |
-
Thank you for completing the PLP questions - It will be a cornerstone of your continued development.
|
130 |
""")
|
131 |
|
132 |
inputs = [
|
@@ -161,8 +163,8 @@ with gr.Blocks(
|
|
161 |
gr.Textbox(label="We define success in our department by..."),
|
162 |
|
163 |
gr.Markdown("### Validation Input:"),
|
164 |
-
gr.Textbox(label="
|
165 |
-
gr.Textbox(label="Enter the password to generate
|
166 |
]
|
167 |
|
168 |
gr.Markdown("### I acknowledge that this is for learning purposes only.")
|
@@ -171,15 +173,16 @@ with gr.Blocks(
|
|
171 |
|
172 |
# Output area for the response summary
|
173 |
|
174 |
-
output = gr.Textbox(label="
|
175 |
|
176 |
-
prompt_template = gr.Textbox(label="This is the prompt that was sent to ChatGPT", lines=10)
|
177 |
|
178 |
# Link the submit button with the function
|
179 |
submit_button.click(
|
180 |
stream_leadership_essay,
|
181 |
inputs=inputs,
|
182 |
-
outputs=[output, prompt_template]
|
|
|
183 |
)
|
184 |
|
185 |
# Launch the Gradio app
|
|
|
15 |
from_email = os.environ["PLP_RETURN_EMAIL_ADDRESS"]
|
16 |
|
17 |
# Initialize the OpenAI model
|
18 |
+
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=.4)
|
19 |
|
20 |
# Define a reusable prompt template using LangChain
|
21 |
template = """
|
|
|
56 |
)
|
57 |
|
58 |
def send_sendgrid_email(essay, email):
|
59 |
+
print(from_email)
|
60 |
message = Mail(
|
61 |
from_email=from_email,
|
62 |
to_emails=email,
|
63 |
+
subject='Personal Leadership Profile Results',
|
64 |
html_content=essay)
|
65 |
try:
|
66 |
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
|
|
|
112 |
essay = ""
|
113 |
for chunk in response_stream:
|
114 |
essay += chunk.content
|
115 |
+
#yield essay, filled_prompt # Yield partial essay to the Gradio output in real-time
|
116 |
+
yield essay
|
117 |
|
118 |
result = send_sendgrid_email(essay, answers[28])
|
119 |
print(result)
|
|
|
126 |
gr.Markdown("# Personal Leadership Profile")
|
127 |
|
128 |
gr.Markdown("""
|
129 |
+
According to 40 years of research by Kouzes and Posner, the most influential leaders have a clear Personal Leadership Philosophy (PLP) and communicate it frequently. 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.
|
130 |
+
Please choose TEN or more of the following questions to answer. Each response must be at least 40 characters. Based on your answers, we will build a “draft” for you to revise, build upon, and use as a roadmap.
|
131 |
+
Thank you for completing the PLP questions - It will be a cornerstone of your continued growth and development.
|
132 |
""")
|
133 |
|
134 |
inputs = [
|
|
|
163 |
gr.Textbox(label="We define success in our department by..."),
|
164 |
|
165 |
gr.Markdown("### Validation Input:"),
|
166 |
+
gr.Textbox(label="We will email you a copy of your PLP. Please enter your address below."),
|
167 |
+
gr.Textbox(label="Enter the password to generate your PLP.")
|
168 |
]
|
169 |
|
170 |
gr.Markdown("### I acknowledge that this is for learning purposes only.")
|
|
|
173 |
|
174 |
# Output area for the response summary
|
175 |
|
176 |
+
output = gr.Textbox(label="Your generated Personal Leadership Profile", lines=10)
|
177 |
|
178 |
+
#prompt_template = gr.Textbox(label="This is the prompt that was sent to ChatGPT", lines=10)
|
179 |
|
180 |
# Link the submit button with the function
|
181 |
submit_button.click(
|
182 |
stream_leadership_essay,
|
183 |
inputs=inputs,
|
184 |
+
#outputs=[output, prompt_template]
|
185 |
+
outputs=output
|
186 |
)
|
187 |
|
188 |
# Launch the Gradio app
|