dengkane commited on
Commit
ad8d2af
·
1 Parent(s): 211bdd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -10,9 +10,13 @@ def backend(question):
10
  res = generator("===question===\n" + question + ". \n===answer===\n ", max_length=1000, num_return_sequences=1)
11
  return res[0]
12
 
 
 
 
 
13
  # 构建页面布局
14
  st.title("GPT-2 Demo")
15
- question = st.text_input("请输入问题")
16
  if st.button("获取答案"):
17
  # 调用后台代码
18
  answer = backend(question)
 
10
  res = generator("===question===\n" + question + ". \n===answer===\n ", max_length=1000, num_return_sequences=1)
11
  return res[0]
12
 
13
+ def on_question_submit(question):
14
+ answer = backend(question)
15
+ st.write(answer)
16
+
17
  # 构建页面布局
18
  st.title("GPT-2 Demo")
19
+ question = st.text_input("请输入问题", on_submit=on_question_submit)
20
  if st.button("获取答案"):
21
  # 调用后台代码
22
  answer = backend(question)