yym68686 commited on
Commit
3d5dc7e
·
1 Parent(s): 97c356d

🐛 Bug: Fix the bug where the 201 status code is mistakenly considered an error.

Browse files
Files changed (3) hide show
  1. main.py +1 -1
  2. response.py +1 -1
  3. test/provider_test.py +1 -1
main.py CHANGED
@@ -765,7 +765,7 @@ async def process_request(request: Union[RequestModel, ImageGenerationRequest, A
765
  timeout_value = get_timeout_value(app.state.provider_timeouts["global_time_out"], original_model)
766
  if timeout_value is None:
767
  timeout_value = app.state.timeouts.get("default", DEFAULT_TIMEOUT)
768
- print("timeout_value", timeout_value)
769
 
770
  try:
771
  async with app.state.client_manager.get_client(timeout_value) as client:
 
765
  timeout_value = get_timeout_value(app.state.provider_timeouts["global_time_out"], original_model)
766
  if timeout_value is None:
767
  timeout_value = app.state.timeouts.get("default", DEFAULT_TIMEOUT)
768
+ # print("timeout_value", timeout_value)
769
 
770
  try:
771
  async with app.state.client_manager.get_client(timeout_value) as client:
response.py CHANGED
@@ -77,7 +77,7 @@ async def generate_no_stream_response(timestamp, model, content=None, tools_id=N
77
  return json_data
78
 
79
  async def check_response(response, error_log):
80
- if response and response.status_code != 200:
81
  error_message = await response.aread()
82
  error_str = error_message.decode('utf-8', errors='replace')
83
  try:
 
77
  return json_data
78
 
79
  async def check_response(response, error_log):
80
+ if response and not (200 <= response.status_code < 300):
81
  error_message = await response.aread()
82
  error_str = error_message.decode('utf-8', errors='replace')
83
  try:
test/provider_test.py CHANGED
@@ -82,7 +82,7 @@ def test_request_model(test_client, api_key, get_model):
82
  response = test_client.post("/v1/chat/completions", json=request_data, headers=headers)
83
  for line in response.iter_lines():
84
  print(line.lstrip("data: "))
85
- assert response.status_code == 200
86
 
87
  if __name__ == "__main__":
88
  pytest.main(["-s", "test/provider_test.py"])
 
82
  response = test_client.post("/v1/chat/completions", json=request_data, headers=headers)
83
  for line in response.iter_lines():
84
  print(line.lstrip("data: "))
85
+ assert 200 <= response.status_code < 300
86
 
87
  if __name__ == "__main__":
88
  pytest.main(["-s", "test/provider_test.py"])