Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,12 @@ openai.api_key = os.environ.get('openai-api')
|
|
| 8 |
# Blocks
|
| 9 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def refreshmode1(mode):
|
| 12 |
mode = gr.update(value= "mode1")
|
| 13 |
return mode
|
|
@@ -125,12 +131,13 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
|
| 125 |
|
| 126 |
# INTERFACE
|
| 127 |
mode = gr.Textbox(value = "mode1", visible = False)
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
with gr.Column(scale = 1):
|
| 130 |
visual = gr.Image(value = url, shape = [150,150])
|
| 131 |
with gr.Column(scale = 3):
|
| 132 |
title = gr.Markdown(value=languagedict['English']['welcome'])
|
| 133 |
-
language = gr.Dropdown(languageoptions , value= "English", label="Choose language / 選擇語言")
|
| 134 |
|
| 135 |
# REFERENCES
|
| 136 |
|
|
@@ -178,15 +185,15 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
|
| 178 |
#INTERFACE
|
| 179 |
with gr.Tab(f"{languagedict['English']['whatcanido']} / {languagedict['廣東話']['whatcanido']}"):
|
| 180 |
chatbot1 = gr.Chatbot([[None,languagedict['English']['whatcanidofirst']]])
|
| 181 |
-
input1 = gr.Textbox(label = languagedict['English']['whatcanidolabel'], placeholder = languagedict['English']['whatcanidoph'])
|
| 182 |
state1 = gr.State([{"role": "system", "content": themewhatcanido},{"role": "assistant", "content": languagedict['English']['whatcanidofirst']}])
|
| 183 |
with gr.Tab(f"{languagedict['English']['interviewquestions']} / {languagedict['廣東話']['interviewquestions']}"):
|
| 184 |
chatbot2 = gr.Chatbot([[None,languagedict['English']['interviewquestionsfirst']]])
|
| 185 |
-
input2 = gr.Textbox(label = languagedict['English']['interviewquestionslabel'], placeholder = languagedict['English']['interviewquestionsph'])
|
| 186 |
state2 = gr.State([{"role": "system", "content": themeinterviewquestions},{"role": "assistant", "content": languagedict['English']['interviewquestionsfirst']}])
|
| 187 |
with gr.Tab(f"{languagedict['English']['help']} / {languagedict['廣東話']['help']}"):
|
| 188 |
chatbot3 = gr.Chatbot([[None,languagedict['English']['helpfirst']]])
|
| 189 |
-
input3 = gr.Textbox(label = languagedict['English']['helplabel'], placeholder = languagedict['English']['helpph'])
|
| 190 |
with gr.Accordion("MIW", open = False):
|
| 191 |
code = gr.Textbox(label = 'Code')
|
| 192 |
instructions = gr.Textbox(label = 'Instructions', lines=10, max_lines= 100, visible = False)
|
|
@@ -200,6 +207,6 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
|
| 200 |
input3.submit(refreshmode3, mode, mode).then(user, [input3, chatbot3, state3, language, mode], [input3, chatbot3, state3]).then(bot, [chatbot3, state3], [chatbot3, state3])
|
| 201 |
clear.click(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).success(init_history, [language, state1, state2, state3], [state1, state2, state3])
|
| 202 |
language.change(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).then(refresh, language, [title, input1, input2, input3, chatbot1, chatbot2, chatbot3, state1, state2, state3])
|
| 203 |
-
|
| 204 |
demo.queue()
|
| 205 |
demo.launch()
|
|
|
|
| 8 |
# Blocks
|
| 9 |
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
| 10 |
|
| 11 |
+
def showall(code:str):
|
| 12 |
+
if code = os.environ.get('accesscode')
|
| 13 |
+
visibility = gr.update(visible = True)
|
| 14 |
+
invisibility = gr.update(visible = False)
|
| 15 |
+
return visibility, visibility, visibility, visibility, invisibility
|
| 16 |
+
|
| 17 |
def refreshmode1(mode):
|
| 18 |
mode = gr.update(value= "mode1")
|
| 19 |
return mode
|
|
|
|
| 131 |
|
| 132 |
# INTERFACE
|
| 133 |
mode = gr.Textbox(value = "mode1", visible = False)
|
| 134 |
+
accesscode = gr.Textbox(label = "Input access code", visible = True)
|
| 135 |
with gr.Row():
|
| 136 |
with gr.Column(scale = 1):
|
| 137 |
visual = gr.Image(value = url, shape = [150,150])
|
| 138 |
with gr.Column(scale = 3):
|
| 139 |
title = gr.Markdown(value=languagedict['English']['welcome'])
|
| 140 |
+
language = gr.Dropdown(languageoptions , value= "English", label="Choose language / 選擇語言", visible = False)
|
| 141 |
|
| 142 |
# REFERENCES
|
| 143 |
|
|
|
|
| 185 |
#INTERFACE
|
| 186 |
with gr.Tab(f"{languagedict['English']['whatcanido']} / {languagedict['廣東話']['whatcanido']}"):
|
| 187 |
chatbot1 = gr.Chatbot([[None,languagedict['English']['whatcanidofirst']]])
|
| 188 |
+
input1 = gr.Textbox(label = languagedict['English']['whatcanidolabel'], placeholder = languagedict['English']['whatcanidoph'], visible = False)
|
| 189 |
state1 = gr.State([{"role": "system", "content": themewhatcanido},{"role": "assistant", "content": languagedict['English']['whatcanidofirst']}])
|
| 190 |
with gr.Tab(f"{languagedict['English']['interviewquestions']} / {languagedict['廣東話']['interviewquestions']}"):
|
| 191 |
chatbot2 = gr.Chatbot([[None,languagedict['English']['interviewquestionsfirst']]])
|
| 192 |
+
input2 = gr.Textbox(label = languagedict['English']['interviewquestionslabel'], placeholder = languagedict['English']['interviewquestionsph'], visible = False)
|
| 193 |
state2 = gr.State([{"role": "system", "content": themeinterviewquestions},{"role": "assistant", "content": languagedict['English']['interviewquestionsfirst']}])
|
| 194 |
with gr.Tab(f"{languagedict['English']['help']} / {languagedict['廣東話']['help']}"):
|
| 195 |
chatbot3 = gr.Chatbot([[None,languagedict['English']['helpfirst']]])
|
| 196 |
+
input3 = gr.Textbox(label = languagedict['English']['helplabel'], placeholder = languagedict['English']['helpph'], visible = False)
|
| 197 |
with gr.Accordion("MIW", open = False):
|
| 198 |
code = gr.Textbox(label = 'Code')
|
| 199 |
instructions = gr.Textbox(label = 'Instructions', lines=10, max_lines= 100, visible = False)
|
|
|
|
| 207 |
input3.submit(refreshmode3, mode, mode).then(user, [input3, chatbot3, state3, language, mode], [input3, chatbot3, state3]).then(bot, [chatbot3, state3], [chatbot3, state3])
|
| 208 |
clear.click(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).success(init_history, [language, state1, state2, state3], [state1, state2, state3])
|
| 209 |
language.change(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).then(refresh, language, [title, input1, input2, input3, chatbot1, chatbot2, chatbot3, state1, state2, state3])
|
| 210 |
+
accesscode.submit(showall, accesscode, [input1, input2, input3, language, accesscode])
|
| 211 |
demo.queue()
|
| 212 |
demo.launch()
|