INNER CODE UNIT · Python
load_config
cognitivetech/ollama-ebook-summary · sum.py:26
def load_config(config_path: Path) -> dict:
"""Load configuration from a YAML file."""
try:
with config_path.open('r', encoding='utf-8') as file:
return yaml.safe_load(file)
except FileNotFoundError:
print(f"Configuration file {config_path} not found.")
sys.exit(1)
except yaml.YAMLError as e:
print(f"Error parsing the configuration file: {e}")
sys.exit(1)
except PermissionError:
print(f"Permission denied when accessing {config_path}")
sys.exit(1)
def get_prompt(self, alias: str) -> str:
"""Retrieve prompt by alias from the configuration."""
prompt = self.prompts.get(alias, {}).get('prompt')