Skip to content

Commit

Permalink
change online_log -> visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkwee committed Dec 18, 2023
1 parent 69ef21f commit 6ff2e8f
Show file tree
Hide file tree
Showing 65 changed files with 178 additions and 3,853 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN pip install --no-cache-dir -r requirements.txt
# (you'll need to provide the actual key when running the container)
ENV OPENAI_API_KEY=your_OpenAI_API_key

# Expose the port for online_log/app.py
# Expose the port for visualizer/app.py
EXPOSE 8000

# Set an entry point that runs a shell for interactive mode
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
【English | <a href="readme/README-Chinese.md">Chinese</a> | <a href="readme/README-Japanese.md">Japanese</a> | <a href="readme/README-Korean.md">Korean</a> | <a href="readme/README-Filipino.md">Filipino</a> | <a href="readme/README-French.md">French</a> | <a href="readme/README-Slovak.md">Slovak</a> | <a href="readme/README-Portuguese.md">Portuguese</a> | <a href="readme/README-Spanish.md">Spanish</a> | <a href="readme/README-Dutch.md">Dutch</a> | <a href="readme/README-Hindi.md">Hindi</a> | <a href="readme/README-Bahasa-Indonesia.md">Bahasa Indonesia</a>】
</p>
<p align="center">
【📚 <a href="wiki.md">Wiki</a> | 🚀 <a href="wiki.md#local-demo">Local Demo</a> | 👥 <a href="Contribution.md">Community Built Software</a> | 🔧 <a href="wiki.md#customization">Customization</a> | 👾 <a href="https://discord.gg/bn4t2Jy6TT")>Discord</a>】
【📚 <a href="wiki.md">Wiki</a> | 🚀 <a href="wiki.md#visualizer">Visualizer</a> | 👥 <a href="Contribution.md">Community Built Software</a> | 🔧 <a href="wiki.md#customization">Customization</a> | 👾 <a href="https://discord.gg/bn4t2Jy6TT")>Discord</a>】

</p>

## 📖 Overview

