Files
NexQuant/rdagent/core/prompts.py
T
XianBW 55959c93ff Ci fix (#22)
* fix replace function of CI tool

* fix ruff errors (ignore some parts)

* add ruff rule ignore comment
2024-06-12 15:12:11 +08:00

19 lines
556 B
Python

from pathlib import Path
from typing import Dict
import yaml
from rdagent.core.utils import SingletonBaseClass
class Prompts(SingletonBaseClass, Dict[str, str]):
def __init__(self, file_path: Path) -> None:
with file_path.open(encoding="utf8") as file:
prompt_yaml_dict = yaml.safe_load(file)
if prompt_yaml_dict is None:
error_message = f"Failed to load prompts from {file_path}"
raise ValueError(error_message)
for key, value in prompt_yaml_dict.items():
self[key] = value