Add multilingual STT support and config UI/runtime updates
This commit is contained in:
parent
ed950cb7c4
commit
4a69c3d333
26 changed files with 2207 additions and 465 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from dataclasses import asdict, dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -50,14 +51,18 @@ def run_diagnostics(config_path: str | None) -> DiagnosticReport:
|
|||
id="config.load",
|
||||
ok=False,
|
||||
message=f"failed to load config: {exc}",
|
||||
hint="run `aman init --force` to regenerate a default config",
|
||||
hint=(
|
||||
"open Settings... from Aman tray to save a valid config, or run "
|
||||
"`aman init --force` for automation"
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
checks.extend(_audio_check(cfg))
|
||||
checks.extend(_hotkey_check(cfg))
|
||||
checks.extend(_injection_backend_check(cfg))
|
||||
checks.extend(_model_check())
|
||||
checks.extend(_provider_check(cfg))
|
||||
checks.extend(_model_check(cfg))
|
||||
return DiagnosticReport(checks=checks)
|
||||
|
||||
|
||||
|
|
@ -138,7 +143,72 @@ def _injection_backend_check(cfg: Config | None) -> list[DiagnosticCheck]:
|
|||
]
|
||||
|
||||
|
||||
def _model_check() -> list[DiagnosticCheck]:
|
||||
def _provider_check(cfg: Config | None) -> list[DiagnosticCheck]:
|
||||
if cfg is None:
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="provider.runtime",
|
||||
ok=False,
|
||||
message="skipped because config failed to load",
|
||||
hint="fix config.load first",
|
||||
)
|
||||
]
|
||||
if cfg.llm.provider == "external_api":
|
||||
key_name = cfg.external_api.api_key_env_var
|
||||
if not os.getenv(key_name, "").strip():
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="provider.runtime",
|
||||
ok=False,
|
||||
message=f"external api provider enabled but {key_name} is missing",
|
||||
hint=f"export {key_name} before starting aman",
|
||||
)
|
||||
]
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="provider.runtime",
|
||||
ok=True,
|
||||
message=f"stt={cfg.stt.provider}, llm={cfg.llm.provider}",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def _model_check(cfg: Config | None) -> list[DiagnosticCheck]:
|
||||
if cfg is None:
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="model.cache",
|
||||
ok=False,
|
||||
message="skipped because config failed to load",
|
||||
hint="fix config.load first",
|
||||
)
|
||||
]
|
||||
if cfg.llm.provider == "external_api":
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="model.cache",
|
||||
ok=True,
|
||||
message="local llm model cache check skipped (external_api provider)",
|
||||
)
|
||||
]
|
||||
if cfg.models.allow_custom_models and cfg.models.llm_model_path.strip():
|
||||
path = Path(cfg.models.llm_model_path)
|
||||
if not path.exists():
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="model.cache",
|
||||
ok=False,
|
||||
message=f"custom llm model path does not exist: {path}",
|
||||
hint="fix models.llm_model_path or disable custom model paths",
|
||||
)
|
||||
]
|
||||
return [
|
||||
DiagnosticCheck(
|
||||
id="model.cache",
|
||||
ok=True,
|
||||
message=f"custom llm model path is ready at {path}",
|
||||
)
|
||||
]
|
||||
try:
|
||||
model_path = ensure_model()
|
||||
return [DiagnosticCheck(id="model.cache", ok=True, message=f"model is ready at {model_path}")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue