(
llm_config,
jupyter_executor,
sys_prompt,
repo_dir
)
| 70 | return navigator |
| 71 | |
| 72 | def load_agent_editor( |
| 73 | llm_config, |
| 74 | jupyter_executor, |
| 75 | sys_prompt, |
| 76 | repo_dir |
| 77 | ): |
| 78 | terminate_condition = lambda x: x.get("content", "").find("Final Answer:") > 0 or "_run" not in x.get("content", "") |
| 79 | def response_preparer(self, messages): |
| 80 | plain_messages = [message["content"] for message in messages] |
| 81 | query = plain_messages[0].split("Query: ")[-1].strip() |
| 82 | # analysis = summarizer(f"Summarize the analysis for following {query} in the codebase. Analysis: {' '.join(plain_messages[1:-1])}") |
| 83 | analysis = f"Here is the current edit patch: {extract_patch(repo_dir)}" |
| 84 | analysis += plain_messages[-1].replace("Final Answer:", "") |
| 85 | return analysis |
| 86 | |
| 87 | editor_assistant = AssistantAgent( |
| 88 | "Inner-Editor-Assistant", |
| 89 | system_message=sys_prompt, |
| 90 | llm_config={"config_list": llm_config}, |
| 91 | human_input_mode="NEVER", |
| 92 | ) |
| 93 | |
| 94 | editor_interpreter = UserProxyAgent( |
| 95 | name="Editor Interpreter", |
| 96 | is_termination_msg=terminate_condition, |
| 97 | llm_config=False, |
| 98 | code_execution_config={ |
| 99 | "executor": jupyter_executor, |
| 100 | }, |
| 101 | human_input_mode="NEVER", |
| 102 | default_auto_reply="", |
| 103 | ) |
| 104 | |
| 105 | groupchat_edit = GroupChat( |
| 106 | agents=[editor_assistant, editor_interpreter], |
| 107 | messages=[], |
| 108 | speaker_selection_method="round_robin", |
| 109 | allow_repeat_speaker=False, |
| 110 | max_round=15, |
| 111 | ) |
| 112 | |
| 113 | manager_edit = GroupChatManager( |
| 114 | groupchat=groupchat_edit, |
| 115 | name="Editor Manager", |
| 116 | llm_config={"config_list": llm_config}, |
| 117 | max_consecutive_auto_reply=0 |
| 118 | ) |
| 119 | |
| 120 | editor = SocietyOfMindAgent( |
| 121 | "Editor", |
| 122 | chat_manager=manager_edit, |
| 123 | llm_config={"config_list": llm_config}, |
| 124 | response_preparer=response_preparer |
| 125 | ) |
| 126 | |
| 127 | editor.register_hook( |
| 128 | "process_last_received_message", |
| 129 | lambda content: react_prompt_message(content), |
no test coverage detected