- **ChatDev** stands as a **virtual software company** that operates through various **intelligent agents** holding
different roles, including Chief Executive Officer <img src='online_log/static/figures/ceo.png' height=20>, Chief Product Officer <img src='online_log/static/figures/cpo.png' height=20>, Chief Technology Officer <img src='online_log/static/figures/cto.png' height=20>, programmer <img src='online_log/static/figures/programmer.png' height=20>, reviewer <img src='online_log/static/figures/reviewer.png' height=20>, tester <img src='online_log/static/figures/tester.png' height=20>, art designer <img src='online_log/static/figures/designer.png' height=20>. These
different roles, including Chief Executive Officer <img src='visualizer/static/figures/ceo.png' height=20>, Chief Product Officer <img src='visualizer/static/figures/cpo.png' height=20>, Chief Technology Officer <img src='visualizer/static/figures/cto.png' height=20>, programmer <img src='visualizer/static/figures/programmer.png' height=20>, reviewer <img src='visualizer/static/figures/reviewer.png' height=20>, tester <img src='visualizer/static/figures/tester.png' height=20>, art designer <img src='visualizer/static/figures/designer.png' height=20>. These
agents form a multi-agent organizational structure and are united by a mission to "revolutionize the digital world
through programming." The agents within ChatDev **collaborate** by participating in specialized functional seminars,
including tasks such as designing, coding, testing, and documenting.
Expand All @@ -40,16 +40,16 @@
<p align="center">
<img src='./misc/docker.png' width=400>
</p>
- September 25, 2023: The **Git** mode is now available, enabling the programmer <img src='online_log/static/figures/programmer.png' height=20> to utilize Git for version control. To enable this feature, simply set ``"git_management"`` to ``"True"`` in ``ChatChainConfig.json``. See [guide](wiki.md#git-mode).
- September 25, 2023: The **Git** mode is now available, enabling the programmer <img src='visualizer/static/figures/programmer.png' height=20> to utilize Git for version control. To enable this feature, simply set ``"git_management"`` to ``"True"`` in ``ChatChainConfig.json``. See [guide](wiki.md#git-mode).
<p align="center">
<img src='./misc/github.png' width=600>
</p>
- September 20, 2023: The **Human-Agent-Interaction** mode is now available! You can get involved with the ChatDev team by playing the role of reviewer <img src='online_log/static/figures/reviewer.png' height=20> and making suggestions to the programmer <img src='online_log/static/figures/programmer.png' height=20>;
- September 20, 2023: The **Human-Agent-Interaction** mode is now available! You can get involved with the ChatDev team by playing the role of reviewer <img src='visualizer/static/figures/reviewer.png' height=20> and making suggestions to the programmer <img src='visualizer/static/figures/programmer.png' height=20>;
try ``python3 run.py --task [description_of_your_idea] --config "Human"``. See [guide](wiki.md#human-agent-interaction) and [example](WareHouse/Gomoku_HumanAgentInteraction_20230920135038).
<p align="center">
<img src='./misc/Human_intro.png' width=600>
</p>
- September 1, 2023: The **Art** mode is available now! You can activate the designer agent <img src='online_log/static/figures/designer.png' height=20> to generate images used in the software;
- September 1, 2023: The **Art** mode is available now! You can activate the designer agent <img src='visualizer/static/figures/designer.png' height=20> to generate images used in the software;
try ``python3 run.py --task [description_of_your_idea] --config "Art"``. See [guide](wiki.md#art) and [example](WareHouse/gomokugameArtExample_THUNLP_20230831122822).
- August 28, 2023: The system is publicly available.
- August 17, 2023: The v1.0.0 version was ready for release.
Expand Down Expand Up @@ -152,8 +152,7 @@ To get started, follow these steps:
For more detailed information, please refer to our [Wiki](wiki.md), where you can find:

- An introduction to all command run parameters.
- A straightforward guide for setting up a local web demo, which includes enhanced visualized logs, a replay demo, and a
simple ChatChain Visualizer.
- A straightforward guide for setting up a local web visualizer demo, which can visualize real-time logs, replayed logs, and ChatChain.
- An overview of the ChatDev framework.
- A comprehensive introduction to all advanced parameters in ChatChain configuration.
- Guides for customizing ChatDev, including:
Expand Down
4 changes: 2 additions & 2 deletions camel/agents/role_playing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from camel.messages import ChatMessage, UserChatMessage
from camel.messages import SystemMessage
from camel.typing import ModelType, RoleType, TaskType, PhaseType
from chatdev.utils import log_arguments, log_and_print_online
from chatdev.utils import log_arguments, log_visualize


@log_arguments
Expand Down Expand Up @@ -199,7 +199,7 @@ def init_chat(self, phase_type: PhaseType = None,
self.user_agent.update_messages(pseudo_msg)

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

Expand Down
24 changes: 12 additions & 12 deletions chatdev/chat_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from camel.typing import TaskType, ModelType
from chatdev.chat_env import ChatEnv, ChatEnvConfig
from chatdev.statistics import get_info
from chatdev.utils import log_and_print_online, now
from chatdev.utils import log_visualize, now


def check_bool(s):
Expand Down Expand Up @@ -234,7 +234,7 @@ def pre_processing(self):
preprocess_msg += "**Log File**: {}\n\n".format(self.log_filepath)
preprocess_msg += "**ChatDevConfig**:\n{}\n\n".format(self.chat_env.config.__str__())
preprocess_msg += "**ChatGPTConfig**:\n{}\n\n".format(chat_gpt_config)
log_and_print_online(preprocess_msg)
log_visualize(preprocess_msg)

# init task prompt
if check_bool(self.config['self_improve']):
Expand All @@ -254,14 +254,14 @@ def post_processing(self):
root = os.path.dirname(filepath)

if self.chat_env_config.git_management:
git_online_log = "**[Git Information]**\n\n"
log_git_info = "**[Git Information]**\n\n"

self.chat_env.codes.version += 1
os.system("cd {}; git add .".format(self.chat_env.env_dict["directory"]))
git_online_log += "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))
git_online_log += "cd {}; git commit -m \"v{} Final Version\"\n".format(self.chat_env.env_dict["directory"], self.chat_env.codes.version)
log_and_print_online(git_online_log)
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)

git_info = "**[Git Log]**\n\n"
import subprocess
Expand All @@ -276,7 +276,7 @@ def post_processing(self):
log_output = "Error when executing " + command

git_info += log_output
log_and_print_online(git_info)
log_visualize(git_info)

post_info = "**[Post Info]**\n\n"
now_time = now()
Expand All @@ -300,7 +300,7 @@ def post_processing(self):
shutil.rmtree(file_path, ignore_errors=True)
post_info += "{} Removed.".format(file_path) + "\n\n"

log_and_print_online(post_info)
log_visualize(post_info)

logging.shutdown()
time.sleep(1)
Expand Down Expand Up @@ -339,14 +339,14 @@ def self_task_improve(self, task_prompt):
model_type=self.model_type,
)

# log_and_print_online("System", role_play_session.assistant_sys_msg)
# log_and_print_online("System", role_play_session.user_sys_msg)
# log_visualize("System", role_play_session.assistant_sys_msg)
# log_visualize("System", role_play_session.user_sys_msg)

_, input_user_msg = role_play_session.init_chat(None, None, self_task_improve_prompt)
assistant_response, user_response = role_play_session.step(input_user_msg, True)
revised_task_prompt = assistant_response.msg.content.split("<INFO>")[-1].lower().strip()
log_and_print_online(role_play_session.assistant_agent.role_name, assistant_response.msg.content)
log_and_print_online(
log_visualize(role_play_session.assistant_agent.role_name, assistant_response.msg.content)
log_visualize(
"**[Task Prompt Self Improvement]**\n**Original Task Prompt**: {}\n**Improved Task Prompt**: {}".format(
task_prompt, revised_task_prompt))
return revised_task_prompt
4 changes: 2 additions & 2 deletions chatdev/chat_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from chatdev.codes import Codes
from chatdev.documents import Documents
from chatdev.roster import Roster
from chatdev.utils import log_and_print_online
from chatdev.utils import log_visualize


class ChatEnvConfig:
Expand Down Expand Up @@ -60,7 +60,7 @@ def fix_module_not_found_error(test_reports):
for match in re.finditer(r"No module named '(\S+)'", test_reports, re.DOTALL):
module = match.group(1)
subprocess.Popen("pip install {}".format(module), shell=True).wait()
log_and_print_online("**[CMD Execute]**\n\n[CMD] pip install {}".format(module))
log_visualize("**[CMD Execute]**\n\n[CMD] pip install {}".format(module))

def set_directory(self, directory):
assert len(self.env_dict['directory']) == 0
Expand Down
20 changes: 10 additions & 10 deletions chatdev/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import subprocess

from chatdev.utils import log_and_print_online
from chatdev.utils import log_visualize


class Codes:
Expand Down Expand Up @@ -70,7 +70,7 @@ def _update_codes(self, generated_content):
'''\n""" + unified_diff + "\n```"

log_and_print_online(update_codes_content)
log_visualize(update_codes_content)
self.codebooks[key] = new_codes.codebooks[key]

def _rewrite_codes(self, git_management, phase_info=None) -> None:
Expand All @@ -91,12 +91,12 @@ def _rewrite_codes(self, git_management, phase_info=None) -> None:
if git_management:
if not phase_info:
phase_info = ""
git_online_log = "**[Git Information]**\n\n"
log_git_info = "**[Git Information]**\n\n"
if self.version == 1.0:
os.system("cd {}; git init".format(self.directory))
git_online_log += "cd {}; git init\n".format(self.directory)
log_git_info += "cd {}; git init\n".format(self.directory)
os.system("cd {}; git add .".format(self.directory))
git_online_log += "cd {}; git add .\n".format(self.directory)
log_git_info += "cd {}; git add .\n".format(self.directory)

# check if there exist diff
completed_process = subprocess.run("cd {}; git status".format(self.directory), shell=True, text=True,
Expand All @@ -106,18 +106,18 @@ def _rewrite_codes(self, git_management, phase_info=None) -> None:
return

os.system("cd {}; git commit -m \"v{}\"".format(self.directory, str(self.version) + " " + phase_info))
git_online_log += "cd {}; git commit -m \"v{}\"\n".format(self.directory,
log_git_info += "cd {}; git commit -m \"v{}\"\n".format(self.directory,
str(self.version) + " " + phase_info)
if self.version == 1.0:
os.system("cd {}; git submodule add ./{} {}".format(os.path.dirname(os.path.dirname(self.directory)),
"WareHouse/" + os.path.basename(self.directory),
"WareHouse/" + os.path.basename(self.directory)))
git_online_log += "cd {}; git submodule add ./{} {}\n".format(
log_git_info += "cd {}; git submodule add ./{} {}\n".format(
os.path.dirname(os.path.dirname(self.directory)),
"WareHouse/" + os.path.basename(self.directory),
"WareHouse/" + os.path.basename(self.directory))
log_and_print_online(rewrite_codes_content)
log_and_print_online(git_online_log)
log_visualize(rewrite_codes_content)
log_visualize(log_git_info)

def _get_codes(self) -> str:
content = ""
Expand All @@ -134,4 +134,4 @@ def _load_from_hardware(self, directory) -> None:
if filename.endswith(".py"):
code = open(os.path.join(directory, filename), "r", encoding="utf-8").read()
self.codebooks[filename] = self._format_code(code)
log_and_print_online("{} files read from {}".format(len(self.codebooks.keys()), directory))
log_visualize("{} files read from {}".format(len(self.codebooks.keys()), directory))
6 changes: 3 additions & 3 deletions chatdev/composed_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from camel.typing import ModelType
from chatdev.chat_env import ChatEnv
from chatdev.utils import log_and_print_online
from chatdev.utils import log_visualize


def check_bool(s):
Expand Down Expand Up @@ -142,7 +142,7 @@ def execute(self, chat_env) -> ChatEnv:
max_turn_step = phase_item['max_turn_step']
need_reflect = check_bool(phase_item['need_reflect'])
self.phase_env["cycle_index"] = cycle_index
log_and_print_online(
log_visualize(
f"**[Execute Detail]**\n\nexecute SimplePhase:[{phase}] in ComposedPhase:[{self.phase_name}], cycle {cycle_index}")
if phase in self.phases:
self.phases[phase].phase_env = self.phase_env
Expand Down Expand Up @@ -246,7 +246,7 @@ def update_chat_env(self, chat_env):

def break_cycle(self, phase_env) -> bool:
if not phase_env['exist_bugs_flag']:
log_and_print_online(f"**[Test Info]**\n\nAI User (Software Test Engineer):\nTest Pass!\n")
log_visualize(f"**[Test Info]**\n\nAI User (Software Test Engineer):\nTest Pass!\n")
return True
else:
return False
Loading

0 comments on commit 6ff2e8f

Please sign in to comment.