r"""Generates a system message from a dictionary. Args: meta_dict (Dict[str, str]): The dictionary containing the information to generate the system message. role_tuple (Tuple[str, RoleType], optional): The tuple containing the role na
(
self,
meta_dict: Dict[str, str],
role_tuple: Tuple[str, RoleType] = ("", RoleType.DEFAULT),
)
| 96 | ) |
| 97 | |
| 98 | def from_dict( |
| 99 | self, |
| 100 | meta_dict: Dict[str, str], |
| 101 | role_tuple: Tuple[str, RoleType] = ("", RoleType.DEFAULT), |
| 102 | ) -> BaseMessage: |
| 103 | r"""Generates a system message from a dictionary. |
| 104 | |
| 105 | Args: |
| 106 | meta_dict (Dict[str, str]): The dictionary containing the |
| 107 | information to generate the system message. |
| 108 | role_tuple (Tuple[str, RoleType], optional): The tuple containing |
| 109 | the role name and role type. (default: ("", RoleType.DEFAULT)) |
| 110 | |
| 111 | Returns: |
| 112 | BaseMessage: The generated system message. |
| 113 | """ |
| 114 | self.validate_meta_dict_keys(meta_dict) |
| 115 | role_name, role_type = role_tuple |
| 116 | sys_prompt = self.sys_prompts[role_type] |
| 117 | sys_prompt = sys_prompt.format(**meta_dict) |
| 118 | return BaseMessage( |
| 119 | role_name=role_name, |
| 120 | role_type=role_type, |
| 121 | meta_dict=meta_dict, |
| 122 | content=sys_prompt, |
| 123 | ) |
| 124 | |
| 125 | def from_dicts( |
| 126 | self, |
no test coverage detected