From 306f0af734e61a5bcf6a67ef37d5054876f35427 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Mon, 20 Oct 2025 03:48:41 +0900 Subject: [PATCH] =?UTF-8?q?controller:=20=E7=BF=BB=E8=A8=B3=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E9=81=B8=E6=8A=9E=E6=99=82=E3=81=AB=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E9=81=A9=E7=94=A8=E3=81=A8=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=82=A2=E3=83=B3=E3=83=88=E6=9B=B4=E6=96=B0=E3=82=92?= =?UTF-8?q?=E7=A2=BA=E5=AE=9F=E3=81=AB=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20-=20=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E9=81=B8=E6=8A=9E=E6=99=82=E3=81=8A=E3=82=88=E3=81=B3?= =?UTF-8?q?=E6=98=8E=E7=A4=BA=E7=9A=84=E3=81=AA=E3=83=A2=E3=83=87=E3=83=AB?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=99=82=E3=81=AB=20model.setTranslatorXMode?= =?UTF-8?q?l(...)=20=E3=82=92=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E3=80=81?= =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E7=8A=B6=E6=85=8B=E3=82=92=E7=A2=BA?= =?UTF-8?q?=E5=AE=9F=E3=81=AB=E5=8F=8D=E6=98=A0=20-=20OpenAI/LMStudio/Olla?= =?UTF-8?q?ma/Plamo/Gemini/Ollama=20=E3=81=A7=E3=82=AF=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=83=88=E6=9B=B4=E6=96=B0=E3=82=92=E9=81=A9?= =?UTF-8?q?=E5=88=87=E3=81=AA=E7=AE=87=E6=89=80=E3=81=AB=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=97=E3=81=A6=E6=95=B4=E5=90=88=E6=80=A7=E3=82=92=E5=90=91?= =?UTF-8?q?=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mainloop: LMStudio/Ollama 接続チェックのエンドポイントを run 系に変更、ローマ字変換関連を追加 - "/get/data/*_connection" → "/run/*_connection" に変更(LMStudio/Ollama) - ローマ字変換(convert_message_to_romaji) のマッピングを追加(取得/有効化/無効化) translation_ollama: 認証チェックのエンドポイント呼び出しを修正 - base_url + "/api/ping" ではなく base_url 直下に対して GET を行うよう変更(環境による応答差異に対応) --- src-python/controller.py | 14 ++++++++++++++ src-python/mainloop.py | 5 +++-- .../models/translation/translation_ollama.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src-python/controller.py b/src-python/controller.py index c33ffe54..f12afec9 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1625,6 +1625,7 @@ class Controller: self.run(200, self.run_mapping["selectable_plamo_model_list"], config.SELECTABLE_PLAMO_MODEL_LIST) if config.SELECTED_PLAMO_MODEL not in config.SELECTABLE_PLAMO_MODEL_LIST: config.SELECTED_PLAMO_MODEL = config.SELECTABLE_PLAMO_MODEL_LIST[0] + model.setTranslatorPlamoModel(model=config.SELECTED_PLAMO_MODEL) self.run(200, self.run_mapping["selected_plamo_model"], config.SELECTED_PLAMO_MODEL) model.updateTranslatorPlamoClient() self.updateTranslationEngineAndEngineList() @@ -1678,6 +1679,7 @@ class Controller: result = model.setTranslatorPlamoModel(model=data) if result is True: config.SELECTED_PLAMO_MODEL = data + model.setTranslatorPlamoModel(model=config.SELECTED_PLAMO_MODEL) model.updateTranslatorPlamoClient() response = {"status":200, "result":config.SELECTED_PLAMO_MODEL} else: @@ -1719,6 +1721,7 @@ class Controller: self.run(200, self.run_mapping["selectable_gemini_model_list"], config.SELECTABLE_GEMINI_MODEL_LIST) if config.SELECTED_GEMINI_MODEL not in config.SELECTABLE_GEMINI_MODEL_LIST: config.SELECTED_GEMINI_MODEL = config.SELECTABLE_GEMINI_MODEL_LIST[0] + model.setTranslatorGeminiModel(model=config.SELECTED_GEMINI_MODEL) self.run(200, self.run_mapping["selected_gemini_model"], config.SELECTED_GEMINI_MODEL) model.updateTranslatorGeminiClient() self.updateTranslationEngineAndEngineList() @@ -1772,6 +1775,7 @@ class Controller: result = model.setTranslatorGeminiModel(model=data) if result is True: config.SELECTED_GEMINI_MODEL = data + model.setTranslatorGeminiModel(model=config.SELECTED_GEMINI_MODEL) model.updateTranslatorGeminiClient() response = {"status":200, "result":config.SELECTED_GEMINI_MODEL} else: @@ -1812,6 +1816,7 @@ class Controller: self.run(200, self.run_mapping["selectable_openai_model_list"], config.SELECTABLE_OPENAI_MODEL_LIST) if config.SELECTED_OPENAI_MODEL not in config.SELECTABLE_OPENAI_MODEL_LIST: config.SELECTED_OPENAI_MODEL = config.SELECTABLE_OPENAI_MODEL_LIST[0] + model.setTranslatorOpenAIModel(model=config.SELECTED_OPENAI_MODEL) self.run(200, self.run_mapping["selected_openai_model"], config.SELECTED_OPENAI_MODEL) model.updateTranslatorOpenAIClient() self.updateTranslationEngineAndEngineList() @@ -1857,6 +1862,8 @@ class Controller: result = model.setTranslatorOpenAIModel(model=data) if result is True: config.SELECTED_OPENAI_MODEL = data + model.setTranslatorOpenAIModel(model=config.SELECTED_OPENAI_MODEL) + model.updateTranslatorOpenAIClient() response = {"status":200, "result":config.SELECTED_OPENAI_MODEL} else: response = { @@ -1888,6 +1895,7 @@ class Controller: self.run(200, self.run_mapping["selectable_lmstudio_model_list"], config.SELECTABLE_LMSTUDIO_MODEL_LIST) if config.SELECTED_LMSTUDIO_MODEL not in config.SELECTABLE_LMSTUDIO_MODEL_LIST: config.SELECTED_LMSTUDIO_MODEL = config.SELECTABLE_LMSTUDIO_MODEL_LIST[0] + model.setTranslatorLMStudioModel(model=config.SELECTED_LMSTUDIO_MODEL) self.run(200, self.run_mapping["selected_lmstudio_model"], config.SELECTED_LMSTUDIO_MODEL) model.updateTranslatorLMStudioClient() self.updateTranslationEngineAndEngineList() @@ -1927,6 +1935,7 @@ class Controller: self.run(200, self.run_mapping["selectable_lmstudio_model_list"], config.SELECTABLE_LMSTUDIO_MODEL_LIST) if config.SELECTED_LMSTUDIO_MODEL not in config.SELECTABLE_LMSTUDIO_MODEL_LIST: config.SELECTED_LMSTUDIO_MODEL = config.SELECTABLE_LMSTUDIO_MODEL_LIST[0] + model.setTranslatorLMStudioModel(model=config.SELECTED_LMSTUDIO_MODEL) self.run(200, self.run_mapping["selected_lmstudio_model"], config.SELECTED_LMSTUDIO_MODEL) model.updateTranslatorLMStudioClient() self.updateTranslationEngineAndEngineList() @@ -1964,6 +1973,8 @@ class Controller: result = model.setTranslatorLMStudioModel(model=data) if result is True: config.SELECTED_LMSTUDIO_MODEL = data + model.setTranslatorLMStudioModel(model=config.SELECTED_LMSTUDIO_MODEL) + model.updateTranslatorLMStudioClient() response = {"status":200, "result":config.SELECTED_LMSTUDIO_MODEL} else: response = { @@ -1995,6 +2006,7 @@ class Controller: self.run(200, self.run_mapping["selectable_ollama_model_list"], config.SELECTABLE_OLLAMA_MODEL_LIST) if config.SELECTED_OLLAMA_MODEL not in config.SELECTABLE_OLLAMA_MODEL_LIST: config.SELECTED_OLLAMA_MODEL = config.SELECTABLE_OLLAMA_MODEL_LIST[0] + model.setTranslatorOllamaModel(model=config.SELECTED_OLLAMA_MODEL) self.run(200, self.run_mapping["selected_ollama_model"], config.SELECTED_OLLAMA_MODEL) model.updateTranslatorOllamaClient() self.updateTranslationEngineAndEngineList() @@ -2032,6 +2044,8 @@ class Controller: result = model.setTranslatorOllamaModel(model=data) if result is True: config.SELECTED_OLLAMA_MODEL = data + model.setTranslatorOllamaModel(model=config.SELECTED_OLLAMA_MODEL) + model.updateTranslatorOllamaClient() response = {"status":200, "result":config.SELECTED_OLLAMA_MODEL} else: response = { diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 21e194bc..aa0cc386 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -206,18 +206,19 @@ mapping = { "/set/data/openai_auth_key": {"status": True, "variable":controller.setOpenAIAuthKey}, "/delete/data/openai_auth_key": {"status": True, "variable":controller.delOpenAIAuthKey}, - "/get/data/lmstudio_connection": {"status": True, "variable":controller.checkTranslatorLMStudioConnection}, + "/run/lmstudio_connection": {"status": True, "variable":controller.checkTranslatorLMStudioConnection}, "/get/data/lmstudio_model_list": {"status": True, "variable":controller.getTranslatorLStudioModelList}, "/get/data/lmstudio_model": {"status": True, "variable":controller.getTranslatorLMStudioModel}, "/set/data/lmstudio_model": {"status": True, "variable":controller.setTranslatorLMStudioModel}, "/get/data/lmstudio_url": {"status": True, "variable":controller.getTranslatorLMStudioURL}, "/set/data/lmstudio_url": {"status": True, "variable":controller.setTranslatorLMStudioURL}, - "/get/data/ollama_connection": {"status": True, "variable":controller.checkTranslatorOllamaConnection}, + "/run/ollama_connection": {"status": True, "variable":controller.checkTranslatorOllamaConnection}, "/get/data/ollama_model_list": {"status": True, "variable":controller.getTranslatorOllamaModelList}, "/get/data/ollama_model": {"status": True, "variable":controller.getTranslatorOllamaModel}, "/set/data/ollama_model": {"status": True, "variable":controller.setTranslatorOllamaModel}, + # Transliteration "/get/data/convert_message_to_romaji": {"status": True, "variable":controller.getConvertMessageToRomaji}, "/set/enable/convert_message_to_romaji": {"status": True, "variable":controller.setEnableConvertMessageToRomaji}, "/set/disable/convert_message_to_romaji": {"status": True, "variable":controller.setDisableConvertMessageToRomaji}, diff --git a/src-python/models/translation/translation_ollama.py b/src-python/models/translation/translation_ollama.py index 6dd1f2fb..4152c953 100644 --- a/src-python/models/translation/translation_ollama.py +++ b/src-python/models/translation/translation_ollama.py @@ -15,7 +15,7 @@ def _authentication_check(base_url: str | None = None) -> bool: """Check authentication for Ollama API. """ try: - response = requests.get(f"{base_url}/api/ping") + response = requests.get(f"{base_url}") if response.status_code == 200: return True else: