diff --git a/jsons/cote_replacements.json b/jsons/cote_replacements.json index cfa70d0..27d039b 100644 --- a/jsons/cote_replacements.json +++ b/jsons/cote_replacements.json @@ -168,7 +168,7 @@ "Manabe Shiho": ["真鍋","志保"], "Mashima Tomonari": ["真嶋","智也"], "Matsushita Chiaki": ["松下","千秋"], - "Minami Hakuo": ["南伯夫"], + "Minami Hakuo": ["南","伯夫"], "Miyake Akito": ["三宅","明人"], "Miyamoto Sōshi":["宮本","蒼士"], "Morishige Takurō": ["森重","卓郎"], diff --git a/kudasai.py b/kudasai.py index 03267c2..2b4cefc 100644 --- a/kudasai.py +++ b/kudasai.py @@ -214,7 +214,7 @@ async def run_kudasai() -> None: and Kudasai.knowledge_base != ""): Kudasai.text_to_preprocess, indexing_log = Kudasai.run_kairyou_indexer(Kudasai.text_to_preprocess, Kudasai.replacement_json, Kudasai.knowledge_base) - preprocessed_text, preprocessing_log, error_log = Kairyou.preprocess(Kudasai.text_to_preprocess, Kudasai.replacement_json) + preprocessed_text, preprocessing_log, error_log = Kairyou.preprocess(Kudasai.text_to_preprocess, Kudasai.replacement_json, add_closing_period=True) ## Need to set this so auto-translation can use the preprocessed text Kudasai.text_to_preprocess = preprocessed_text diff --git a/requirements.txt b/requirements.txt index ab4d338..c3a8776 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ backoff==2.2.1 -gradio==4.44.0 -kairyou==1.6.5 -easytl==0.4.10 +gradio==5.5.0 +kairyou==1.6.7 +easytl==0.5.1 python-dotenv diff --git a/webgui.py b/webgui.py index ae06099..484a079 100644 --- a/webgui.py +++ b/webgui.py @@ -29,6 +29,8 @@ from kudasai import Kudasai +## since debug log doesn't update periodically, we need to somehow show progress updates in the gui for the translation tab, should get the info from backend somehow idk + ##-------------------start-of-KudasaiGUI--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class KudasaiGUI: @@ -106,7 +108,24 @@ def build_gui(self) -> None: """ - with gr.Blocks(title="Kudasai", delete_cache=(300, 300), analytics_enabled=False) as self.gui: + with gr.Blocks( + title="Kudasai", + delete_cache=(300, 300), + analytics_enabled=False, + ) as self.gui: + self.gui.load( + None, + None, + js=""" + () => { + const params = new URLSearchParams(window.location.search); + if (!params.has('__theme')) { + params.set('__theme', 'dark'); + window.location.search = params.toString(); + } + }""" + ) + ##-------------------start-of-Utility-Functions--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ##-------------------start-of-fetch_log_content()--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -860,12 +879,13 @@ def index(input_txt_file:gr.File, input_json_file_preprocessing:gr.File, input_k else: knowledge_base_paths = [file for file in input_knowledge_base_directory] + for file in knowledge_base_paths: knowledge_base_string += gui_get_text_from_file(file) gr.Info("Indexing may take a while, please be patient.") - unique_names, indexing_log = Indexer.index(text_to_index, knowledge_base_string, replacements) + unique_names, indexing_log = Indexer.index(text_to_index, knowledge_base_string, replacements, discard_ner_objects=False) ## Indexer does not directly log anything, in case of anything else touching it, we will grab the log from the log file log_text = FileEnsurer.standard_read_file(FileEnsurer.debug_log_path) @@ -922,7 +942,7 @@ def preprocess(input_txt_file:gr.File, input_json_file_preprocessing:gr.File, in try: - preprocessed_text, preprocessing_log, error_log = Kairyou.preprocess(text_to_preprocess, replacements) + preprocessed_text, preprocessing_log, error_log = Kairyou.preprocess(text_to_preprocess, replacements, discard_ner_objects=False) except InvalidReplacementJsonKeys: ## link needs to be updated later @@ -1674,9 +1694,7 @@ def switch_translator_api_key_type(translation_method:str) -> str: self.translator_translate_button.click(fn=fetch_log_content, inputs=[], - outputs=[self.translator_debug_log_output_field], ## debug log on translator tab - - every=.1) ## update every 100ms + outputs=[self.translator_debug_log_output_field]) ##-------------------start-of translator_calculate_costs_button_click()--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -2157,8 +2175,12 @@ def toggle_text_inputs(file_input, text_input): if current_time - KudasaiGUI.last_text_change < KudasaiGUI.debounce_delay: # If it's a text change and we're within the debounce period, don't update return gr.update(), gr.update() - self.last_text_change = current_time - return gr.update(placeholder=""), gr.update(interactive=not bool(file_input)), gr.update(interactive=not bool(text_input)) + KudasaiGUI.last_text_change = current_time + + return ( + gr.update(placeholder="", interactive=not bool(file_input)), # text input update + gr.update(interactive=not bool(text_input)) # file input update + ) ## For preprocessor