mirror of
https://github.com/Horizontal42/Sort_YM.git
synced 2026-11-10 21:32:00 +03:00
ollama settings in config.toml
This commit is contained in:
parent
881e22c528
commit
165aa4fabc
3 changed files with 68 additions and 0 deletions
12
config.toml
12
config.toml
|
|
@ -22,6 +22,18 @@ top_artists = 40
|
||||||
# Сколько альбомов показывать поимённо; остальные - в одну строку с метрикой "альбомы vs синглы".
|
# Сколько альбомов показывать поимённо; остальные - в одну строку с метрикой "альбомы vs синглы".
|
||||||
top_albums = 15
|
top_albums = 15
|
||||||
|
|
||||||
|
[ollama]
|
||||||
|
# Локальная Ollama для разбора текстов песен (sort_ym analyze).
|
||||||
|
host = "http://localhost:11434"
|
||||||
|
model = "qwen3.6-35b-a3b:latest"
|
||||||
|
# Любое изменение промпта или схемы ответа => +1. Старые записи кэша станут невалидными
|
||||||
|
# и будут переанализированы, а это ~3 часа на полную библиотеку - не менять просто так.
|
||||||
|
prompt_version = 1
|
||||||
|
# Таймаут одного запроса, секунды. В пилоте худший трек занял 84с, 600 - запас ~7x.
|
||||||
|
timeout = 600
|
||||||
|
# Сколько Ollama держит модель загруженной между треками (иначе перезагрузка на каждый трек).
|
||||||
|
keep_alive = "30m"
|
||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
token_file = ".token"
|
token_file = ".token"
|
||||||
cache_dir = "cache"
|
cache_dir = "cache"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ class Config:
|
||||||
small_group_min: int
|
small_group_min: int
|
||||||
digest_top_artists: int
|
digest_top_artists: int
|
||||||
digest_top_albums: int
|
digest_top_albums: int
|
||||||
|
ollama_host: str
|
||||||
|
ollama_model: str
|
||||||
|
ollama_prompt_version: int
|
||||||
|
ollama_timeout: float
|
||||||
|
ollama_keep_alive: str
|
||||||
token_file: Path
|
token_file: Path
|
||||||
cache_dir: Path
|
cache_dir: Path
|
||||||
out_dir: Path
|
out_dir: Path
|
||||||
|
|
@ -36,6 +41,11 @@ def load_config(path: Path | None = None) -> Config:
|
||||||
small_group_min=data["classify"]["small_group_min"],
|
small_group_min=data["classify"]["small_group_min"],
|
||||||
digest_top_artists=data["digest"]["top_artists"],
|
digest_top_artists=data["digest"]["top_artists"],
|
||||||
digest_top_albums=data["digest"]["top_albums"],
|
digest_top_albums=data["digest"]["top_albums"],
|
||||||
|
ollama_host=data["ollama"]["host"],
|
||||||
|
ollama_model=data["ollama"]["model"],
|
||||||
|
ollama_prompt_version=data["ollama"]["prompt_version"],
|
||||||
|
ollama_timeout=data["ollama"]["timeout"],
|
||||||
|
ollama_keep_alive=data["ollama"]["keep_alive"],
|
||||||
token_file=ROOT / data["paths"]["token_file"],
|
token_file=ROOT / data["paths"]["token_file"],
|
||||||
cache_dir=ROOT / data["paths"]["cache_dir"],
|
cache_dir=ROOT / data["paths"]["cache_dir"],
|
||||||
out_dir=ROOT / data["paths"]["out_dir"],
|
out_dir=ROOT / data["paths"]["out_dir"],
|
||||||
|
|
|
||||||
46
tests/test_config.py
Normal file
46
tests/test_config.py
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from sort_ym.config import load_config
|
||||||
|
|
||||||
|
MINIMAL_TOML = """
|
||||||
|
[throttle]
|
||||||
|
fetch_batch_delay = 0.4
|
||||||
|
lyrics_request_delay = 0.25
|
||||||
|
apply_request_delay = 0.3
|
||||||
|
request_timeout = 20
|
||||||
|
|
||||||
|
[fetch]
|
||||||
|
batch_size = 100
|
||||||
|
|
||||||
|
[classify]
|
||||||
|
small_group_min = 12
|
||||||
|
|
||||||
|
[digest]
|
||||||
|
top_artists = 40
|
||||||
|
top_albums = 15
|
||||||
|
|
||||||
|
[ollama]
|
||||||
|
host = "http://localhost:11434"
|
||||||
|
model = "qwen3.6-35b-a3b:latest"
|
||||||
|
prompt_version = 1
|
||||||
|
timeout = 600
|
||||||
|
keep_alive = "30m"
|
||||||
|
|
||||||
|
[paths]
|
||||||
|
token_file = ".token"
|
||||||
|
cache_dir = "cache"
|
||||||
|
out_dir = "out"
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_config_reads_ollama_block(tmp_path: Path):
|
||||||
|
path = tmp_path / "config.toml"
|
||||||
|
path.write_text(MINIMAL_TOML, encoding="utf-8")
|
||||||
|
|
||||||
|
cfg = load_config(path)
|
||||||
|
|
||||||
|
assert cfg.ollama_host == "http://localhost:11434"
|
||||||
|
assert cfg.ollama_model == "qwen3.6-35b-a3b:latest"
|
||||||
|
assert cfg.ollama_prompt_version == 1
|
||||||
|
assert cfg.ollama_timeout == 600
|
||||||
|
assert cfg.ollama_keep_alive == "30m"
|
||||||
Loading…
Add table
Reference in a new issue