File size: 2,698 Bytes
cb87a75
 
0cc2db4
 
 
 
86abc04
cb87a75
0cc2db4
86abc04
 
 
 
 
 
 
 
cb87a75
 
 
 
 
 
 
 
 
 
 
86abc04
cb87a75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86abc04
 
 
 
cb87a75
86abc04
 
 
 
cb87a75
 
 
e32d5cd
cb87a75
 
86abc04
cb87a75
 
86abc04
cb87a75
86abc04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import requests
import gradio as gr
import os

address = os.getenv("address")

def generate_message(indcator_no_login,indcator_low_activity,indcator_repeated_course,indcator_low_marks,indcator_low_wam,indcator_fail):

   response = requests.post(address, json={
    "no_login":indcator_no_login,
    "low_activity":indcator_low_activity,
    "repeated_course":indcator_repeated_course,
    "low_marks":indcator_low_marks,
    "low_wam": indcator_low_wam,
    "fail": indcator_fail,
    "prediction": "",
    "additional_info": "",
   }).json()
   
   result = response["body"]

   return result

title = "Message Generator Playground"

with gr.Blocks(title=title) as demo:
    gr.Markdown("""
    # Message Generator Playground
    Select the conditions for a dummy student.
    """)
    with gr.Tab("Options"):
       with gr.Row():
           with gr.Column():
             no_login = gr.Radio(["Yes", "No"],
             label="No Moodle login in last 7 days",
             value="Yes",
             type="value"
             )
             low_activity = gr.Radio(["Yes", "No"],
             label="Low Moodle activity",
             value="No",
             type="value"
             )
             repeated_course = gr.Radio(["Yes", "No"],
             label="Repeated Course",
             value="No",
             type="value"
             )
             low_marks = gr.Radio(["Yes", "No"],
             label="Low marks",
             value="No",
             type="value"
             )
             low_wam = gr.Radio(["Yes", "No"],
             label="Low WAM",
             value="No",
             type="value"
             )
             fails = gr.Radio(["Yes", "No"],
             label="Failed other course previously",
             value="No",
             type="value"
             )
             ai_button = gr.Button("Generate GenAI Message")
           with gr.Column():
             textlabel = gr.Textbox(label="Placeholder",lines=5,value="Your HTML message will be shown below. PLEASE NOTE: All URLs end with '%7Bga_link_placeholder%7D', which is used for tracking in Google Analytics and post-processing. Therefore, they are not clickable here. You can remove '%7Bga_link_placeholder%7D' from the links to access the webpages. However, these URLs will be processed and will be clickable for students in actual emails.",)
             email_ai = gr.HTML(
             label="AI-generated Email",
             value="Depending on message content, please wait up to 1 mins, please scroll if message is long",
             )

    ai_button.click(generate_message, inputs=[no_login,low_activity,repeated_course,low_marks,low_wam,fails], outputs=[email_ai])    

demo.launch()