Niansuh commited on
Commit
d3f79a5
·
verified ·
1 Parent(s): b0b613c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -3
main.py CHANGED
@@ -373,7 +373,6 @@ class Blackbox:
373
  except json.JSONDecodeError as je:
374
  logger.error("Failed to parse search results JSON.")
375
  raise je
376
- break # Exit the retry loop if successful
377
  except ClientError as ce:
378
  logger.error(f"Client error occurred: {ce}. Retrying attempt {attempt + 1}/{retry_attempts}")
379
  if attempt == retry_attempts - 1:
@@ -526,7 +525,8 @@ async def chat_completions(request: ChatRequest, req: Request, api_key: str = De
526
  try:
527
  if request.stream:
528
  logger.info("Streaming response")
529
- streaming_response = await Blackbox.create_async_generator(
 
530
  model=modified_request.model,
531
  messages=[{"role": msg.role, "content": msg.content} for msg in modified_request.messages],
532
  proxy=None,
@@ -610,7 +610,8 @@ async def chat_completions(request: ChatRequest, req: Request, api_key: str = De
610
  return StreamingResponse(generate_with_analysis(), media_type="text/event-stream")
611
  else:
612
  logger.info("Non-streaming response")
613
- streaming_response = await Blackbox.create_async_generator(
 
614
  model=modified_request.model,
615
  messages=[{"role": msg.role, "content": msg.content} for msg in modified_request.messages],
616
  proxy=None,
 
373
  except json.JSONDecodeError as je:
374
  logger.error("Failed to parse search results JSON.")
375
  raise je
 
376
  except ClientError as ce:
377
  logger.error(f"Client error occurred: {ce}. Retrying attempt {attempt + 1}/{retry_attempts}")
378
  if attempt == retry_attempts - 1:
 
525
  try:
526
  if request.stream:
527
  logger.info("Streaming response")
528
+ # **Removed the 'await' keyword here**
529
+ streaming_response = Blackbox.create_async_generator(
530
  model=modified_request.model,
531
  messages=[{"role": msg.role, "content": msg.content} for msg in modified_request.messages],
532
  proxy=None,
 
610
  return StreamingResponse(generate_with_analysis(), media_type="text/event-stream")
611
  else:
612
  logger.info("Non-streaming response")
613
+ # **Removed the 'await' keyword here as well**
614
+ streaming_response = Blackbox.create_async_generator(
615
  model=modified_request.model,
616
  messages=[{"role": msg.role, "content": msg.content} for msg in modified_request.messages],
617
  proxy=None,