Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
yihong0618 2024-01-27 22:17:23 +08:00
parent 5a8cbf496f
commit cb3779f279
3 changed files with 14 additions and 1 deletions

4
.gitignore vendored
View File

@ -134,3 +134,7 @@ dmypy.json
/test_books/*.epub /test_books/*.epub
log/ log/
.chatgpt_cache.json .chatgpt_cache.json
# for user do not want to push
*.srt
*.txt
*.bin

View File

@ -21,6 +21,7 @@ GPT35_MODEL_LIST = [
"gpt-3.5-turbo-0613", "gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k-0613", "gpt-3.5-turbo-16k-0613",
"gpt-3.5-turbo-0301", "gpt-3.5-turbo-0301",
"gpt-3.5-turbo-0125",
] ]
GPT4_MODEL_LIST = [ GPT4_MODEL_LIST = [
"gpt-4-1106-preview", "gpt-4-1106-preview",

View File

@ -53,6 +53,13 @@ class Gemini(Base):
def translate(self, text): def translate(self, text):
t_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: try:
self.convo.send_message( self.convo.send_message(
self.DEFAULT_PROMPT.format(text=text, language=self.language) self.DEFAULT_PROMPT.format(text=text, language=self.language)
@ -60,7 +67,6 @@ class Gemini(Base):
print(text) print(text)
t_text = self.convo.last.text.strip() t_text = self.convo.last.text.strip()
except StopCandidateException as e: except StopCandidateException as e:
print("Here")
match = re.search(r'content\s*{\s*parts\s*{\s*text:\s*"([^"]+)"', str(e)) match = re.search(r'content\s*{\s*parts\s*{\s*text:\s*"([^"]+)"', str(e))
if match: if match:
t_text = match.group(1) 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]") print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
# for limit # for limit
time.sleep(0.5) time.sleep(0.5)
if num:
t_text = str(num) + "\n" + t_text
return t_text return t_text