Files
NexQuant/rdagent/core/prompts.py
T
Linlang 276b462f40 Fix ruff error1 (#81)
* fix_ruff_error1

* fix_ruff_error

* fix ruff error

* fix ruff error

* pass model.py

* rename exception class

* rename exception class

* rename func name generate_feedback

* remove prepare args

* optimize code

* optimize code

* fix code error
2024-07-18 22:36:04 +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