config_manager¶
config_manager
¶
Utility for managing persistent application settings using configparser.
_get_config_path
¶
get_settings
¶
Returns a ConfigParser instance loaded from the settings file.
| 戻り値 | デスクリプション |
|---|---|
ConfigParser
|
configparser.ConfigParser: The loaded configuration. |
ソースコード位置: src/utils/config_manager.py
_save_config
¶
Writes the config to disk, creating the parent directory if needed.
All values are sanitised in-place before serialisation so that any pre-existing multi-line values (inherited from a previously corrupted INI) are collapsed to a single line and can't round-trip back as stray continuation lines.
ソースコード位置: src/utils/config_manager.py
_sanitize_ini_value
¶
Strips newlines from value before it reaches configparser.
configparser treats indented lines that follow a key as multi-line
continuations of that key's value. If a caller ever saves a string
containing a newline, the round-trip can corrupt neighbouring keys on
the next load — which historically leaked stray = m lines into
settings.ini and contaminated shortcut values. Collapse newlines
at the storage boundary while preserving in-line whitespace (so
whitespace-only values keep their legacy truthy semantics).
ソースコード位置: src/utils/config_manager.py
save_setting
¶
Saves a setting value for the given key.
| 引数 | デスクリプション |
|---|---|
key
|
The setting key.
タイプ:
|
value
|
The value to save.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
load_setting
¶
Loads a setting value for the given key.
| 引数 | デスクリプション |
|---|---|
key
|
The setting key.
タイプ:
|
default
|
The default value if key is not found.
タイプ:
|
| 戻り値 | デスクリプション |
|---|---|
Any
|
The loaded value or default.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
load_custom_providers
¶
Loads the list of custom LLM provider configurations.
Each provider dict has name, api_key, endpoint, and
models (comma-separated) keys. Migrates the legacy single-provider
settings on first call if the new JSON setting is empty.
| 戻り値 | デスクリプション |
|---|---|
list[dict[str, str]]
|
List of provider config dicts. |
ソースコード位置: src/utils/config_manager.py
save_custom_providers
¶
Saves the list of custom LLM provider configurations.
| 引数 | デスクリプション |
|---|---|
providers
|
List of provider config dicts with
タイプ:
|
ソースコード位置: src/utils/config_manager.py
get_custom_provider_for_model
¶
Finds the custom provider config that contains a given model name.
| 引数 | デスクリプション |
|---|---|
model
|
The model name to look up.
タイプ:
|
| 戻り値 | デスクリプション |
|---|---|
dict[str, str] | None
|
The provider dict, or None if not found. |
ソースコード位置: src/utils/config_manager.py
get_available_models
¶
Returns all available (provider, model_name) tuples from configured providers.
A provider is available when its required credentials are non-empty.
Gemini contributes all entries from GEMINI_MODELS; each custom
provider contributes its comma-separated model names.
| 戻り値 | デスクリプション |
|---|---|
list[tuple[str, str]]
|
List of (provider, model_name) tuples, e.g. |
list[tuple[str, str]]
|
|
ソースコード位置: src/utils/config_manager.py
load_model_for_feature
¶
Returns the model id to use for a given feature.
Resolution order:
- The feature's own key (e.g.
SETTING_LLM_MODEL_LIVE) if set. - Global fallback
SETTING_LLM_LAST_MODELso first-time users don't have to pick a model in every feature before using it. - Empty string — callers then fall through to the first available
model via
_resolve_provider_model.
ソースコード位置: src/utils/config_manager.py
save_model_for_feature
¶
Persists model_id under the feature's own key.
The global default (SETTING_LLM_LAST_MODEL) is owned exclusively by
the Settings → LLM "Default model" picker — this function deliberately
does not touch it, so picking a model inside one feature can never
silently change another feature's behaviour.
ソースコード位置: src/utils/config_manager.py
is_valid_endpoint
¶
Returns True when url is a well-formed http / https endpoint.
Accepts only http:// and https:// schemes — most OpenAI-compatible
inference endpoints use these, and anything else (ftp, file, bare host)
is almost certainly a typo. Requires a non-empty netloc so https://
alone is rejected.
ソースコード位置: src/utils/config_manager.py
format_model_id
¶
parse_model_id
¶
Parses "Provider:model_name" into (provider, model_name).
Falls back to (LLM_METHOD_GEMINI, DEFAULT_GEMINI_MODEL) when the
string is empty or missing the separator.
ソースコード位置: src/utils/config_manager.py
check_llm_setup
¶
Checks if at least one LLM provider has valid credentials.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if any provider is configured, False otherwise.
タイプ:
|
load_google_cloud_api_key
¶
Loads the Google Cloud API key.
| 戻り値 | デスクリプション |
|---|---|
str
|
The API key, or empty string if not configured.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_google_cloud_setup
¶
Checks if the Google Cloud API key is configured.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if the API key is present, False otherwise.
タイプ:
|
check_elevenlabs_setup
¶
Checks if the ElevenLabs API key is configured.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if the API key is present, False otherwise.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_soniox_setup
¶
Checks if the Soniox API key is configured.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if the API key is present, False otherwise.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_gemini_setup
¶
Checks if the Gemini provider is configured.
Two valid configurations:
1. Developer API — non-empty llm/gemini_api_key.
2. Vertex AI — llm/gemini_use_vertex is True AND a project
ID is set. Credentials may come from a service-account JSON
file (llm/vertex_credentials) or from Application Default
Credentials (gcloud user creds, env var, or instance metadata).
We can't easily probe ADC without a network call, so we trust
the project setting and surface ADC failures at request time
via AUTH_ERROR.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True when either configuration looks valid.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_ocr_setup
¶
Checks if a valid OCR configuration exists for the selected method.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if OCR is set up, False otherwise.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_ocr_setup_for_method
¶
Checks OCR readiness for an explicit OCR method.
| 引数 | デスクリプション |
|---|---|
method
|
Canonical OCR method name.
タイプ:
|
| 戻り値 | デスクリプション |
|---|---|
bool
|
True when the requested OCR backend is configured or available. |
ソースコード位置: src/utils/config_manager.py
check_msoffice_available
¶
Checks if Microsoft Office is available via win32com (Windows only).
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if win32com can be imported, False otherwise.
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_libreoffice_available
¶
Checks if LibreOffice UNO is available.
Adds platform-specific search paths to sys.path so that a
system-installed LibreOffice is found even inside a virtualenv.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if the
タイプ:
|
ソースコード位置: src/utils/config_manager.py
check_office_converter_setup
¶
Checks if an office converter backend (win32com or UNO) is available.
These backends are required to convert legacy/ODF files to modern format.
| 戻り値 | デスクリプション |
|---|---|
bool
|
True if at least one converter is available, False otherwise.
タイプ:
|