MCPcopy Create free account
hub / github.com/aiwaves-cn/agents / ControllerConfig

Class ControllerConfig

src/agents/task/node.py:33–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 required_fields = ["node_name", "node_description", "begin_role", "controller"]
32
33 class ControllerConfig(Config):
34
35 required_fields = []
36
37 def __init__(self, config_path_or_dict: Union[str, dict] = None) -> None:
38 super().__init__(config_path_or_dict)
39 self._validate_config()
40
41 self.max_chat_nums = self.config_dict.get("max_chat_nums", 10)
42
43 self.transit_type = self.config_dict.get("transit_type", "llm")
44 self.transit_system_prompt = self.config_dict.get("transit_system_prompt")
45 self.transit_last_prompt = self.config_dict.get("transit_last_prompt")
46 self.transit_extract_word = self.config_dict.get(
47 "transit_extract_word", "node"
48 )
49
50 self.route_type = self.config_dict.get("route_type", "order")
51 self.route_system_prompt = self.config_dict.get("route_system_prompt")
52 self.route_last_prompt = self.config_dict.get("route_last_prompt")
53 self.route_extract_word = self.config_dict.get("route_extract_word", "role")
54
55 @classmethod
56 def generate_config(
57 cls,
58 task_description: str,
59 node_name: str,
60 node_description: str,
61 next_nodes: List[str],
62 node_roles_description: Dict[str, str],
63 ):
64 max_chat_nums = 10
65
66 llm_config = {
67 "LLM_type": "OpenAI",
68 "model": "gpt-4-turbo-2024-04-09",
69 "temperature": 0.3,
70 "log_path": "logs/generate_config/node/controller/transit",
71 "ACTIVE_MODE": True,
72 "SAVE_LOGS": True,
73 }
74 llm = OpenAILLM(LLMConfig(llm_config))
75 system_prompt = "You are a helpful assistant."
76 last_prompt = TRANSIT_CONTROLLER_CONFIG_GENERATION_PROMPT_TEMPLATE.format(
77 task_description=task_description,
78 node_description=node_description,
79 node_roles_description=node_roles_description,
80 )
81
82 response, content = llm.get_response(
83 chat_messages=None,
84 system_prompt=system_prompt,
85 last_prompt=last_prompt,
86 )
87
88 transit_type = "llm"
89 transit_system_prompt = (
90 content

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected