Skip to content

Commit 2629760

Browse files
committed
Resolve #302: Hardcoded chatdev_prompt_template --> background_prompt parameter in ChatChainConfig.json
1 parent 4cbd741 commit 2629760

File tree

10 files changed

+22
-13
lines changed

10 files changed

+22
-13
lines changed

CompanyConfig/Art/ChatChainConfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,6 @@
116116
"gui_design": "True",
117117
"git_management": "False",
118118
"self_improve": "False",
119-
"incremental_develop": "False"
119+
"incremental_develop": "False",
120+
"background_prompt": "ChatDev is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of 'changing the digital world through programming'."
120121
}

CompanyConfig/Default/ChatChainConfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@
9797
"gui_design": "True",
9898
"git_management": "False",
9999
"self_improve": "False",
100-
"incremental_develop": "False"
100+
"incremental_develop": "False",
101+
"background_prompt": "ChatDev is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of 'changing the digital world through programming'."
101102
}

CompanyConfig/Human/ChatChainConfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,6 @@
110110
"gui_design": "True",
111111
"git_management": "False",
112112
"self_improve": "False",
113-
"incremental_develop": "False"
113+
"incremental_develop": "False",
114+
"background_prompt": "ChatDev is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of 'changing the digital world through programming'."
114115
}

CompanyConfig/Incremental/ChatChainConfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@
9191
"gui_design": "True",
9292
"git_management": "False",
9393
"self_improve": "False",
94-
"incremental_develop": "True"
94+
"incremental_develop": "True",
95+
"background_prompt": "ChatDev is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of 'changing the digital world through programming'."
9596
}

