Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofinch committed Dec 18, 2024
1 parent ff5859a commit 7d9e8aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 7 additions & 11 deletions pdf2zh/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def progress_bar(t: tqdm.tqdm):
"callback": progress_bar,
"cancellation_event": cancellation_event_map[session_id],
"envs": _envs,
"prompt":prompt,
"prompt": prompt,
}
try:
translate(**param)
Expand Down Expand Up @@ -332,7 +332,7 @@ def progress_bar(t: tqdm.tqdm):
label="Pages",
value=list(page_map.keys())[0],
)

page_input = gr.Textbox(
label="Page range",
visible=False,
Expand All @@ -341,14 +341,9 @@ def progress_bar(t: tqdm.tqdm):

with gr.Accordion("Open for More Experimental Options!", open=False):
gr.Markdown("#### Experimental")
threads=gr.Textbox(
label="number of threads",
interactive=True
)
prompt=gr.Textbox(
label="Custom Prompt for llm",
interactive=True,
visible=False
threads = gr.Textbox(label="number of threads", interactive=True)
prompt = gr.Textbox(
label="Custom Prompt for llm", interactive=True, visible=False
)
envs.append(prompt)

Expand All @@ -375,6 +370,7 @@ def on_select_page(choice):
return gr.update(visible=True)
else:
return gr.update(visible=False)

output_title = gr.Markdown("## Translated", visible=False)
output_file_mono = gr.File(
label="Download Translation (Mono)", visible=False
Expand All @@ -397,7 +393,7 @@ def on_select_page(choice):
""",
elem_classes=["secondary-text"],
)
page_range.select(on_select_page,page_range,page_input)
page_range.select(on_select_page, page_range, page_input)
service.select(
on_select_service,
service,
Expand Down
3 changes: 2 additions & 1 deletion pdf2zh/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def set_envs(self, envs):

def translate(self, text):
pass

def prompt(self, text, prompt):
if prompt:
context = {
Expand Down Expand Up @@ -201,7 +202,7 @@ class OllamaTranslator(BaseTranslator):
"OLLAMA_MODEL": "gemma2",
}
CustomPrompt = True

def __init__(self, lang_in, lang_out, model, envs=None, prompt=None):
self.set_envs(envs)
if not model:
Expand Down

0 comments on commit 7d9e8aa

Please sign in to comment.