LMStudio 接続チェックとモデル選択処理を追加・強化、mainloop にエンドポイント追加、LMStudio/Ollama のモデル取得を例外耐性化
- Controller に checkTranslatorLMStudioConnection を追加し、接続成功時に SELECTABLE_TRANSLATION_ENGINE_STATUS や SELECTABLE_LMSTUDIO_MODEL_LIST を更新、選択モデルのフォールバック設定・クライアント更新・UI 更新呼び出しを行うよう実装 - setTranslatorLMStudioURL を接続成功時にモデルリスト/ステータス更新や選択モデルのフォールバック処理を行うよう拡張 - checkTranslatorOllamaConnection 成功時にも SELECTABLE_TRANSLATION_ENGINE_STATUS/モデルリスト更新、選択モデルフォールバック、クライアント更新、UI 更新呼び出しを追加 - mainloop に /get/data/lmstudio_connection エンドポイントを追加して LMStudio 接続チェックを公開 - translation_lmstudio.py と translation_ollama.py のモデル取得処理を try/except で保護し、例外時は空リストを返すよう修正(接続失敗やレスポンス異常に対する耐性向上)
This commit is contained in:
@@ -25,11 +25,15 @@ def _authentication_check(api_key: str, base_url: str | None = None) -> bool:
|
||||
def _get_available_text_models(api_key: str, base_url: str | None = None) -> list[str]:
|
||||
"""Extract the list of available text models from the LM Studio.
|
||||
"""
|
||||
client = OpenAI(api_key=api_key, base_url=base_url)
|
||||
res = client.models.list()
|
||||
allowed_models = []
|
||||
try:
|
||||
client = OpenAI(api_key=api_key, base_url=base_url)
|
||||
res = client.models.list()
|
||||
models = res.data
|
||||
except Exception:
|
||||
models = []
|
||||
|
||||
for model in res.data:
|
||||
allowed_models = []
|
||||
for model in models:
|
||||
allowed_models.append(model.id)
|
||||
|
||||
allowed_models.sort()
|
||||
|
||||
@@ -26,8 +26,11 @@ def _authentication_check(base_url: str | None = None) -> bool:
|
||||
def _get_available_text_models(base_url: str | None = None) -> list[str]:
|
||||
"""Extract available text models from Ollama.
|
||||
"""
|
||||
response = requests.get(f"{base_url}/api/tags")
|
||||
models = response.json()["models"]
|
||||
try:
|
||||
response = requests.get(f"{base_url}/api/tags")
|
||||
models = response.json()["models"]
|
||||
except Exception:
|
||||
models = []
|
||||
|
||||
allowed_models = []
|
||||
for model in models:
|
||||
|
||||
Reference in New Issue
Block a user