YangWu001 commited on
Commit
850df56
·
1 Parent(s): ecf9cdb
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -44,6 +44,10 @@ def respond(
44
  do_sample=True,
45
  top_p=top_p,
46
  ):
 
 
 
 
47
  token = output['generated_text'][-1]['content']
48
  response += token
49
  yield history + [(message, response)] # Yield history + new response
@@ -66,6 +70,10 @@ def respond(
66
  temperature=temperature,
67
  top_p=top_p,
68
  ):
 
 
 
 
69
  if stop_inference:
70
  response = "Inference cancelled."
71
  break
 
44
  do_sample=True,
45
  top_p=top_p,
46
  ):
47
+ if stop_inference:
48
+ response = "Inference cancelled."
49
+ yield history + [(message, response)]
50
+ return
51
  token = output['generated_text'][-1]['content']
52
  response += token
53
  yield history + [(message, response)] # Yield history + new response
 
70
  temperature=temperature,
71
  top_p=top_p,
72
  ):
73
+ if stop_inference:
74
+ response = "Inference cancelled."
75
+ yield history + [(message, response)]
76
+ return
77
  if stop_inference:
78
  response = "Inference cancelled."
79
  break