camel/agents/role_playing.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def __init__(
9090
sys_msg_generator_kwargs: Optional[Dict] = None,
9191
extend_sys_msg_meta_dicts: Optional[List[Dict]] = None,
9292
extend_task_specify_meta_dict: Optional[Dict] = None,
93+
background_prompt: Optional[str] = ""
9394
) -> None:
9495
self.with_task_specify = with_task_specify
9596
self.with_task_planner = with_task_planner
@@ -131,9 +132,7 @@ def __init__(
131132

132133
self.task_prompt = task_prompt
133134

134-
chatdev_prompt_template = "ChatDev is a software company powered by multiple intelligent agents, such as chief executive officer, chief human resources officer, chief product officer, chief technology officer, etc, with a multi-agent organizational structure and the mission of \"changing the digital world through programming\"."
135-
136-
sys_msg_meta_dicts = [dict(chatdev_prompt=chatdev_prompt_template, task=task_prompt)] * 2
135+
sys_msg_meta_dicts = [dict(chatdev_prompt=background_prompt, task=task_prompt)] * 2
137136
if (extend_sys_msg_meta_dicts is None and self.task_type in [TaskType.AI_SOCIETY, TaskType.MISALIGNMENT,
138137
TaskType.CHATDEV]):
139138
extend_sys_msg_meta_dicts = [dict(assistant_role=assistant_role_name, user_role=user_role_name)] * 2
@@ -200,7 +199,7 @@ def init_chat(self, phase_type: PhaseType = None,
200199

201200
# here we concatenate to store the real message in the log
202201
log_visualize(self.user_agent.role_name,
203-
"**[Start Chat]**\n\n[" + self.assistant_agent.system_message.content + "]\n\n" + content)
202+
"**[Start Chat]**\n\n[" + self.assistant_agent.system_message.content + "]\n\n" + content)
204203
return None, user_msg
205204

206205
def process_messages(

chatdev/chat_chain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def __init__(self,
6767
self.chat_env_config = ChatEnvConfig(clear_structure=check_bool(self.config["clear_structure"]),
6868
gui_design=check_bool(self.config["gui_design"]),
6969
git_management=check_bool(self.config["git_management"]),
70-
incremental_develop=check_bool(self.config["incremental_develop"]))
70+
incremental_develop=check_bool(self.config["incremental_develop"]),
71+
background_prompt=self.config["background_prompt"])
7172
self.chat_env = ChatEnv(self.chat_env_config)
7273

7374
# the user input prompt will be self-improved (if set "self_improve": "True" in ChatChainConfig.json)

chatdev/chat_env.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ class ChatEnvConfig:
2727
def __init__(self, clear_structure,
2828
gui_design,
2929
git_management,
30-
incremental_develop):
30+
incremental_develop,
31+
background_prompt):
3132
self.clear_structure = clear_structure # Whether to clear non-software files in the WareHouse and cache files in generated software path
3233
self.gui_design = gui_design # Encourage ChatDev generate software with GUI
3334
self.git_management = git_management # Whether to use git to manage the creation and changes of generated software
3435
self.incremental_develop = incremental_develop # Whether to use incremental develop on an existing project
36+
self.background_prompt = background_prompt # background prompt that will be added to every inquiry to LLM
3537

3638
def __str__(self):
3739
string = ""
3840
string += "ChatEnvConfig.clear_structure: {}\n".format(self.clear_structure)
3941
string += "ChatEnvConfig.git_management: {}\n".format(self.git_management)
4042
string += "ChatEnvConfig.gui_design: {}\n".format(self.gui_design)
4143
string += "ChatEnvConfig.incremental_develop: {}\n".format(self.incremental_develop)
44+
string += "ChatEnvConfig.background_prompt: {}\n".format(self.background_prompt)
4245
return string
4346

4447

chatdev/phase.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def chatting(
6565
"""
6666
6767
Args:
68-
chat_env: global chatchain environment TODO: only for employee detection, can be deleted
68+
chat_env: global chatchain environment
6969
task_prompt: user query prompt for building the software
7070
assistant_role_name: who receives the chat
7171
user_role_name: who starts the chat
@@ -103,6 +103,7 @@ def chatting(
103103
task_type=task_type,
104104
with_task_specify=with_task_specify,
105105
model_type=model_type,
106+
background_prompt=chat_env.config.background_prompt
106107
)
107108

108109
# log_visualize("System", role_play_session.assistant_sys_msg)

chatdev/statistics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_info(dir, log_filepath):
105105
if len(sublines) > 0:
106106
model_type = sublines[0].split("| **model_type** | ModelType.")[-1].split(" | ")[0]
107107
model_type = model_type[:-2]
108-
if model_type == "GPT_3_5_TURBO":
108+
if model_type == "GPT_3_5_TURBO" or model_type == "GPT_3_5_TURBO_NEW":
109109
model_type = "gpt-3.5-turbo"
110110
elif model_type == "GPT_4":
111111
model_type = "gpt-4"
@@ -114,7 +114,7 @@ def get_info(dir, log_filepath):
114114
elif model_type == "GPT_4_TURBO":
115115
model_type = "gpt-4-1106-preview"
116116
# print("model_type:", model_type)
117-
117+
118118
lines = open(log_filepath, "r", encoding="utf8").read().split("\n")
119119
start_lines = [line for line in lines if "**[Start Chat]**" in line]
120120
chat_lines = [line for line in lines if "<->" in line]

wiki.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ then go to [Visualizer Website](http://127.0.0.1:8000/) to see an online visuali
277277
- *incremental_develop*: Whether to use incremental develop on an existing project.
278278
- *self_improve*: flag for self-improvement on user input prompt. It is a special chatting that LLM plays as a prompt engineer to improve the user input prompt. **⚠️ Attention** Model generated prompts contains uncertainty and there may
279279
be a deviation from the requirement meaning contained in the original prompt.
280+
- *background_prompt*: background prompt that will be added to every inquiry to LLM
280281
- params in SimplePhase:
281282
- *max_turn_step*: Max number of chatting turn. You can increase max_turn_step for better performance but it will
282283
take longer time to finish the phase.

0 commit comments

Comments
 (0)