mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-02 09:30:24 +00:00
feat: all print green
This commit is contained in:
parent
cc64495d90
commit
4cfe467c5f
@ -1,6 +1,8 @@
|
||||
import json
|
||||
import re
|
||||
|
||||
import requests
|
||||
from rich import print
|
||||
|
||||
from .base_translator import Base
|
||||
|
||||
@ -42,5 +44,5 @@ class Caiyun(Base):
|
||||
headers=self.headers,
|
||||
)
|
||||
t_text = json.loads(response.text)["target"]
|
||||
print(t_text)
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
return t_text
|
||||
|
@ -1,4 +1,4 @@
|
||||
import requests
|
||||
import re
|
||||
from revChatGPT.V1 import Chatbot
|
||||
from rich import print
|
||||
|
||||
@ -24,10 +24,10 @@ class ChatGPTAccount(Base):
|
||||
}
|
||||
)
|
||||
prompt = f"Please help me to translate,`{text}` to {self.language}"
|
||||
response = ""
|
||||
t_text = ""
|
||||
|
||||
for data in chatbot.ask(prompt):
|
||||
response = data["message"].encode("utf8").decode()
|
||||
t_text = data["message"].encode("utf8").decode()
|
||||
|
||||
print(response)
|
||||
return response
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
return t_text
|
||||
|
@ -2,10 +2,12 @@ import json
|
||||
import time
|
||||
|
||||
import requests
|
||||
import re
|
||||
|
||||
from book_maker.utils import LANGUAGES, TO_LANGUAGE_CODE
|
||||
|
||||
from .base_translator import Base
|
||||
from rich import print
|
||||
|
||||
|
||||
class DeepL(Base):
|
||||
@ -83,5 +85,5 @@ class DeepL(Base):
|
||||
headers=self.headers,
|
||||
)
|
||||
t_text = response.json().get("text", "")
|
||||
print(t_text)
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
return t_text
|
||||
|
@ -1,4 +1,7 @@
|
||||
import re
|
||||
import requests
|
||||
from rich import print
|
||||
|
||||
|
||||
from .base_translator import Base
|
||||
|
||||
@ -34,5 +37,5 @@ class Google(Base):
|
||||
t_text = "".join(
|
||||
[sentence.get("trans", "") for sentence in r.json()["sentences"]],
|
||||
)
|
||||
print(t_text)
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
return t_text
|
||||
|
@ -1,3 +1,4 @@
|
||||
import re
|
||||
import requests
|
||||
from rich import print
|
||||
|
||||
@ -45,5 +46,5 @@ class GPT3(Base):
|
||||
if not r.ok:
|
||||
return text
|
||||
t_text = r.json().get("choices")[0].get("text", "").strip()
|
||||
print(t_text)
|
||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||
return t_text
|
||||
|
Loading…
x
Reference in New Issue
Block a user