mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
fix: 374
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
5a8cbf496f
commit
cb3779f279
4
.gitignore
vendored
4
.gitignore
vendored
@ -134,3 +134,7 @@ dmypy.json
|
||||
/test_books/*.epub
|
||||
log/
|
||||
.chatgpt_cache.json
|
||||
# for user do not want to push
|
||||
*.srt
|
||||
*.txt
|
||||
*.bin
|
||||
|
@ -21,6 +21,7 @@ GPT35_MODEL_LIST = [
|
||||
"gpt-3.5-turbo-0613",
|
||||
"gpt-3.5-turbo-16k-0613",
|
||||
"gpt-3.5-turbo-0301",
|
||||
"gpt-3.5-turbo-0125",
|
||||
]
|
||||
GPT4_MODEL_LIST = [
|
||||
"gpt-4-1106-preview",
|
||||
|
@ -53,6 +53,13 @@ class Gemini(Base):
|
||||
|
||||
def translate(self, text):
|
||||
t_text = ""
|
||||
print(text)
|
||||
# same for caiyun translate src issue #279 gemini for #374
|
||||
text_list = text.splitlines()
|
||||
num = None
|
||||
if len(text_list) > 1:
|
||||
if text_list[0].isdigit():
|
||||
num = text_list[0]
|
||||
try:
|
||||
self.convo.send_message(
|
||||
self.DEFAULT_PROMPT.format(text=text, language=self.language)
|
||||
@ -60,7 +67,6 @@ class Gemini(Base):
|
||||
print(text)
|
||||
t_text = self.convo.last.text.strip()
|
||||
except StopCandidateException as e:
|
||||
print("Here")
|
||||
match = re.search(r'content\s*{\s*parts\s*{\s*text:\s*"([^"]+)"', str(e))
|
||||
if match:
|
||||
t_text = match.group(1)
|
||||
@ -80,4 +86,6 @@ class Gemini(Base):
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
# for limit
|
||||
time.sleep(0.5)
|
||||
if num:
|
||||
t_text = str(num) + "\n" + t_text
|
||||
return t_text
|
||||
|
Loading…
x
Reference in New Issue
Block a user