Merge pull request #3462 from ffreemt/main

Add return_exceptions to batch_completion (retry)
This commit is contained in:
Ishaan Jaff 2024-05-24 09:19:10 -07:00 committed by GitHub
commit 466accd4f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View file

@ -2535,6 +2535,7 @@ def batch_completion(
list: A list of completion results.
"""
args = locals()
batch_messages = messages
completions = []
model = model
@ -2588,7 +2589,15 @@ def batch_completion(
completions.append(future)
# Retrieve the results from the futures
results = [future.result() for future in completions]
# results = [future.result() for future in completions]
# return exceptions if any
results = []
for future in completions:
try:
results.append(future.result())
except Exception as exc:
results.append(exc)
return results