Files
PyVtT/src/pyvtt/configuration.py
Max P. 58b9cb586c feat(libs): integrate Ollama and Whisper clients with config models
- Add `AppConfig` and `PresetConfig` models using Pydantic for config validation
- Refactor `read_configurations` to return an `AppConfig` instance
- Implement `OllamaClient` for chat-based server interaction
- Implement `WhisperClient` for transcription via Whisper CLI
- Migrate notification utilities to `libs` directory
- Update tray application to use new clients and config structure
- Simplify Whisper and Ollama integration logic in `WhisperWorker`

Signed-off-by: Max P. <Mail@MPassarello.de>
2025-05-05 12:00:33 +02:00

27 lines
842 B
Python

import json
import os
from pathlib import Path
from pyvtt.models.config import AppConfig
DEFAULT_CONFIG_PATH = Path.home() / ".pyvtt.json"
def read_configurations() -> AppConfig:
"""
Reads the configuration settings from a JSON file named 'pyvtt.settings.json'
located in the same directory as the script.
Returns:
dict: The configuration settings loaded from the JSON file.
Raises:
Exception: If there is an error reading or parsing the JSON file,
an exception is raised with the error details.
"""
try:
with open(DEFAULT_CONFIG_PATH) as f:
raw_config = json.load(f)
return AppConfig(**raw_config)
except Exception as e:
print(f"Error reading configurations: {e}")
raise Exception(f"Error reading configurations: {e}")