|
@@ -13,6 +13,7 @@ from gradio_pdf import PDF
|
|
|
|
|
|
|
|
from pdf2zh import __version__
|
|
from pdf2zh import __version__
|
|
|
from pdf2zh.high_level import translate
|
|
from pdf2zh.high_level import translate
|
|
|
|
|
+from pdf2zh.pdf2zh import model
|
|
|
from pdf2zh.translator import (
|
|
from pdf2zh.translator import (
|
|
|
AnythingLLMTranslator,
|
|
AnythingLLMTranslator,
|
|
|
AzureOpenAITranslator,
|
|
AzureOpenAITranslator,
|
|
@@ -22,6 +23,7 @@ from pdf2zh.translator import (
|
|
|
DeepLTranslator,
|
|
DeepLTranslator,
|
|
|
DeepLXTranslator,
|
|
DeepLXTranslator,
|
|
|
DifyTranslator,
|
|
DifyTranslator,
|
|
|
|
|
+ ArgosTranslator,
|
|
|
GeminiTranslator,
|
|
GeminiTranslator,
|
|
|
GoogleTranslator,
|
|
GoogleTranslator,
|
|
|
ModelScopeTranslator,
|
|
ModelScopeTranslator,
|
|
@@ -51,6 +53,7 @@ service_map: dict[str, BaseTranslator] = {
|
|
|
"Tencent": TencentTranslator,
|
|
"Tencent": TencentTranslator,
|
|
|
"Dify": DifyTranslator,
|
|
"Dify": DifyTranslator,
|
|
|
"AnythingLLM": AnythingLLMTranslator,
|
|
"AnythingLLM": AnythingLLMTranslator,
|
|
|
|
|
+ "Argos Translate": ArgosTranslator,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# The following variables associate strings with specific languages
|
|
# The following variables associate strings with specific languages
|
|
@@ -265,6 +268,7 @@ def translate_file(
|
|
|
"cancellation_event": cancellation_event_map[session_id],
|
|
"cancellation_event": cancellation_event_map[session_id],
|
|
|
"envs": _envs,
|
|
"envs": _envs,
|
|
|
"prompt": prompt,
|
|
"prompt": prompt,
|
|
|
|
|
+ "model": model,
|
|
|
}
|
|
}
|
|
|
try:
|
|
try:
|
|
|
translate(**param)
|
|
translate(**param)
|
|
@@ -587,7 +591,9 @@ def parse_user_passwd(file_path: str) -> tuple:
|
|
|
return tuple_list, content
|
|
return tuple_list, content
|
|
|
|
|
|
|
|
|
|
|
|
|
-def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
|
|
|
|
+def setup_gui(
|
|
|
|
|
+ share: bool = False, auth_file: list = ["", ""], server_port=7860
|
|
|
|
|
+) -> None:
|
|
|
"""
|
|
"""
|
|
|
Setup the GUI with the given parameters.
|
|
Setup the GUI with the given parameters.
|
|
|
|
|
|
|
@@ -605,7 +611,11 @@ def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
if len(user_list) == 0:
|
|
if len(user_list) == 0:
|
|
|
try:
|
|
try:
|
|
|
demo.launch(
|
|
demo.launch(
|
|
|
- server_name="0.0.0.0", debug=True, inbrowser=True, share=share
|
|
|
|
|
|
|
+ server_name="0.0.0.0",
|
|
|
|
|
+ debug=True,
|
|
|
|
|
+ inbrowser=True,
|
|
|
|
|
+ share=share,
|
|
|
|
|
+ server_port=server_port,
|
|
|
)
|
|
)
|
|
|
except Exception:
|
|
except Exception:
|
|
|
print(
|
|
print(
|
|
@@ -613,13 +623,19 @@ def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
)
|
|
)
|
|
|
try:
|
|
try:
|
|
|
demo.launch(
|
|
demo.launch(
|
|
|
- server_name="127.0.0.1", debug=True, inbrowser=True, share=share
|
|
|
|
|
|
|
+ server_name="127.0.0.1",
|
|
|
|
|
+ debug=True,
|
|
|
|
|
+ inbrowser=True,
|
|
|
|
|
+ share=share,
|
|
|
|
|
+ server_port=server_port,
|
|
|
)
|
|
)
|
|
|
except Exception:
|
|
except Exception:
|
|
|
print(
|
|
print(
|
|
|
"Error launching GUI using 127.0.0.1.\nThis may be caused by global mode of proxy software."
|
|
"Error launching GUI using 127.0.0.1.\nThis may be caused by global mode of proxy software."
|
|
|
)
|
|
)
|
|
|
- demo.launch(debug=True, inbrowser=True, share=True)
|
|
|
|
|
|
|
+ demo.launch(
|
|
|
|
|
+ debug=True, inbrowser=True, share=True, server_port=server_port
|
|
|
|
|
+ )
|
|
|
else:
|
|
else:
|
|
|
try:
|
|
try:
|
|
|
demo.launch(
|
|
demo.launch(
|
|
@@ -629,6 +645,7 @@ def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
share=share,
|
|
share=share,
|
|
|
auth=user_list,
|
|
auth=user_list,
|
|
|
auth_message=html,
|
|
auth_message=html,
|
|
|
|
|
+ server_port=server_port,
|
|
|
)
|
|
)
|
|
|
except Exception:
|
|
except Exception:
|
|
|
print(
|
|
print(
|
|
@@ -642,6 +659,7 @@ def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
share=share,
|
|
share=share,
|
|
|
auth=user_list,
|
|
auth=user_list,
|
|
|
auth_message=html,
|
|
auth_message=html,
|
|
|
|
|
+ server_port=server_port,
|
|
|
)
|
|
)
|
|
|
except Exception:
|
|
except Exception:
|
|
|
print(
|
|
print(
|
|
@@ -653,6 +671,7 @@ def setup_gui(share: bool = False, auth_file: list = ["", ""]) -> None:
|
|
|
share=True,
|
|
share=True,
|
|
|
auth=user_list,
|
|
auth=user_list,
|
|
|
auth_message=html,
|
|
auth_message=html,
|
|
|
|
|
+ server_port=server_port,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|