mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-29 21:28:07 +00:00
Resolve #283: fix directory not found problem when clear_structure=False
This commit is contained in:
parent
452df57cca
commit
d1ffafcb64
@ -186,10 +186,11 @@ class ChatChain:
|
|||||||
Returns: None
|
Returns: None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
filepath = os.path.dirname(__file__)
|
||||||
|
root = os.path.dirname(filepath)
|
||||||
|
directory = os.path.join(root, "WareHouse")
|
||||||
|
|
||||||
if self.chat_env.config.clear_structure:
|
if self.chat_env.config.clear_structure:
|
||||||
filepath = os.path.dirname(__file__)
|
|
||||||
root = os.path.dirname(filepath)
|
|
||||||
directory = os.path.join(root, "WareHouse")
|
|
||||||
for filename in os.listdir(directory):
|
for filename in os.listdir(directory):
|
||||||
file_path = os.path.join(directory, filename)
|
file_path = os.path.join(directory, filename)
|
||||||
# logs with error trials are left in WareHouse/
|
# logs with error trials are left in WareHouse/
|
||||||
@ -259,8 +260,10 @@ class ChatChain:
|
|||||||
self.chat_env.codes.version += 1
|
self.chat_env.codes.version += 1
|
||||||
os.system("cd {}; git add .".format(self.chat_env.env_dict["directory"]))
|
os.system("cd {}; git add .".format(self.chat_env.env_dict["directory"]))
|
||||||
log_git_info += "cd {}; git add .\n".format(self.chat_env.env_dict["directory"])
|
log_git_info += "cd {}; git add .\n".format(self.chat_env.env_dict["directory"])
|
||||||
os.system("cd {}; git commit -m \"v{} Final Version\"".format(self.chat_env.env_dict["directory"], self.chat_env.codes.version))
|
os.system("cd {}; git commit -m \"v{} Final Version\"".format(self.chat_env.env_dict["directory"],
|
||||||
log_git_info += "cd {}; git commit -m \"v{} Final Version\"\n".format(self.chat_env.env_dict["directory"], self.chat_env.codes.version)
|
self.chat_env.codes.version))
|
||||||
|
log_git_info += "cd {}; git commit -m \"v{} Final Version\"\n".format(self.chat_env.env_dict["directory"],
|
||||||
|
self.chat_env.codes.version)
|
||||||
log_visualize(log_git_info)
|
log_visualize(log_git_info)
|
||||||
|
|
||||||
git_info = "**[Git Log]**\n\n"
|
git_info = "**[Git Log]**\n\n"
|
||||||
@ -292,8 +295,8 @@ class ChatChain:
|
|||||||
post_info += "ChatDev Starts ({})".format(self.start_time) + "\n\n"
|
post_info += "ChatDev Starts ({})".format(self.start_time) + "\n\n"
|
||||||
post_info += "ChatDev Ends ({})".format(now_time) + "\n\n"
|
post_info += "ChatDev Ends ({})".format(now_time) + "\n\n"
|
||||||
|
|
||||||
|
directory = self.chat_env.env_dict['directory']
|
||||||
if self.chat_env.config.clear_structure:
|
if self.chat_env.config.clear_structure:
|
||||||
directory = self.chat_env.env_dict['directory']
|
|
||||||
for filename in os.listdir(directory):
|
for filename in os.listdir(directory):
|
||||||
file_path = os.path.join(directory, filename)
|
file_path = os.path.join(directory, filename)
|
||||||
if os.path.isdir(file_path) and file_path.endswith("__pycache__"):
|
if os.path.isdir(file_path) and file_path.endswith("__pycache__"):
|
||||||
|
|||||||
@ -28,10 +28,10 @@ class ChatEnvConfig:
|
|||||||
gui_design,
|
gui_design,
|
||||||
git_management,
|
git_management,
|
||||||
incremental_develop):
|
incremental_develop):
|
||||||
self.clear_structure = clear_structure
|
self.clear_structure = clear_structure # Whether to clear non-software files in the WareHouse and cache files in generated software path
|
||||||
self.gui_design = gui_design
|
self.gui_design = gui_design # Encourage ChatDev generate software with GUI
|
||||||
self.git_management = git_management
|
self.git_management = git_management # Whether to use git to manage the creation and changes of generated software
|
||||||
self.incremental_develop = incremental_develop
|
self.incremental_develop = incremental_develop # Whether to use incremental develop on an existing project
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = ""
|
string = ""
|
||||||
@ -81,13 +81,12 @@ class ChatEnv:
|
|||||||
new_directory = "{}.{}".format(directory, time.strftime("%Y%m%d%H%M%S", time.localtime()))
|
new_directory = "{}.{}".format(directory, time.strftime("%Y%m%d%H%M%S", time.localtime()))
|
||||||
shutil.copytree(directory, new_directory)
|
shutil.copytree(directory, new_directory)
|
||||||
print("{} Copied to {}".format(directory, new_directory))
|
print("{} Copied to {}".format(directory, new_directory))
|
||||||
if self.config.clear_structure:
|
if os.path.exists(self.env_dict['directory']):
|
||||||
if os.path.exists(self.env_dict['directory']):
|
shutil.rmtree(self.env_dict['directory'])
|
||||||
shutil.rmtree(self.env_dict['directory'])
|
os.mkdir(self.env_dict['directory'])
|
||||||
os.mkdir(self.env_dict['directory'])
|
print("{} Created".format(directory))
|
||||||
print("{} Created".format(directory))
|
else:
|
||||||
else:
|
os.mkdir(self.env_dict['directory'])
|
||||||
os.mkdir(self.env_dict['directory'])
|
|
||||||
|
|
||||||
def exist_bugs(self) -> tuple[bool, str]:
|
def exist_bugs(self) -> tuple[bool, str]:
|
||||||
directory = self.env_dict['directory']
|
directory = self.env_dict['directory']
|
||||||
@ -274,7 +273,7 @@ class ChatEnv:
|
|||||||
if desc.endswith(".png"):
|
if desc.endswith(".png"):
|
||||||
desc = desc.replace(".png", "")
|
desc = desc.replace(".png", "")
|
||||||
print("{}: {}".format(filename, desc))
|
print("{}: {}".format(filename, desc))
|
||||||
|
|
||||||
if openai_new_api:
|
if openai_new_api:
|
||||||
response = openai.images.generate(
|
response = openai.images.generate(
|
||||||
prompt=desc,
|
prompt=desc,
|
||||||
|
|||||||
10
wiki.md
10
wiki.md
@ -271,12 +271,12 @@ then go to [Visualizer Website](http://127.0.0.1:8000/) to see an online visuali
|
|||||||
|
|
||||||
## ChatChain Parameters
|
## ChatChain Parameters
|
||||||
|
|
||||||
- *clear_structure*: clean cache folders.
|
- *clear_structure*: Whether to clear non-software files in the WareHouse and cache files in generated software path.
|
||||||
- *brainstorming*: TBD
|
- *brainstorming*: TBD
|
||||||
- *gui_design*: whether create gui for software.
|
- *gui_design*: Encourage ChatDev generate software with GUI.
|
||||||
- *git_management*: open git management on software project or not.
|
- *git_management*: Whether to use git to manage the creation and changes of generated software.
|
||||||
- *self_improve*: flag for self-improvement on user input prompt. It is a special chatting that LLM plays as a prompt
|
- *incremental_develop*: Whether to use incremental develop on an existing project.
|
||||||
engineer to improve the user input prompt. **⚠️ Attention** Model generated prompts contains uncertainty and there may
|
- *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
|
||||||
be a deviation from the requirement meaning contained in the original prompt.
|
be a deviation from the requirement meaning contained in the original prompt.
|
||||||
- params in SimplePhase:
|
- params in SimplePhase:
|
||||||
- *max_turn_step*: Max number of chatting turn. You can increase max_turn_step for better performance but it will
|
- *max_turn_step*: Max number of chatting turn. You can increase max_turn_step for better performance but it will
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user