Make Word equation mode configurable

This commit is contained in:
Edern Deneuville
2026-09-11 14:05:54 +02:00
parent 693c165c51
commit 63dbde759d
+6 -6
View File
@@ -6,7 +6,7 @@ from pathlib import Path
from typing import Any, Literal
Provider = Literal["ollama", "gemini"]
MathTextFormat = Literal["plain", "unicode", "unicode_math"]
MathTextFormat = Literal["plain", "unicode", "unicode_math", "word_equation"]
@dataclass(frozen=True)
@@ -19,7 +19,7 @@ class AppConfig:
request_timeout_seconds: float | None = 300.0
copy_wait_seconds: float = 1.0
type_delay_seconds: float = 0.0
math_text_format: MathTextFormat = "unicode"
math_text_format: MathTextFormat = "word_equation"
restore_clipboard: bool = True
system_prompt: str = (
"Réponds directement et de manière ultra-concise. "
@@ -43,9 +43,9 @@ def _coerce_timeout(value: Any) -> float | None:
def _coerce_math_text_format(value: Any) -> MathTextFormat:
mode = str(value or "unicode").lower().strip()
if mode not in {"plain", "unicode", "unicode_math"}:
raise ValueError("config.math_text_format doit être 'plain' ou 'unicode'")
mode = str(value or "word_equation").lower().strip()
if mode not in {"plain", "unicode", "unicode_math", "word_equation"}:
raise ValueError("config.math_text_format doit être 'plain', 'unicode' ou 'word_equation'")
return mode # type: ignore[return-value]
@@ -65,7 +65,7 @@ def load_config(path: str | Path = "config.json") -> AppConfig:
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)),
math_text_format=_coerce_math_text_format(data.get("math_text_format", "unicode")),
math_text_format=_coerce_math_text_format(data.get("math_text_format", "word_equation")),
restore_clipboard=bool(data.get("restore_clipboard", True)),
system_prompt=str(data.get("system_prompt", AppConfig.system_prompt)),
)