3v324v23 commited on
Commit
38ea63e
·
1 Parent(s): 894d64e

improving mobile layout

Browse files
Files changed (1) hide show
  1. app.py +33 -28
app.py CHANGED
@@ -96,36 +96,40 @@ def helper_text(text_input,radio=None):
96
  return output[0]
97
 
98
  # Gradio function for configure the language of UI
99
- def change_language(radio,text_input,text_output,clear_btn,submit_btn,markdown, markdown_msg1):
100
  if radio == "简体中文":
101
  index = 0
102
  text_input_update=gr.Textbox.update(value = chinese_converter.to_simplified(text_input), label = text_input_label[index])
103
  text_output_update=gr.Textbox.update(value = chinese_converter.to_simplified(text_output),label = text_output_label[index])
104
  markdown_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown))
105
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg1))
 
106
  elif radio == "繁體中文":
107
  index = 1
108
  text_input_update=gr.Textbox.update(value = chinese_converter.to_traditional(text_input),label = text_input_label[index])
109
  text_output_update=gr.Textbox.update(value = chinese_converter.to_traditional(text_output),label = text_output_label[index])
110
  markdown_update=gr.Markdown.update(value = chinese_converter.to_traditional(markdown))
111
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_traditional(markdown_msg1))
 
112
  elif radio == "English":
113
  index = 2
114
  text_input_update=gr.Textbox.update(label = text_input_label[index])
115
  text_output_update=gr.Textbox.update(label = text_output_label[index])
116
  markdown_update=gr.Markdown.update(value = markdown)
117
  markdown_msg1_update=gr.Markdown.update(value = markdown_msg1)
 
118
  else:
119
  index = 0
120
  text_input_update=gr.Textbox.update(label = text_input_label[index])
121
  text_output_update=gr.Textbox.update(label = text_output_label[index])
122
  markdown_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown))
123
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg1))
 
124
 
125
  clear_btn_update = gr.ClearButton.update(value = clear_label[index])
126
  submit_btn_update = gr.Button.update(value = submit_label[index])
127
 
128
- return [text_input_update,text_output_update,clear_btn_update,submit_btn_update,markdown_update, markdown_msg1_update ]
129
 
130
  def clear_text():
131
  text_input_update=gr.Textbox.update(value=None)
@@ -174,25 +178,7 @@ with gr.Blocks() as demo:
174
  the eighth lunar month). When people are viewing the flower lanterns, they can guess the riddles on the lanterns together.
175
 
176
  ----
