YC-Chen commited on
Commit
e35e05b
1 Parent(s): b040fe2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -178,11 +178,15 @@ with gr.Blocks() as demo:
178
  keep_streaming = True
179
  s = requests.Session()
180
  with s.post(API_URL, headers=HEADERS, json=data, stream=True, timeout=30) as r:
181
- time.sleep(0.3)
182
  for line in r.iter_lines():
 
 
 
 
183
  if line and keep_streaming:
184
  if r.status_code != 200:
185
- raise Exception('status_code != 200')
186
  json_response = json.loads(line)
187
 
188
  try:
@@ -199,10 +203,6 @@ with gr.Blocks() as demo:
199
  else:
200
  history[-1][1] += delta
201
  yield history
202
-
203
- if time.time() - start_time > MAX_SEC:
204
- keep_streaming = False
205
- break
206
 
207
  if history[-1][1].endswith('</s>'):
208
  history[-1][1] = history[-1][1][:-4]
 
178
  keep_streaming = True
179
  s = requests.Session()
180
  with s.post(API_URL, headers=HEADERS, json=data, stream=True, timeout=30) as r:
181
+ time.sleep(0.1)
182
  for line in r.iter_lines():
183
+ if time.time() - start_time > MAX_SEC:
184
+ keep_streaming = False
185
+ break
186
+
187
  if line and keep_streaming:
188
  if r.status_code != 200:
189
+ continue
190
  json_response = json.loads(line)
191
 
192
  try:
 
203
  else:
204
  history[-1][1] += delta
205
  yield history
 
 
 
 
206
 
207
  if history[-1][1].endswith('</s>'):
208
  history[-1][1] = history[-1][1][:-4]