Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,17 @@ import os
|
|
| 4 |
|
| 5 |
address = os.getenv("address")
|
| 6 |
|
| 7 |
-
def generate_message(
|
| 8 |
|
| 9 |
response = requests.post(address, json={
|
| 10 |
-
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
}).json()
|
| 19 |
|
| 20 |
result = response["body"]
|
|
@@ -26,7 +26,7 @@ title = "Message Generator Playground"
|
|
| 26 |
with gr.Blocks(title=title) as demo:
|
| 27 |
gr.Markdown("""
|
| 28 |
# Message Generator Playground
|
| 29 |
-
Select the conditions for a dummy student.
|
| 30 |
""")
|
| 31 |
with gr.Tab("Options"):
|
| 32 |
with gr.Row():
|
|
@@ -51,29 +51,24 @@ with gr.Blocks(title=title) as demo:
|
|
| 51 |
value="No",
|
| 52 |
type="value"
|
| 53 |
)
|
| 54 |
-
|
| 55 |
-
label="
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
with gr.Column():
|
| 59 |
-
prompt = gr.Textbox(label="Persona",
|
| 60 |
-
info="Persona of the AI agent",
|
| 61 |
-
lines=10,
|
| 62 |
-
value="Personality: You are an academic support AI helping professor writing message to student. You exhibit deep understanding of student challenges. You demonstrate knowledge of academic subjects and support pathways. You are approachable with and open and trustworthy demeanour. \n\n Communication style: You provide information that is straightforward and easy to understand. You use positive and encouraging language to motivate students who might be struggling. You apply a calm, patient and understanding tone to build trust and avoid creating panic. You show respect for different cultural backgrounds and foster an inclusive environment. Use British English spelling.",
|
| 63 |
)
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
)
|
| 69 |
ai_button = gr.Button("Generate GenAI Message")
|
| 70 |
with gr.Column():
|
| 71 |
textlabel = gr.Textbox(label="Placeholder",lines=1,value="Your HTML message will be shown below:",)
|
| 72 |
email_ai = gr.HTML(
|
| 73 |
label="AI-generated Email",
|
| 74 |
-
value="Depending on message content, please wait up to
|
| 75 |
)
|
| 76 |
|
| 77 |
-
ai_button.click(generate_message, inputs=[
|
| 78 |
|
| 79 |
-
demo.launch()
|
|
|
|
| 4 |
|
| 5 |
address = os.getenv("address")
|
| 6 |
|
| 7 |
+
def generate_message(indcator_no_login,indcator_low_activity,indcator_repeated_course,indcator_low_marks,indcator_low_wam,indcator_fail):
|
| 8 |
|
| 9 |
response = requests.post(address, json={
|
| 10 |
+
"no_login":indcator_no_login,
|
| 11 |
+
"low_activity":indcator_low_activity,
|
| 12 |
+
"repeated_course":indcator_repeated_course,
|
| 13 |
+
"low_marks":indcator_low_marks,
|
| 14 |
+
"low_wam": indcator_low_wam,
|
| 15 |
+
"fail": indcator_fail,
|
| 16 |
+
"prediction": "",
|
| 17 |
+
"additional_info": "",
|
| 18 |
}).json()
|
| 19 |
|
| 20 |
result = response["body"]
|
|
|
|
| 26 |
with gr.Blocks(title=title) as demo:
|
| 27 |
gr.Markdown("""
|
| 28 |
# Message Generator Playground
|
| 29 |
+
Select the conditions for a dummy student.
|
| 30 |
""")
|
| 31 |
with gr.Tab("Options"):
|
| 32 |
with gr.Row():
|
|
|
|
| 51 |
value="No",
|
| 52 |
type="value"
|
| 53 |
)
|
| 54 |
+
low_wam = gr.Radio(["Yes", "No"],
|
| 55 |
+
label="Low WAM",
|
| 56 |
+
value="No",
|
| 57 |
+
type="value"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
)
|
| 59 |
+
fails = gr.Radio(["Yes", "No"],
|
| 60 |
+
label="Failed other course previously",
|
| 61 |
+
value="No",
|
| 62 |
+
type="value"
|
| 63 |
)
|
| 64 |
ai_button = gr.Button("Generate GenAI Message")
|
| 65 |
with gr.Column():
|
| 66 |
textlabel = gr.Textbox(label="Placeholder",lines=1,value="Your HTML message will be shown below:",)
|
| 67 |
email_ai = gr.HTML(
|
| 68 |
label="AI-generated Email",
|
| 69 |
+
value="Depending on message content, please wait up to 1 mins, please scroll if message is long",
|
| 70 |
)
|
| 71 |
|
| 72 |
+
ai_button.click(generate_message, inputs=[no_login,low_activity,repeated_course,low_marks,low_wam,fails], outputs=[email_ai])
|
| 73 |
|
| 74 |
+
demo.launch()
|