smgc commited on
Commit
f30c15c
1 Parent(s): 38637c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -100,6 +100,9 @@ def messages():
100
  "usage": {"input_tokens": 0, "output_tokens": 0}
101
  })
102
 
 
 
 
103
  def generate():
104
  previous_messages = "\n\n".join([msg['content'] for msg in json_body['messages']])
105
  msg_id = str(uuid.uuid4())
@@ -203,7 +206,6 @@ def messages():
203
  "usage": {"output_tokens": len(''.join(response_text))},
204
  })
205
  yield create_event("message_stop", {"type": "message_stop"}) # 确保发送 message_stop 事件
206
- log_request(request.remote_addr, request.path, 200)
207
 
208
  return Response(generate(), content_type='text/event-stream')
209
 
 
100
  "usage": {"input_tokens": 0, "output_tokens": 0}
101
  })
102
 
103
+ # 记录日志:此时请求上下文仍然有效
104
+ log_request(request.remote_addr, request.path, 200)
105
+
106
  def generate():
107
  previous_messages = "\n\n".join([msg['content'] for msg in json_body['messages']])
108
  msg_id = str(uuid.uuid4())
 
206
  "usage": {"output_tokens": len(''.join(response_text))},
207
  })
208
  yield create_event("message_stop", {"type": "message_stop"}) # 确保发送 message_stop 事件
 
209
 
210
  return Response(generate(), content_type='text/event-stream')
211