Allow configurable disabled request timeout

This commit is contained in:
Edern Deneuville
2026-09-11 13:43:28 +02:00
parent 7bac4874d9
commit eb1d9529d6
+9 -2
View File
@@ -15,7 +15,7 @@ class AppConfig:
api_key: str = ""
server_url: str = "http://localhost:11434"
hotkey: str = "ctrl+alt+a"
request_timeout_seconds: float = 120.0
request_timeout_seconds: float | None = 300.0
copy_wait_seconds: float = 1.0
type_delay_seconds: float = 0.0
restore_clipboard: bool = True
@@ -33,6 +33,13 @@ def _coerce_provider(value: Any) -> Provider:
return provider # type: ignore[return-value]
def _coerce_timeout(value: Any) -> float | None:
timeout = float(value)
if timeout <= 0:
return None
return timeout
def load_config(path: str | Path = "config.json") -> AppConfig:
cfg_path = Path(path)
if not cfg_path.exists():
@@ -46,7 +53,7 @@ def load_config(path: str | Path = "config.json") -> AppConfig:
api_key=str(data.get("api_key", "")),
server_url=str(data.get("server_url", "http://localhost:11434")).rstrip("/"),
hotkey=str(data.get("hotkey", "ctrl+alt+a")).lower(),
request_timeout_seconds=float(data.get("request_timeout_seconds", 120)),
request_timeout_seconds=_coerce_timeout(data.get("request_timeout_seconds", 300)),
copy_wait_seconds=float(data.get("copy_wait_seconds", 1)),
type_delay_seconds=float(data.get("type_delay_seconds", 0)),
restore_clipboard=bool(data.get("restore_clipboard", True)),