Files
NexQuant/rdagent/core/prompts.py
T
Linlang 571b5304cb fix mypy error (#91)
* fix mypy error

* fix mypy error

* fix ruff error

* change command

* delete python 3.8&3.9 from CI

* change command

* Some modifications according to the comments

* Add literal type

* Update .github/workflows/ci.yml

* Some modifications according to the comments

* fix ruff error

* fix meta dict

* Fix type

* Some modifications according to the comments

* merge latest code

* Some modifications according to the comments

* Some modifications according to the comments

* fix ci error

* fix ruff error

* Update Makefile

* Update Makefile

---------

Co-authored-by: Ubuntu <debug@debug.qjtqi00gqezu1eqs55bqdrf51f.px.internal.cloudapp.net>
Co-authored-by: Young <afe.young@gmail.com>
Co-authored-by: you-n-g <you-n-g@users.noreply.github.com>
2024-07-25 15:20:04 +08:00

21 lines
598 B
Python

from pathlib import Path # noqa: I001
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:
super().__init__()
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