npc0 commited on
Commit
621b0e0
·
1 Parent(s): 29a14b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -53,6 +53,10 @@ def postprocess(text):
53
 
54
 
55
  def predict(input, max_length, top_p, temperature, history):
 
 
 
 
56
  response = ""
57
  history.append(input)
58
 
@@ -112,19 +116,13 @@ with gr.Blocks() as demo:
112
  history = gr.State(init_history)
113
 
114
  submitBtn.click(
115
- predict, [
116
- '請為『%s』選取5個公式' %user_input,
117
- max_length, top_p, temperature, history],
118
  [five_sample, history], show_progress=True
119
  )
120
  submitBtn.click(reset_user_input, [], [user_input])
121
  submitBtn.click(reset_user_input, [], [final_sample])
122
 
123
- expand.select(fn=predict,
124
- inputs=('現在你作為一個專業的編劇,'
125
- '你需要為故事%轉寫一段故事大綱'
126
- '提供一個完整的龍骨給之後的編劇用。') %expand,
127
- outputs=final_sample)
128
 
129
  emptyBtn.click(reset_state,
130
  outputs=[five_sample, final_sample, history],
 
53
 
54
 
55
  def predict(input, max_length, top_p, temperature, history):
56
+ if input.isdigit():
57
+ input = '現在你作為一個專業的編劇,你需要為故事%s轉寫一段故事大綱提供一個完整的龍骨給之後的編劇用。' %input
58
+ else:
59
+ input = '請為『%s』選取5個公式' %input
60
  response = ""
61
  history.append(input)
62
 
 
116
  history = gr.State(init_history)
117
 
118
  submitBtn.click(
119
+ predict, [user_input, max_length, top_p, temperature, history],
 
 
120
  [five_sample, history], show_progress=True
121
  )
122
  submitBtn.click(reset_user_input, [], [user_input])
123
  submitBtn.click(reset_user_input, [], [final_sample])
124
 
125
+ expand.select(fn=predict, inputs=expand, outputs=final_sample)
 
 
 
 
126
 
127
  emptyBtn.click(reset_state,
128
  outputs=[five_sample, final_sample, history],