(
cls,
task_description: str,
node_name: str,
node_description: str,
next_nodes: List[str],
node_roles_description: Dict[str, str],
)
| 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 |
| 91 | + " If all the rules above are met, the task is complete, please consider to transit to the next node. Otherwise, the task is not complete, stay at the current node." |
| 92 | ) |
| 93 | transit_extract_word = "node" |
| 94 | transit_last_prompt = TRANSIT_LAST_PROMPT_TEMPLATE.format( |
| 95 | next_nodes=next_nodes, extract_word=transit_extract_word |
| 96 | ) |
| 97 | |
| 98 | llm_config = { |
| 99 | "LLM_type": "OpenAI", |
| 100 | "model": "gpt-4-turbo-2024-04-09", |
| 101 | "temperature": 0.3, |
| 102 | "log_path": "logs/generate_config/node/controller/route", |
| 103 | "ACTIVE_MODE": True, |
| 104 | } |
| 105 | llm = OpenAILLM(LLMConfig(llm_config)) |
| 106 | system_prompt = "You are a helpful assistant designed to output JSON." |
| 107 | last_prompt = ROUTE_CONTROLLER_CONFIG_GENERATION_PROMPT_TEMPLATE.format( |
| 108 | task_description=task_description, |
| 109 | node_description=node_description, |
| 110 | node_roles_description=node_roles_description, |
| 111 | ) |
| 112 | |
| 113 | response, content = llm.get_response( |
nothing calls this directly
no test coverage detected