Shreyas094 commited on
Commit
634b153
·
verified ·
1 Parent(s): b537733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -484,16 +484,20 @@ Write a detailed and complete response that answers the following user question:
484
  response = ""
485
  for i in range(num_calls):
486
  logging.info(f"API call {i+1}/{num_calls}")
487
- for message in client.chat_completion(
488
- messages=[{"role": "user", "content": prompt}],
489
- max_tokens=10000,
490
- temperature=temperature,
491
- stream=True,
492
- ):
493
- if message.choices and message.choices[0].delta and message.choices[0].delta.content:
494
- chunk = message.choices[0].delta.content
495
- response += chunk
496
- yield response # Yield partial response
 
 
 
 
497
 
498
  logging.info("Finished generating response")
499
 
 
484
  response = ""
485
  for i in range(num_calls):
486
  logging.info(f"API call {i+1}/{num_calls}")
487
+ try:
488
+ for message in client.chat_completion(
489
+ messages=[{"role": "user", "content": prompt}],
490
+ max_tokens=10000,
491
+ temperature=temperature,
492
+ stream=True,
493
+ ):
494
+ if message.choices and message.choices[0].delta and message.choices[0].delta.content:
495
+ chunk = message.choices[0].delta.content
496
+ response += chunk
497
+ yield response # Yield partial response
498
+ logging.info(f"API call {i+1} completed successfully")
499
+ except Exception as e:
500
+ logging.error(f"Error in API call {i+1}: {str(e)}")
501
 
502
  logging.info("Finished generating response")
503