Skip to content

Commit

Permalink
make gpt more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
zyddnys committed Jun 17, 2024
1 parent ad5171f commit 371f5aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions manga_translator/translators/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ async def _translate(self, from_lang: str, to_lang: str, queries: List[str]) ->
# Try splitting by newlines instead
new_translations = re.split(r'\n', response)

if len(new_translations) != query_size:
# super method will repeat translation as per self._INVALID_REPEAT_COUNT
translations = []
break
if len(new_translations) > query_size:
new_translations = new_translations[: len(query_size)]
elif len(new_translations) < query_size :
new_translations = new_translations + [''] * (query_size - len(new_translations))

translations.extend([t.strip() for t in new_translations])

Expand Down

0 comments on commit 371f5aa

Please sign in to comment.