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

Method __init__

camel/generators.py:34–83  ·  view source on GitHub ↗
(
        self,
        task_type: TaskType = TaskType.AI_SOCIETY,
        sys_prompts: Optional[Dict[RoleType, str]] = None,
        sys_msg_meta_dict_keys: Optional[Set[str]] = None,
    )

Source from the content-addressed store, hash-verified

32 """
33
34 def __init__(
35 self,
36 task_type: TaskType = TaskType.AI_SOCIETY,
37 sys_prompts: Optional[Dict[RoleType, str]] = None,
38 sys_msg_meta_dict_keys: Optional[Set[str]] = None,
39 ) -> None:
40 self.sys_prompts: Dict[RoleType, str]
41
42 if sys_prompts is not None:
43 self.sys_prompts = sys_prompts
44 self.sys_msg_meta_dict_keys = sys_msg_meta_dict_keys or set()
45 else:
46 assistant_prompt_template = (
47 PromptTemplateGenerator().get_system_prompt(
48 task_type,
49 RoleType.ASSISTANT,
50 )
51 )
52 user_prompt_template = PromptTemplateGenerator().get_system_prompt(
53 task_type,
54 RoleType.USER,
55 )
56 critic_prompt_template = (
57 PromptTemplateGenerator().get_system_prompt(
58 task_type,
59 RoleType.CRITIC,
60 )
61 )
62 embodiment_prompt_template = (
63 PromptTemplateGenerator().get_system_prompt(
64 task_type,
65 RoleType.EMBODIMENT,
66 )
67 )
68
69 self.sys_prompts = dict()
70 self.sys_prompts[RoleType.ASSISTANT] = assistant_prompt_template
71 self.sys_prompts[RoleType.USER] = user_prompt_template
72 self.sys_prompts[RoleType.CRITIC] = critic_prompt_template
73 self.sys_prompts[RoleType.EMBODIMENT] = embodiment_prompt_template
74
75 self.sys_msg_meta_dict_keys = (
76 assistant_prompt_template.key_words
77 | user_prompt_template.key_words
78 | critic_prompt_template.key_words
79 | embodiment_prompt_template.key_words
80 )
81
82 if RoleType.DEFAULT not in self.sys_prompts:
83 self.sys_prompts[RoleType.DEFAULT] = "You are a helpful assistant."
84
85 def validate_meta_dict_keys(self, meta_dict: Dict[str, str]) -> None:
86 r"""Validates the keys of the meta_dict.

Callers

nothing calls this directly

Calls 2

get_system_promptMethod · 0.45

Tested by

no test coverage detected