fixed: The choices may be empty. (#876)

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
dashi6174 2024-05-22 15:29:07 +08:00 committed by GitHub
parent be13429d05
commit 21453ffff0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,6 +56,7 @@ class Base(ABC):
stream=True,
**gen_conf)
for resp in response:
if len(resp.choices) == 0:continue
if not resp.choices[0].delta.content:continue
ans += resp.choices[0].delta.content
total_tokens += 1