Handle empty string case in maybe_trim_space (#1055)

* Handle empty string case in maybe_trim_space

* nit

---------

Co-authored-by: Awni Hannun <awni@apple.com>
This commit is contained in:
aronson 2024-10-20 22:46:43 -05:00 committed by GitHub
parent f491d473a3
commit 743763bc2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -193,7 +193,9 @@ class BPEStreamingDetokenizer(StreamingDetokenizer):
self.tokens = []
def _maybe_trim_space(self, current_text):
if current_text[0] != " ":
if len(current_text) == 0:
return current_text
elif current_text[0] != " ":
return current_text
elif not self.text:
return current_text[1:]