Guiyom commited on
Commit
7db5477
·
1 Parent(s): 957be7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -76,7 +76,13 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
76
  input1up = gr.update(value = languagedict[language]['whatcanidolabel'])
77
  input2up = gr.update(value = languagedict[language]['interviewquestionslabel'])
78
  input3up = gr.update(value = languagedict[language]['helplabel'])
79
- return titleup, input1up, input2up, input3up
 
 
 
 
 
 
80
 
81
  # REFERENCES
82
  languageoptions = ["English", "廣東話"]
@@ -114,15 +120,15 @@ with gr.Blocks(theme=gr.themes.Glass()) as demo:
114
  with gr.Tab(f"{languagedict['English']['whatcanido']} / {languagedict['廣東話']['whatcanido']}", id = 1):
115
  chatbot1 = gr.Chatbot([None,languagedict['English']['whatcanidofirst']])
116
  input1 = gr.Textbox(label = languagedict['English']['whatcanidolabel'])
117
- state1 = gr.State([])
118
  with gr.Tab(f"{languagedict['English']['interviewquestions']} / {languagedict['廣東話']['interviewquestions']}", id = 2):
119
  chatbot2 = gr.Chatbot([None,languagedict['English']['interviewquestionsfirst']])
120
  input2 = gr.Textbox(label = languagedict['English']['interviewquestionslabel'])
121
- state2 = gr.State([])
122
  with gr.Tab(f"{languagedict['English']['help']} / {languagedict['廣東話']['help']}", id = 3):
123
  chatbot3 = gr.Chatbot([None,languagedict['English']['helpfirst']])
124
  input3 = gr.Textbox(label = languagedict['English']['helplabel'])
125
- state3 = gr.State([])
126
  with gr.Tab("MIW"):
127
  code = gr.Textbox(label = 'Code')
128
  instructions = gr.Textbox(label = 'Instructions', lines=10, max_lines= 100, visible = False)
@@ -175,7 +181,7 @@ IMPORTANT: write in {language}, in the style of a native inhabitant from Kowloon
175
  input2.submit(refreshmode2, mode, mode).then(user, [input2, chatbot2, state2], [input2, chatbot2, state2]).then(bot, [chatbot2, state2, mode], [chatbot2, state2])
176
  input3.submit(refreshmode3, mode, mode).then(user, [input3, chatbot3, state3], [input3, chatbot3, state3]).then(bot, [chatbot3, state3, mode], [chatbot3, state3])
177
  clear.click(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).success(init_history, [state1, state2, state3], [state1, state2, state3])
178
- language.change(refresh, language, [title, input1, input2, input3])
179
 
180
  demo.queue()
181
  demo.launch()
 
76
  input1up = gr.update(value = languagedict[language]['whatcanidolabel'])
77
  input2up = gr.update(value = languagedict[language]['interviewquestionslabel'])
78
  input3up = gr.update(value = languagedict[language]['helplabel'])
79
+ chatbot1up = [None,languagedict['English']['whatcanidofirst']
80
+ state1up = [{"role": "system", "content": themewhatcanido},{"role": "assistant", "content": languagedict[language]['whatcanidofirst']}]
81
+ chatbot2up = [None,languagedict['English']['interviewquestionsfirst']
82
+ state2up = [{"role": "system", "content": themeinterviewquestions},{"role": "assistant", "content": languagedict[language]['interviewquestionsfirst']}]
83
+ chatbot3up = [None,languagedict['English']['whatcanidofirst']
84
+ state3up = [{"role": "system", "content": themehelp},{"role": "assistant", "content": languagedict[language]['helpfirst']}]
85
+ return titleup, input1up, input2up, input3up, chatbot1up, chatbot2up, chatbot3up, state1up, state2up, state3up
86
 
87
  # REFERENCES
88
  languageoptions = ["English", "廣東話"]
 
120
  with gr.Tab(f"{languagedict['English']['whatcanido']} / {languagedict['廣東話']['whatcanido']}", id = 1):
121
  chatbot1 = gr.Chatbot([None,languagedict['English']['whatcanidofirst']])
122
  input1 = gr.Textbox(label = languagedict['English']['whatcanidolabel'])
123
+ state1 = gr.State([{"role": "system", "content": themewhatcanido},{"role": "assistant", "content": languagedict[language]['whatcanidofirst']}])
124
  with gr.Tab(f"{languagedict['English']['interviewquestions']} / {languagedict['廣東話']['interviewquestions']}", id = 2):
125
  chatbot2 = gr.Chatbot([None,languagedict['English']['interviewquestionsfirst']])
126
  input2 = gr.Textbox(label = languagedict['English']['interviewquestionslabel'])
127
+ state2 = gr.State([{"role": "system", "content": themeinterviewquestions},{"role": "assistant", "content": languagedict[language]['interviewquestionsfirst']}])
128
  with gr.Tab(f"{languagedict['English']['help']} / {languagedict['廣東話']['help']}", id = 3):
129
  chatbot3 = gr.Chatbot([None,languagedict['English']['helpfirst']])
130
  input3 = gr.Textbox(label = languagedict['English']['helplabel'])
131
+ state3 = gr.State([{"role": "system", "content": themehelp},{"role": "assistant", "content": languagedict[language]['helpfirst']}])
132
  with gr.Tab("MIW"):
133
  code = gr.Textbox(label = 'Code')
134
  instructions = gr.Textbox(label = 'Instructions', lines=10, max_lines= 100, visible = False)
 
181
  input2.submit(refreshmode2, mode, mode).then(user, [input2, chatbot2, state2], [input2, chatbot2, state2]).then(bot, [chatbot2, state2, mode], [chatbot2, state2])
182
  input3.submit(refreshmode3, mode, mode).then(user, [input3, chatbot3, state3], [input3, chatbot3, state3]).then(bot, [chatbot3, state3, mode], [chatbot3, state3])
183
  clear.click(lambda: None, None, [chatbot1, chatbot2, chatbot3], queue=True).success(init_history, [state1, state2, state3], [state1, state2, state3])
184
+ language.change(refresh, language, [title, input1, input2, input3, chatbot1, state1, chatbot2, state2, chatbot3, state3])
185
 
186
  demo.queue()
187
  demo.launch()