make gemini robust (#3012)

### What problem does this PR solve?

#3003

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu 2024-10-25 10:50:44 +08:00 committed by GitHub
parent 648f8e81d1
commit 9457d20ef1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -780,10 +780,11 @@ class GeminiChat(Base):
ans += resp.text
yield ans
yield response._chunks[-1].usage_metadata.total_token_count
except Exception as e:
yield ans + "\n**ERROR**: " + str(e)
yield response._chunks[-1].usage_metadata.total_token_count
yield 0
class GroqChat: