mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
parent
98e3dd680c
commit
7e0f4fce54
BIN
.lemo.temp.bin
Normal file
BIN
.lemo.temp.bin
Normal file
Binary file not shown.
@ -82,7 +82,11 @@ class EPUBBookLoader(BaseBookLoader):
|
|||||||
else:
|
else:
|
||||||
obj.out.writestr("%s" % item.file_name, item.content)
|
obj.out.writestr("%s" % item.file_name, item.content)
|
||||||
|
|
||||||
|
def _check_deprecated(obj):
|
||||||
|
pass
|
||||||
|
|
||||||
epub.EpubWriter._write_items = _write_items_patch
|
epub.EpubWriter._write_items = _write_items_patch
|
||||||
|
epub.EpubReader._check_deprecated = _check_deprecated # drop the warning
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.origin_book = epub.read_epub(self.epub_name)
|
self.origin_book = epub.read_epub(self.epub_name)
|
||||||
|
@ -4,7 +4,7 @@ from copy import copy
|
|||||||
from os import environ
|
from os import environ
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from openai import AzureOpenAI, OpenAI
|
from openai import AzureOpenAI, OpenAI, RateLimitError
|
||||||
from rich import print
|
from rich import print
|
||||||
|
|
||||||
from .base_translator import Base
|
from .base_translator import Base
|
||||||
@ -94,11 +94,7 @@ class ChatGPTAPI(Base):
|
|||||||
self.rotate_key()
|
self.rotate_key()
|
||||||
self.rotate_model() # rotate all the model to avoid the limit
|
self.rotate_model() # rotate all the model to avoid the limit
|
||||||
|
|
||||||
try:
|
completion = self.create_chat_completion(text)
|
||||||
completion = self.create_chat_completion(text)
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
pass
|
|
||||||
|
|
||||||
# TODO work well or exception finish by length limit
|
# TODO work well or exception finish by length limit
|
||||||
t_text = completion.choices[0].message.content.encode("utf8").decode() or ""
|
t_text = completion.choices[0].message.content.encode("utf8").decode() or ""
|
||||||
@ -119,7 +115,7 @@ class ChatGPTAPI(Base):
|
|||||||
try:
|
try:
|
||||||
t_text = self.get_translation(text)
|
t_text = self.get_translation(text)
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except RateLimitError as e:
|
||||||
# todo: better sleep time? why sleep alawys about key_len
|
# todo: better sleep time? why sleep alawys about key_len
|
||||||
# 1. openai server error or own network interruption, sleep for a fixed time
|
# 1. openai server error or own network interruption, sleep for a fixed time
|
||||||
# 2. an apikey has no money or reach limit, don`t sleep, just replace it with another apikey
|
# 2. an apikey has no money or reach limit, don`t sleep, just replace it with another apikey
|
||||||
@ -131,6 +127,8 @@ class ChatGPTAPI(Base):
|
|||||||
if attempt_count == max_attempts:
|
if attempt_count == max_attempts:
|
||||||
print(f"Get {attempt_count} consecutive exceptions")
|
print(f"Get {attempt_count} consecutive exceptions")
|
||||||
raise
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
print(str(e), "!!")
|
||||||
|
|
||||||
# todo: Determine whether to print according to the cli option
|
# todo: Determine whether to print according to the cli option
|
||||||
if needprint:
|
if needprint:
|
||||||
|
2
setup.py
2
setup.py
@ -17,7 +17,7 @@ packages = [
|
|||||||
setup(
|
setup(
|
||||||
name="bbook_maker",
|
name="bbook_maker",
|
||||||
description="The bilingual_book_maker is an AI translation tool that uses ChatGPT to assist users in creating multi-language versions of epub/txt files and books.",
|
description="The bilingual_book_maker is an AI translation tool that uses ChatGPT to assist users in creating multi-language versions of epub/txt files and books.",
|
||||||
version="0.6.0",
|
version="0.6.1",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
author="yihong0618",
|
author="yihong0618",
|
||||||
author_email="zouzou0208@gmail.com",
|
author_email="zouzou0208@gmail.com",
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user