Spaces:
Runtime error
Runtime error
added examples
Browse files
app.py
CHANGED
@@ -50,6 +50,7 @@ def answer(text,context=""):
|
|
50 |
text = f"{context}\n{text}\n谜底:"
|
51 |
text = text.strip()
|
52 |
|
|
|
53 |
text = preprocess(text)
|
54 |
out_text = pipe(text)
|
55 |
|
@@ -131,6 +132,7 @@ def change_language(radio,text_input,text_output,clear_btn,submit_btn,markdown,
|
|
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)
|
136 |
text_output_update=gr.Textbox.update(value=None)
|
@@ -153,6 +155,12 @@ submit_label = ["提交","提交","Submit"]
|
|
153 |
|
154 |
with gr.Blocks() as demo:
|
155 |
index = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
radio = gr.Radio(
|
157 |
["简体中文","繁體中文", "English"],show_label=False,value="简体中文"
|
158 |
)
|
@@ -171,6 +179,13 @@ with gr.Blocks() as demo:
|
|
171 |
|
172 |
text_output = gr.Textbox(label=text_output_label[index])
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
markdown_msg1 = gr.Markdown(
|
175 |
"""
|
176 |
灯谜是中华文化特色文娱活动,自北宋盛行。每年逢正月十五元宵节,或是八月十五中秋节,将谜语贴在花灯上,让大家可一起猜谜。
|
@@ -219,6 +234,8 @@ with gr.Blocks() as demo:
|
|
219 |
The model is released under [apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)。
|
220 |
""")
|
221 |
|
|
|
|
|
222 |
|
223 |
|
224 |
|
@@ -232,8 +249,7 @@ with gr.Blocks() as demo:
|
|
232 |
# title="aaa",description="aaa",article="aaa")
|
233 |
demo.launch()
|
234 |
|
|
|
235 |
|
236 |
|
237 |
|
238 |
-
|
239 |
-
# %%
|
|
|
50 |
text = f"{context}\n{text}\n谜底:"
|
51 |
text = text.strip()
|
52 |
|
53 |
+
print(text)
|
54 |
text = preprocess(text)
|
55 |
out_text = pipe(text)
|
56 |
|
|
|
132 |
|
133 |
return [text_input_update,text_output_update,clear_btn_update,submit_btn_update,markdown_update, markdown_msg1_update ,markdown_msg2_update ]
|
134 |
|
135 |
+
|
136 |
def clear_text():
|
137 |
text_input_update=gr.Textbox.update(value=None)
|
138 |
text_output_update=gr.Textbox.update(value=None)
|
|
|
155 |
|
156 |
with gr.Blocks() as demo:
|
157 |
index = 0
|
158 |
+
example_list = [
|
159 |
+
["小家伙穿黄袍,花丛中把房造。飞到西来飞到东,人人夸他爱劳动。(猜一动物)"],
|
160 |
+
["一物生来身穿三百多件衣,每天脱一件,年底剩张皮。(猜一物品)"],
|
161 |
+
["A thousand threads, a million strands. Reaching the water, vanishing all at once. (Hint: natural phenomenon)"],
|
162 |
+
["无底洞(猜成语)"],
|
163 |
+
]
|
164 |
radio = gr.Radio(
|
165 |
["简体中文","繁體中文", "English"],show_label=False,value="简体中文"
|
166 |
)
|
|
|
179 |
|
180 |
text_output = gr.Textbox(label=text_output_label[index])
|
181 |
|
182 |
+
examples = gr.Examples(
|
183 |
+
examples=example_list,
|
184 |
+
inputs=text_input,
|
185 |
+
outputs=text_output,
|
186 |
+
fn=helper_text,
|
187 |
+
cache_examples=True,
|
188 |
+
)
|
189 |
markdown_msg1 = gr.Markdown(
|
190 |
"""
|
191 |
灯谜是中华文化特色文娱活动,自北宋盛行。每年逢正月十五元宵节,或是八月十五中秋节,将谜语贴在花灯上,让大家可一起猜谜。
|
|
|
234 |
The model is released under [apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)。
|
235 |
""")
|
236 |
|
237 |
+
|
238 |
+
|
239 |
|
240 |
|
241 |
|
|
|
249 |
# title="aaa",description="aaa",article="aaa")
|
250 |
demo.launch()
|
251 |
|
252 |
+
# %%
|
253 |
|
254 |
|
255 |
|
|
|
|