broadfield-dev commited on
Commit
1082c65
·
verified ·
1 Parent(s): 49100eb

Update model_logic.py

Browse files
Files changed (1) hide show
  1. model_logic.py +5 -5
model_logic.py CHANGED
@@ -390,11 +390,11 @@ def generate_stream(provider: str, model_display_name: str, api_key_override: st
390
  byte_buffer = b""
391
  for chunk in response.iter_content(chunk_size=8192):
392
  # Check for potential HTTP errors during streaming
393
- if response.status_code != 200:
394
- error_body = response.text
395
- logger.error(f"HTTP Error during Cohere stream: {response.status_code}, Body: {error_body}")
396
- yield f"API HTTP Error ({response.status_code}) during Cohere stream: {error_body}"
397
- return # Stop streaming on error
398
 
399
  byte_buffer += chunk
400
  while b'\n\n' in byte_buffer: # Cohere uses \n\n as event separator
 
390
  byte_buffer = b""
391
  for chunk in response.iter_content(chunk_size=8192):
392
  # Check for potential HTTP errors during streaming
393
+ if response.status_code != 200:
394
+ error_body = response.text
395
+ logger.error(f"HTTP Error during Cohere stream: {response.status_code}, Body: {error_body}")
396
+ yield f"API HTTP Error ({response.status_code}) during Cohere stream: {error_body}"
397
+ return # Stop streaming on error
398
 
399
  byte_buffer += chunk
400
  while b'\n\n' in byte_buffer: # Cohere uses \n\n as event separator