177
-
178
- # 声明 Disclaimer
179
-
180
- 本应用输出的文本为机器基于模型生成的结果,不代表任何人观点,请谨慎辨别和参考。请在法律允许的范围内使用。
181
-
182
- 本应用调用了 [ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2) 对话语言大模型,\
183
- 使用本应用前请务必阅读和同意遵守其[使用授权许可证](https://huggingface.co/ClueAI/ChatYuan-large-v2/blob/main/LICENSE)。
184
-
185
- 本应用仅供非商业用途。
186
-
187
- The outputs of this application are machine-generated with a statistical model. \
188
- The outputs do not reflect any opinions of any human subjects. You must identify the outputs in caution. \
189
- It is your responsbility to decide whether to accept the outputs. You must use the applicaiton in obedience to the Law.
190
-
191
- This application utilizes [ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2) \
192
- Conversational Large Language Model. Before using this application, you must read and accept to follow \
193
- the [LICENSE](https://huggingface.co/ClueAI/ChatYuan-large-v2/blob/main/LICENSE).
194
-
195
- This application is for non-commercial use only.
196
 
197
  """
198
  )
@@ -200,12 +186,31 @@ with gr.Blocks() as demo:
200
  text_output = gr.Textbox(label=text_output_label[index])
201
  markdown_msg2 = gr.Markdown(
202
  """
203
- <br/>
204
- <br/>
205
- <br/>
206
- <br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
- ![lantern](file/data/DSC_0105.jpg)
209
  """)
210
 
211
 
@@ -213,8 +218,8 @@ with gr.Blocks() as demo:
213
 
214
  submit_btn.click(fn=helper_text, inputs=[text_input,radio], outputs=text_output)
215
  clear_btn.click(fn=clear_text,outputs=[text_input,text_output])
216
- radio.change(fn=change_language,inputs=[radio,text_input,text_output,clear_btn,submit_btn,markdown, markdown_msg1],
217
- outputs=[text_input,text_output,clear_btn,submit_btn, markdown, markdown_msg1])
218
 
219
  #demo = gr.Interface(fn=helper_text, inputs=text_input, outputs=text_output,
220
  # flagging_options=["Inappropriate"],allow_flagging="never",
 
96
  return output[0]
97
 
98
  # Gradio function for configure the language of UI
99
+ def change_language(radio,text_input,text_output,clear_btn,submit_btn,markdown, markdown_msg1, markdown_msg2):
100
  if radio == "简体中文":
101
  index = 0
102
  text_input_update=gr.Textbox.update(value = chinese_converter.to_simplified(text_input), label = text_input_label[index])
103
  text_output_update=gr.Textbox.update(value = chinese_converter.to_simplified(text_output),label = text_output_label[index])
104
  markdown_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown))
105
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg1))
106
+ markdown_msg2_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg2))
107
  elif radio == "繁體中文":
108
  index = 1
109
  text_input_update=gr.Textbox.update(value = chinese_converter.to_traditional(text_input),label = text_input_label[index])
110
  text_output_update=gr.Textbox.update(value = chinese_converter.to_traditional(text_output),label = text_output_label[index])
111
  markdown_update=gr.Markdown.update(value = chinese_converter.to_traditional(markdown))
112
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_traditional(markdown_msg1))
113
+ markdown_msg2_update=gr.Markdown.update(value = chinese_converter.to_traditional(markdown_msg2))
114
  elif radio == "English":
115
  index = 2
116
  text_input_update=gr.Textbox.update(label = text_input_label[index])
117
  text_output_update=gr.Textbox.update(label = text_output_label[index])
118
  markdown_update=gr.Markdown.update(value = markdown)
119
  markdown_msg1_update=gr.Markdown.update(value = markdown_msg1)
120
+ markdown_msg2_update=gr.Markdown.update(value = markdown_msg2)
121
  else:
122
  index = 0
123
  text_input_update=gr.Textbox.update(label = text_input_label[index])
124
  text_output_update=gr.Textbox.update(label = text_output_label[index])
125
  markdown_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown))
126
  markdown_msg1_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg1))
127
+ markdown_msg2_update=gr.Markdown.update(value = chinese_converter.to_simplified(markdown_msg2))
128
 
129
  clear_btn_update = gr.ClearButton.update(value = clear_label[index])
130
  submit_btn_update = gr.Button.update(value = submit_label[index])
131
 
132
+ return [text_input_update,text_output_update,clear_btn_update,submit_btn_update,markdown_update, markdown_msg1_update ,markdown_msg2_update ]
133
 
134
  def clear_text():
135
  text_input_update=gr.Textbox.update(value=None)
 
178
  the eighth lunar month). When people are viewing the flower lanterns, they can guess the riddles on the lanterns together.
179
 
180
  ----
181
+ ![lantern](file/data/DSC_0105.jpg)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
  """
184
  )
 
186
  text_output = gr.Textbox(label=text_output_label[index])
187
  markdown_msg2 = gr.Markdown(
188
  """
189
+ <br />
190
+ <br />
191
+ <br />
192
+ <br />
193
+ <br />
194
+
195
+ ---
196
+ # 声明 Disclaimer
197
+
198
+ 本应用输出的文本为机器基于模型生成的结果,不代表��何人观点,请谨慎辨别和参考。请在法律允许的范围内使用。
199
+
200
+ 本应用调用了 [ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2) 对话语言大模型,\
201
+ 使用本应用前请务必阅读和同意遵守其[使用授权许可证](https://huggingface.co/ClueAI/ChatYuan-large-v2/blob/main/LICENSE)。
202
+
203
+ 本应用仅供非商业用途。
204
+
205
+ The outputs of this application are machine-generated with a statistical model. \
206
+ The outputs do not reflect any opinions of any human subjects. You must identify the outputs in caution. \
207
+ It is your responsbility to decide whether to accept the outputs. You must use the applicaiton in obedience to the Law.
208
+
209
+ This application utilizes [ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2) \
210
+ Conversational Large Language Model. Before using this application, you must read and accept to follow \
211
+ the [LICENSE](https://huggingface.co/ClueAI/ChatYuan-large-v2/blob/main/LICENSE).
212
 
213
+ This application is for non-commercial use only.
214
  """)
215
 
216
 
 
218
 
219
  submit_btn.click(fn=helper_text, inputs=[text_input,radio], outputs=text_output)
220
  clear_btn.click(fn=clear_text,outputs=[text_input,text_output])
221
+ radio.change(fn=change_language,inputs=[radio,text_input,text_output,clear_btn,submit_btn,markdown, markdown_msg1,markdown_msg2],
222
+ outputs=[text_input,text_output,clear_btn,submit_btn, markdown, markdown_msg1,markdown_msg2])
223
 
224
  #demo = gr.Interface(fn=helper_text, inputs=text_input, outputs=text_output,
225
  # flagging_options=["Inappropriate"],allow_flagging="never",