MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / from_dicts

Method from_dicts

camel/generators.py:125–153  ·  view source on GitHub ↗

r"""Generates a list of system messages from a list of dictionaries. Args: meta_dicts (List[Dict[str, str]]): A list of dictionaries containing the information to generate the system messages. role_tuples (List[Tuple[str, RoleType]]): A list of tuples

(
        self,
        meta_dicts: List[Dict[str, str]],
        role_tuples: List[Tuple[str, RoleType]],
    )

Source from the content-addressed store, hash-verified

123 )
124
125 def from_dicts(
126 self,
127 meta_dicts: List[Dict[str, str]],
128 role_tuples: List[Tuple[str, RoleType]],
129 ) -> List[BaseMessage]:
130 r"""Generates a list of system messages from a list of dictionaries.
131
132 Args:
133 meta_dicts (List[Dict[str, str]]): A list of dictionaries
134 containing the information to generate the system messages.
135 role_tuples (List[Tuple[str, RoleType]]): A list of tuples
136 containing the role name and role type for each system message.
137
138 Returns:
139 List[BaseMessage]: A list of generated system messages.
140
141 Raises:
142 ValueError: If the number of meta_dicts and role_tuples are
143 different.
144 """
145 if len(meta_dicts) != len(role_tuples):
146 raise ValueError(
147 "The number of meta_dicts and role_types should be the same."
148 )
149
150 return [
151 self.from_dict(meta_dict, role_tuple)
152 for meta_dict, role_tuple in zip(meta_dicts, role_tuples)
153 ]
154
155
156class RoleNameGenerator:

Callers 2

__init__Method · 0.95
_get_sys_message_infoMethod · 0.45

Calls 1

from_dictMethod · 0.95

Tested by

no test coverage detected