0920Update, add Human-Agent-Interaction mode

This commit is contained in:
thinkwee 2023-09-20 15:22:30 +08:00
parent 5078d9697b
commit 535921ebae
29 changed files with 5953 additions and 94 deletions

View File

@ -175,30 +175,6 @@
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format." "As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
] ]
}, },
"CodeReviewHuman": {
"assistant_role_name": "Programmer",
"user_role_name": "Code Reviewer",
"phase_prompt": [
"According to the new user's task, our designed product modality and three creative ideas, our developed first-edition source codes are listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Comments on Codes:",
"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the fixed codes strictly following the required format."
]
},
"TestErrorSummary": { "TestErrorSummary": {
"assistant_role_name": "Programmer", "assistant_role_name": "Programmer",
"user_role_name": "Software Test Engineer", "user_role_name": "Software Test Engineer",

View File

@ -0,0 +1,114 @@
{
"chain": [
{
"phase": "DemandAnalysis",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "True"
},
{
"phase": "LanguageChoose",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "True"
},
{
"phase": "Coding",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeCompleteAll",
"phaseType": "ComposedPhase",
"cycleNum": 10,
"Composition": [
{
"phase": "CodeComplete",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "CodeReview",
"phaseType": "ComposedPhase",
"cycleNum": 3,
"Composition": [
{
"phase": "CodeReviewComment",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeReviewModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "HumanAgentInteraction",
"phaseType": "ComposedPhase",
"cycleNum": 5,
"Composition": [
{
"phase": "CodeReviewHuman",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "Test",
"phaseType": "ComposedPhase",
"cycleNum": 3,
"Composition": [
{
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "TestModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "EnvironmentDoc",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "True"
},
{
"phase": "Manual",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
],
"recruitments": [
"Chief Executive Officer",
"Counselor",
"Chief Human Resource Officer",
"Chief Product Officer",
"Chief Technology Officer",
"Programmer",
"Code Reviewer",
"Software Test Engineer",
"Chief Creative Officer"
],
"clear_structure": "True",
"brainstorming": "False",
"gui_design": "True",
"git_management": "False",
"self_improve": "False"
}

View File

@ -0,0 +1,301 @@
{
"DemandAnalysis": {
"assistant_role_name": "Chief Product Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"ChatDev has made products in the following form before:",
"Image: can present information in line chart, bar chart, flow chart, cloud chart, Gantt chart, etc.",
"Document: can present information via .docx files.",
"PowerPoint: can present information via .pptx files.",
"Excel: can present information via .xlsx files.",
"PDF: can present information via .pdf files.",
"Website: can present personal resume, tutorial, products, or ideas, via .html files.",
"Application: can implement visualized game, software, tool, etc, via python.",
"Dashboard: can display a panel visualizing real-time information.",
"Mind Map: can represent ideas, with related concepts arranged around a core concept.",
"As the {assistant_role}, to satisfy the new user's demand and the product should be realizable, you should keep discussing with me to decide which product modality do we want the product to be?",
"Note that we must ONLY discuss the product modality and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion by replying with only one line, which starts with a single word <INFO>, followed by our final product modality without any other words, e.g., \"<INFO> PowerPoint\"."
]
},
"LanguageChoose": {
"assistant_role_name": "Chief Technology Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"According to the new user's task and some creative brainstorm ideas listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Ideas: \"{ideas}\".",
"We have decided to complete the task through a executable software implemented via a programming language. ",
"As the {assistant_role}, to satisfy the new user's demand and make the software realizable, you should propose a concrete programming language. If python can complete this task via Python, please answer Python; otherwise, answer another programming language (e.g., Java, C++, etc,).",
"Note that we must ONLY discuss the target programming language and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion and conclude the best programming language we have discussed without any other words or reasons, return only one line using the format: \"<INFO> *\" where \"*\" represents a programming language."
]
},
"Coding": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"According to the new user's task and our software designs listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas:\"{ideas}\"",
"We have decided to complete the task through a executable software with multiple files implemented via {language}. As the {assistant_role}, to satisfy the new user's demands, you should write one or multiple files and make sure that every detail of the architecture is, in the end, implemented as code. {gui}",
"Think step by step and reason yourself to the right decisions to make sure we get it right.",
"You will first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose.",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"You will start with the \"main\" file, then go to the ones that are imported by that file, and so on.",
"Please note that the code should be fully functional. Ensure to implement all functions. No placeholders (such as 'pass' in Python)."
]
},
"ArtDesign": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Creative Officer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Task: \"{task}\".",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), we will discuss and design many decorative images for GUI decoration. Now, we keep discussing the GUI beautification by listing some functionally independent elements in GUI that are being considered to be decorated by different pictures. For example, ten digits (0-9) in a calculator are functionally independent.",
"To answer, use the format: \" FILENAME.png: DESCRIPTION\" where \"FILENAME\" is the filename of the image and \"DESCRIPTION\" denotes the detailed description of the independent elements. For example:",
"'''",
"button_1.png: The button with the number \"1\" on it.",
"button_multiply.png: The button with the multiplication symbol (\"*\") on it.",
"background.png: the background color to decorate the Go game",
"'''",
"Now, list all functionally independent elements as much as possible."
]
},
"ArtIntegration": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Creative Officer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Task: \"{task}\".",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), you will incorporate our designed images for GUI decoration. Here are some ready-made high-quality pictures and corresponding descriptions:",
"{images}",
"Note that the designed images have a fixed size of 256x256 pixels and the images are located in the same directory as all the Python files; please dynamically scaling these images according to the size of GUI, and use \"self.*\" to avoid displaying-related problems caused by automatic garbage collection. For example:",
"```",
"self.image = ImageTk.PhotoImage(Image.open(\"./image.png\").resize((50, 50)))",
"```",
"Now, use some or all of the pictures into the GUI to make it more beautiful and creative. Output codes strictly following the required format mentioned above."
]
},
"CodeComplete": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"According to the new user's task and our software designs listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Codes:",
"\"{codes}\"",
"Unimplemented File:",
"\"{unimplemented_file}\"",
"In our software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the complete function of our developed software, you have to implement all methods in the {unimplemented_file} file which contains a unimplemented class. Now, implement all methods of the {unimplemented_file} and all other codes needed, then output the fully implemented codes, strictly following the required format."
]
},
"CodeReviewComment": {
"assistant_role_name": "Code Reviewer",
"user_role_name": "Programmer",
"phase_prompt": [
"According to the new user's task and our software designs: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes:",
"\"{codes}\"",
"As the {assistant_role}, to make the software directly operable without further coding, ChatDev have formulated the following regulations:",
"1) all referenced classes should be imported;",
"2) all methods should be implemented;",
"3) all methods need to have the necessary comments;",
"4) no potential bugs;",
"5) The entire project conforms to the tasks proposed by the user;",
"6) most importantly, do not only check the errors in the code, but also the logic of code. Make sure that user can interact with generated software without losing any feature in the requirement;",
"Now, you should check the above regulations one by one and review the codes in detail, propose one comment with the highest priority about the codes, and give me instructions on how to fix. Tell me your comment with the highest priority and corresponding suggestions on revision. If the codes are perfect and you have no comment on them, return only one line like \"<INFO> Finished\"."
]
},
"CodeReviewModification": {
"assistant_role_name": "Programmer",
"user_role_name": "Code Reviewer",
"phase_prompt": [
"According to the new user's task, our designed product modality, languages and ideas, our developed first-edition source codes are listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Comments on Codes:",
"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
]
},
"CodeReviewHuman": {
"assistant_role_name": "Programmer",
"user_role_name": "Code Reviewer",
"phase_prompt": [
"According to the new user's task, our designed product modality and three creative ideas, our developed first-edition source codes are listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Comments on Codes:",
"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
]
},
"TestErrorSummary": {
"assistant_role_name": "Programmer",
"user_role_name": "Software Test Engineer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Test Reports of Source Codes:",
"\"{test_reports}\"",
"According to my test reports, please locate and summarize the bugs that cause the problem."
]
},
"TestModification": {
"assistant_role_name": "Programmer",
"user_role_name": "Software Test Engineer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Test Reports of Source Codes:",
"\"{test_reports}\"",
"Error Summary of Test Reports:",
"\"{error_summary}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software execute smoothly and robustly, you should modify the codes based on the error summary. Now, use the format exemplified above and modify the problematic codes based on the error summary. Output the codes that you fixed based on the test reported and corresponding explanations (strictly follow the format defined above, including FILENAME, LANGUAGE, DOCSTRING and CODE; incomplete \"TODO\" codes are strictly prohibited). If no bugs are reported, please return only one line like \"<INFO> Finished\"."
]
},
"EnvironmentDoc": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"The new user's task and our developed codes are listed: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"As the {assistant_role}, you should write a requirements.txt file, which is commonly used in Python projects to specify the dependencies or packages required for the project to run properly. It serves as a way to document and manage the project's dependencies in a standardized format. For example:",
"requirements.txt",
"```",
"numpy==1.19.2",
"pandas>=1.1.4",
"```",
"According to the codes and file format listed above, write a requirements.txt file to specify the dependencies or packages required for the project to run properly."
]
},
"Manual": {
"assistant_role_name": "Chief Product Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"The new user's task, our developed codes and required dependencies are listed: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Requirements:",
"\"{requirements}\"",
"As the {assistant_role}, by using Markdown, you should write a manual.md file which is a detailed user manual to use the software, including introducing main functions of the software, how to install environment dependencies and how to use/play it. For example:",
"manual.md",
"```",
"# LangChain",
"Building applications with LLMs through composability",
"Looking for the JS/TS version? Check out LangChain.js.",
"**Production Support:** As you move your LangChains into production, we'd love to offer more comprehensive support.",
"Please fill out this form and we'll set up a dedicated support Slack channel.",
"## Quick Install",
"`pip install langchain`",
"or",
"`conda install langchain -c conda-forge`",
"## 🤔 What is this?",
"Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications that they previously could not. However, using these LLMs in isolation is often insufficient for creating a truly powerful app - the real power comes when you can combine them with other sources of computation or knowledge.",
"This library aims to assist in the development of those types of applications. Common examples of these applications include:",
"**❓ Question Answering over specific documents**",
"- Documentation",
"- End-to-end Example: Question Answering over Notion Database",
"**🤖 Agents**",
"- Documentation",
"- End-to-end Example: GPT+WolframAlpha",
"## 📖 Documentation",
"Please see [here](https://python.langchain.com) for full documentation on:",
"- Getting started (installation, setting up the environment, simple examples)",
"- How-To examples (demos, integrations, helper functions)",
"- Reference (full API docs)",
"- Resources (high-level explanation of core concepts)",
"```"
]
}
}

View File

@ -7,11 +7,15 @@
<p align="center"> <p align="center">
【English | <a href="README-Chinese.md">Chinese</a> | <a href="README-Japanese.md">Japanese</a> | <a href="README-Korean.md">Korean</a> 【English | <a href="README-Chinese.md">Chinese</a> | <a href="README-Japanese.md">Japanese</a> | <a href="README-Korean.md">Korean</a>
</p> </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>
</p>
## 📖 Overview ## 📖 Overview
- **ChatDev** stands as a **virtual software company** that operates through various **intelligent agents** holding - **ChatDev** stands as a **virtual software company** that operates through various **intelligent agents** holding
different roles, including Chief Executive Officer, Chief Technology Officer, Programmer, Tester, and more. These 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
agents form a multi-agent organizational structure and are united by a mission to "revolutionize the digital world 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, through programming." The agents within ChatDev **collaborate** by participating in specialized functional seminars,
including tasks such as designing, coding, testing, and documenting. including tasks such as designing, coding, testing, and documenting.
@ -20,14 +24,17 @@
## 📰 News ## 📰 News
* **September 1, 2023: The Art mode is available now! You can use agent to generate images used in the software, * **September 20th, 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>;
try ``python3 run.py --config "Art"``.** See [example](WareHouse/gomokugameArtExample_THUNLP_20230831122822) here. try ``python3 run.py --task [description_of_your_idea] --config "Human"``.** See [guide](wiki.md#human-agent-interaction) and [example](WareHouse/Gomoku_HumanAgentInteraction_20230920135038).
* August 28, 2023: The system is publicly available. <img src='misc/Human_intro.png' width=800>
* August 17, 2023: The V1.0.0 version was ready for release. * September 1st, 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;
* July 30, 2023: Users can customize ChatChain, Phase, and Role settings. Additionally, both online Log mode and replay try ``python3 run.py --task [description_of_your_idea] --config "Art"``. See [guide](wiki.md#art) and [example](WareHouse/gomokugameArtExample_THUNLP_20230831122822).
* August 28th, 2023: The system is publicly available.
* August 17th, 2023: The V1.0.0 version was ready for release.
* July 30th, 2023: Users can customize ChatChain, Phase, and Role settings. Additionally, both online Log mode and replay
mode are now supported. mode are now supported.
* July 16, 2023: The [preprint paper](https://arxiv.org/abs/2307.07924) associated with this project was published. * July 16th, 2023: The [preprint paper](https://arxiv.org/abs/2307.07924) associated with this project was published.
* June 30, 2023: The initial version of the `ChatDev` repository was released. * June 30th, 2023: The initial version of the `ChatDev` repository was released.
## ❓ What Can ChatDev Do? ## ❓ What Can ChatDev Do?

View File

@ -0,0 +1,114 @@
{
"chain": [
{
"phase": "DemandAnalysis",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "True"
},
{
"phase": "LanguageChoose",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "True"
},
{
"phase": "Coding",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeCompleteAll",
"phaseType": "ComposedPhase",
"cycleNum": 10,
"Composition": [
{
"phase": "CodeComplete",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "CodeReview",
"phaseType": "ComposedPhase",
"cycleNum": 3,
"Composition": [
{
"phase": "CodeReviewComment",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeReviewModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "HumanAgentInteraction",
"phaseType": "ComposedPhase",
"cycleNum": 5,
"Composition": [
{
"phase": "CodeReviewHuman",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "Test",
"phaseType": "ComposedPhase",
"cycleNum": 3,
"Composition": [
{
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "TestModification",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "EnvironmentDoc",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "True"
},
{
"phase": "Manual",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
],
"recruitments": [
"Chief Executive Officer",
"Counselor",
"Chief Human Resource Officer",
"Chief Product Officer",
"Chief Technology Officer",
"Programmer",
"Code Reviewer",
"Software Test Engineer",
"Chief Creative Officer"
],
"clear_structure": "True",
"brainstorming": "False",
"gui_design": "True",
"git_management": "False",
"self_improve": "False"
}

View File

@ -0,0 +1 @@
Develop a basic Gomoku game.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,301 @@
{
"DemandAnalysis": {
"assistant_role_name": "Chief Product Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"ChatDev has made products in the following form before:",
"Image: can present information in line chart, bar chart, flow chart, cloud chart, Gantt chart, etc.",
"Document: can present information via .docx files.",
"PowerPoint: can present information via .pptx files.",
"Excel: can present information via .xlsx files.",
"PDF: can present information via .pdf files.",
"Website: can present personal resume, tutorial, products, or ideas, via .html files.",
"Application: can implement visualized game, software, tool, etc, via python.",
"Dashboard: can display a panel visualizing real-time information.",
"Mind Map: can represent ideas, with related concepts arranged around a core concept.",
"As the {assistant_role}, to satisfy the new user's demand and the product should be realizable, you should keep discussing with me to decide which product modality do we want the product to be?",
"Note that we must ONLY discuss the product modality and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion by replying with only one line, which starts with a single word <INFO>, followed by our final product modality without any other words, e.g., \"<INFO> PowerPoint\"."
]
},
"LanguageChoose": {
"assistant_role_name": "Chief Technology Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"According to the new user's task and some creative brainstorm ideas listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Ideas: \"{ideas}\".",
"We have decided to complete the task through a executable software implemented via a programming language. ",
"As the {assistant_role}, to satisfy the new user's demand and make the software realizable, you should propose a concrete programming language. If python can complete this task via Python, please answer Python; otherwise, answer another programming language (e.g., Java, C++, etc,).",
"Note that we must ONLY discuss the target programming language and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion and conclude the best programming language we have discussed without any other words or reasons, return only one line using the format: \"<INFO> *\" where \"*\" represents a programming language."
]
},
"Coding": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"According to the new user's task and our software designs listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas:\"{ideas}\"",
"We have decided to complete the task through a executable software with multiple files implemented via {language}. As the {assistant_role}, to satisfy the new user's demands, you should write one or multiple files and make sure that every detail of the architecture is, in the end, implemented as code. {gui}",
"Think step by step and reason yourself to the right decisions to make sure we get it right.",
"You will first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose.",
"Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"You will start with the \"main\" file, then go to the ones that are imported by that file, and so on.",
"Please note that the code should be fully functional. Ensure to implement all functions. No placeholders (such as 'pass' in Python)."
]
},
"ArtDesign": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Creative Officer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Task: \"{task}\".",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), we will discuss and design many decorative images for GUI decoration. Now, we keep discussing the GUI beautification by listing some functionally independent elements in GUI that are being considered to be decorated by different pictures. For example, ten digits (0-9) in a calculator are functionally independent.",
"To answer, use the format: \" FILENAME.png: DESCRIPTION\" where \"FILENAME\" is the filename of the image and \"DESCRIPTION\" denotes the detailed description of the independent elements. For example:",
"'''",
"button_1.png: The button with the number \"1\" on it.",
"button_multiply.png: The button with the multiplication symbol (\"*\") on it.",
"background.png: the background color to decorate the Go game",
"'''",
"Now, list all functionally independent elements as much as possible."
]
},
"ArtIntegration": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Creative Officer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Task: \"{task}\".",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), you will incorporate our designed images for GUI decoration. Here are some ready-made high-quality pictures and corresponding descriptions:",
"{images}",
"Note that the designed images have a fixed size of 256x256 pixels and the images are located in the same directory as all the Python files; please dynamically scaling these images according to the size of GUI, and use \"self.*\" to avoid displaying-related problems caused by automatic garbage collection. For example:",
"```",
"self.image = ImageTk.PhotoImage(Image.open(\"./image.png\").resize((50, 50)))",
"```",
"Now, use some or all of the pictures into the GUI to make it more beautiful and creative. Output codes strictly following the required format mentioned above."
]
},
"CodeComplete": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"According to the new user's task and our software designs listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Codes:",
"\"{codes}\"",
"Unimplemented File:",
"\"{unimplemented_file}\"",
"In our software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the complete function of our developed software, you have to implement all methods in the {unimplemented_file} file which contains a unimplemented class. Now, implement all methods of the {unimplemented_file} and all other codes needed, then output the fully implemented codes, strictly following the required format."
]
},
"CodeReviewComment": {
"assistant_role_name": "Code Reviewer",
"user_role_name": "Programmer",
"phase_prompt": [
"According to the new user's task and our software designs: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes:",
"\"{codes}\"",
"As the {assistant_role}, to make the software directly operable without further coding, ChatDev have formulated the following regulations:",
"1) all referenced classes should be imported;",
"2) all methods should be implemented;",
"3) all methods need to have the necessary comments;",
"4) no potential bugs;",
"5) The entire project conforms to the tasks proposed by the user;",
"6) most importantly, do not only check the errors in the code, but also the logic of code. Make sure that user can interact with generated software without losing any feature in the requirement;",
"Now, you should check the above regulations one by one and review the codes in detail, propose one comment with the highest priority about the codes, and give me instructions on how to fix. Tell me your comment with the highest priority and corresponding suggestions on revision. If the codes are perfect and you have no comment on them, return only one line like \"<INFO> Finished\"."
]
},
"CodeReviewModification": {
"assistant_role_name": "Programmer",
"user_role_name": "Code Reviewer",
"phase_prompt": [
"According to the new user's task, our designed product modality, languages and ideas, our developed first-edition source codes are listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Comments on Codes:",
"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
]
},
"CodeReviewHuman": {
"assistant_role_name": "Programmer",
"user_role_name": "Code Reviewer",
"phase_prompt": [
"According to the new user's task, our designed product modality and three creative ideas, our developed first-edition source codes are listed below: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Comments on Codes:",
"\"{comments}\"",
"In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
]
},
"TestErrorSummary": {
"assistant_role_name": "Programmer",
"user_role_name": "Software Test Engineer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Test Reports of Source Codes:",
"\"{test_reports}\"",
"According to my test reports, please locate and summarize the bugs that cause the problem."
]
},
"TestModification": {
"assistant_role_name": "Programmer",
"user_role_name": "Software Test Engineer",
"phase_prompt": [
"Our developed source codes and corresponding test reports are listed below: ",
"Programming Language: \"{language}\"",
"Source Codes:",
"\"{codes}\"",
"Test Reports of Source Codes:",
"\"{test_reports}\"",
"Error Summary of Test Reports:",
"\"{error_summary}\"",
"Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
"FILENAME",
"```LANGUAGE",
"'''",
"DOCSTRING",
"'''",
"CODE",
"```",
"As the {assistant_role}, to satisfy the new user's demand and make the software execute smoothly and robustly, you should modify the codes based on the error summary. Now, use the format exemplified above and modify the problematic codes based on the error summary. Output the codes that you fixed based on the test reported and corresponding explanations (strictly follow the format defined above, including FILENAME, LANGUAGE, DOCSTRING and CODE; incomplete \"TODO\" codes are strictly prohibited). If no bugs are reported, please return only one line like \"<INFO> Finished\"."
]
},
"EnvironmentDoc": {
"assistant_role_name": "Programmer",
"user_role_name": "Chief Technology Officer",
"phase_prompt": [
"The new user's task and our developed codes are listed: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"As the {assistant_role}, you should write a requirements.txt file, which is commonly used in Python projects to specify the dependencies or packages required for the project to run properly. It serves as a way to document and manage the project's dependencies in a standardized format. For example:",
"requirements.txt",
"```",
"numpy==1.19.2",
"pandas>=1.1.4",
"```",
"According to the codes and file format listed above, write a requirements.txt file to specify the dependencies or packages required for the project to run properly."
]
},
"Manual": {
"assistant_role_name": "Chief Product Officer",
"user_role_name": "Chief Executive Officer",
"phase_prompt": [
"The new user's task, our developed codes and required dependencies are listed: ",
"Task: \"{task}\".",
"Modality: \"{modality}\".",
"Programming Language: \"{language}\"",
"Ideas: \"{ideas}\"",
"Codes: ",
"\"{codes}\"",
"Requirements:",
"\"{requirements}\"",
"As the {assistant_role}, by using Markdown, you should write a manual.md file which is a detailed user manual to use the software, including introducing main functions of the software, how to install environment dependencies and how to use/play it. For example:",
"manual.md",
"```",
"# LangChain",
"Building applications with LLMs through composability",
"Looking for the JS/TS version? Check out LangChain.js.",
"**Production Support:** As you move your LangChains into production, we'd love to offer more comprehensive support.",
"Please fill out this form and we'll set up a dedicated support Slack channel.",
"## Quick Install",
"`pip install langchain`",
"or",
"`conda install langchain -c conda-forge`",
"## 🤔 What is this?",
"Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications that they previously could not. However, using these LLMs in isolation is often insufficient for creating a truly powerful app - the real power comes when you can combine them with other sources of computation or knowledge.",
"This library aims to assist in the development of those types of applications. Common examples of these applications include:",
"**❓ Question Answering over specific documents**",
"- Documentation",
"- End-to-end Example: Question Answering over Notion Database",
"**🤖 Agents**",
"- Documentation",
"- End-to-end Example: GPT+WolframAlpha",
"## 📖 Documentation",
"Please see [here](https://python.langchain.com) for full documentation on:",
"- Getting started (installation, setting up the environment, simple examples)",
"- How-To examples (demos, integrations, helper functions)",
"- Reference (full API docs)",
"- Resources (high-level explanation of core concepts)",
"```"
]
}
}

View File

@ -0,0 +1,65 @@
{
"Chief Executive Officer": [
"{chatdev_prompt}",
"You are Chief Executive Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.",
"Here is a new customer's task: {task}.",
"To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
],
"Chief Product Officer": [
"{chatdev_prompt}",
"You are Chief Product Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are responsible for all product-related matters in ChatDev. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Counselor": [
"{chatdev_prompt}",
"You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ",
"Here is a new customer's task: {task}.",
"To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
],
"Chief Technology Officer": [
"{chatdev_prompt}",
"You are Chief Technology Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.",
"Here is a new customer's task: {task}.",
"To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Chief Human Resource Officer": [
"{chatdev_prompt}",
"You are Chief Human Resource Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Programmer": [
"{chatdev_prompt}",
"You are Programmer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Code Reviewer": [
"{chatdev_prompt}",
"You are Code Reviewer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can help programmers to assess source codes for software troubleshooting, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Software Test Engineer": [
"{chatdev_prompt}",
"You are Software Test Engineer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Chief Creative Officer": [
"{chatdev_prompt}",
"You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
]
}

View File

@ -0,0 +1,38 @@
'''
This file contains the Game class which manages the game logic.
'''
class Game:
def __init__(self):
self.board = [[0] * 15 for _ in range(15)]
self.current_player = 1
def make_move(self, x, y):
if self.board[y][x] == 0:
self.board[y][x] = self.current_player
self.current_player = 3 - self.current_player
return True
return False
def check_winner(self, x, y):
directions = [(1, 0), (0, 1), (1, 1), (1, -1)]
for dx, dy in directions:
count = 1
count += self.count_in_direction(x, y, dx, dy)
count += self.count_in_direction(x, y, -dx, -dy)
if count >= 5:
return True
return False
def count_in_direction(self, x, y, dx, dy):
count = 0
player = self.board[y][x]
while True:
x += dx
y += dy
if not (0 <= x < 15 and 0 <= y < 15):
break
if self.board[y][x] == player:
count += 1
else:
break
return count
def reset(self):
self.board = [[0] * 15 for _ in range(15)]
self.current_player = 1

View File

@ -0,0 +1,63 @@
'''
This is the main file of the Gomoku game.
'''
import tkinter as tk
from tkinter import messagebox
from game import Game
class GomokuApp:
def __init__(self, master):
self.master = master
self.master.title("Gomoku")
self.game = Game()
self.canvas = tk.Canvas(self.master, width=500, height=500, bg="white")
self.canvas.pack()
self.canvas.bind("<Button-1>", self.on_click)
self.draw_board()
self.restart_button = tk.Button(self.master, text="Restart", command=self.restart)
self.restart_button.pack()
self.status_bar = tk.Label(self.master, text="Black's Turn", bd=1, relief=tk.SUNKEN, anchor=tk.W)
self.status_bar.pack(side=tk.BOTTOM, fill=tk.X)
def draw_board(self):
self.canvas.delete("all")
cell_width = 500 / 15
cell_height = 500 / 15
for row in range(15):
self.canvas.create_line(0, row * cell_height, 500, row * cell_height)
for col in range(15):
self.canvas.create_line(col * cell_width, 0, col * cell_width, 500)
def on_click(self, event):
cell_width = 500 / 15
cell_height = 500 / 15
x = int(event.x // cell_width)
y = int(event.y // cell_height)
if self.game.make_move(x, y):
self.draw_piece(x, y)
self.update_status_bar()
if self.game.check_winner(x, y):
self.show_winner()
def draw_piece(self, x, y):
cell_width = 500 / 15
cell_height = 500 / 15
oval_coords = (x * cell_width, y * cell_height, (x + 1) * cell_width, (y + 1) * cell_height)
color = "black" if self.game.current_player == 1 else "white"
self.canvas.create_oval(*oval_coords, fill=color)
def show_winner(self):
winner = "Black" if self.game.current_player == 1 else "White"
messagebox.showinfo("Game Over", f"{winner} wins!")
self.canvas.unbind("<Button-1>")
self.restart_button.pack_forget()
self.canvas.bind("<Button-1>", self.restart)
def restart(self):
self.game.reset()
self.draw_board()
self.canvas.unbind("<Button-1>")
self.canvas.bind("<Button-1>", self.on_click)
self.restart_button.pack()
self.update_status_bar()
def update_status_bar(self):
player = "Black" if self.game.current_player == 1 else "White"
self.status_bar.config(text=f"{player}'s Turn")
if __name__ == "__main__":
root = tk.Tk()
app = GomokuApp(root)
root.mainloop()

View File

@ -0,0 +1,45 @@
# Gomoku Game User Manual
Welcome to the Gomoku game! This user manual will guide you on how to install the game and play it.
## Table of Contents
1. [Installation](#installation)
2. [Game Rules](#game-rules)
3. [Playing the Game](#playing-the-game)
4. [Restarting the Game](#restarting-the-game)
5. [Winning the Game](#winning-the-game)
## 1. Installation <a name="installation"></a>
To install and run the Gomoku game, please follow the steps below:
1. Make sure you have Python installed on your computer. You can download Python from the official website: [https://www.python.org/downloads/](https://www.python.org/downloads/)
2. Open a terminal or command prompt.
3. Navigate to the directory where you have saved the `main.py` and `game.py` files.
4. Install the required dependencies by running the following command:
```
pip install -r requirements.txt
```
5. Once the dependencies are installed, you can start the game by running the following command:
```
python main.py
```
## 2. Game Rules <a name="game-rules"></a>
Gomoku is a two-player board game played on a 15x15 grid. The objective of the game is to be the first player to get five of their pieces in a row, either horizontally, vertically, or diagonally.
## 3. Playing the Game <a name="playing-the-game"></a>
Once you start the game, you will see a 15x15 grid on the screen. Each cell represents a position on the board where you can place your piece.
To make a move, simply click on an empty cell on the board. The game will alternate between the black player and the white player.
## 4. Restarting the Game <a name="restarting-the-game"></a>
If you want to restart the game, click the "Restart" button at the bottom of the screen. This will reset the board and allow you to start a new game.
## 5. Winning the Game <a name="winning-the-game"></a>
The game will automatically detect when a player has won. If a player gets five of their pieces in a row, a message box will appear announcing the winner (either black or white). After the game is over, you can click the "Restart" button to start a new game.
Enjoy playing Gomoku!

View File

@ -0,0 +1,29 @@
Task:
Develop a basic Gomoku game.
Config:
ChatEnvConfig.clear_structure: True
ChatEnvConfig.brainstorming: False
Roster:
Chief Executive Officer, Counselor, Chief Human Resource Officer, Chief Product Officer, Chief Technology Officer, Programmer, Code Reviewer, Software Test Engineer, Chief Creative Officer
Modality:
application
Ideas:
Language:
Python
Code_Version:
7.0
Proposed_images:
0
Incorporated_images:
0

View File

@ -0,0 +1 @@
tkinter==8.6

View File

@ -42,6 +42,7 @@ class ComposedPhase(ABC):
self.config_role = config_role self.config_role = config_role
self.phase_env = dict() self.phase_env = dict()
self.phase_env["cycle_num"] = cycle_num
# init chat turn # init chat turn
self.chat_turn_limit_default = 10 self.chat_turn_limit_default = 10
@ -140,6 +141,7 @@ class ComposedPhase(ABC):
phase = phase_item['phase'] phase = phase_item['phase']
max_turn_step = phase_item['max_turn_step'] max_turn_step = phase_item['max_turn_step']
need_reflect = check_bool(phase_item['need_reflect']) need_reflect = check_bool(phase_item['need_reflect'])
self.phase_env["cycle_index"] = cycle_index
log_and_print_online( log_and_print_online(
f"**[Execute Detail]**\n\nexecute SimplePhase:[{phase}] in ComposedPhase:[{self.phase_name}], cycle {cycle_index}") f"**[Execute Detail]**\n\nexecute SimplePhase:[{phase}] in ComposedPhase:[{self.phase_name}], cycle {cycle_index}")
if phase in self.phases: if phase in self.phases:
@ -182,11 +184,11 @@ class CodeCompleteAll(ComposedPhase):
pyfiles = [filename for filename in os.listdir(chat_env.env_dict['directory']) if filename.endswith(".py")] pyfiles = [filename for filename in os.listdir(chat_env.env_dict['directory']) if filename.endswith(".py")]
num_tried = defaultdict(int) num_tried = defaultdict(int)
num_tried.update({filename: 0 for filename in pyfiles}) num_tried.update({filename: 0 for filename in pyfiles})
self.phase_env = { self.phase_env.update({
"max_num_implement": 5, "max_num_implement": 5,
"pyfiles": pyfiles, "pyfiles": pyfiles,
"num_tried": num_tried "num_tried": num_tried
} })
def update_chat_env(self, chat_env): def update_chat_env(self, chat_env):
return chat_env return chat_env
@ -203,7 +205,7 @@ class CodeReview(ComposedPhase):
super().__init__(**kwargs) super().__init__(**kwargs)
def update_phase_env(self, chat_env): def update_phase_env(self, chat_env):
self.phase_env = {"modification_conclusion": ""} self.phase_env.update({"modification_conclusion": ""})
def update_chat_env(self, chat_env): def update_chat_env(self, chat_env):
return chat_env return chat_env
@ -215,12 +217,29 @@ class CodeReview(ComposedPhase):
return False return False
class HumanAgentInteraction(ComposedPhase):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def update_phase_env(self, chat_env):
self.phase_env.update({"modification_conclusion": "", "comments": ""})
def update_chat_env(self, chat_env):
return chat_env
def break_cycle(self, phase_env) -> bool:
if "<INFO> Finished".lower() in phase_env['modification_conclusion'].lower() or phase_env["comments"].lower() == "end":
return True
else:
return False
class Test(ComposedPhase): class Test(ComposedPhase):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
def update_phase_env(self, chat_env): def update_phase_env(self, chat_env):
self.phase_env = dict() pass
def update_chat_env(self, chat_env): def update_chat_env(self, chat_env):
return chat_env return chat_env

View File

@ -357,7 +357,8 @@ class Coding(Phase):
if len(chat_env.codes.codebooks.keys()) == 0: if len(chat_env.codes.codebooks.keys()) == 0:
raise ValueError("No Valid Codes.") raise ValueError("No Valid Codes.")
chat_env.rewrite_codes() chat_env.rewrite_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env
@ -372,7 +373,8 @@ class ArtDesign(Phase):
def update_chat_env(self, chat_env) -> ChatEnv: def update_chat_env(self, chat_env) -> ChatEnv:
chat_env.proposed_images = chat_env.get_proposed_images_from_message(self.seminar_conclusion) chat_env.proposed_images = chat_env.get_proposed_images_from_message(self.seminar_conclusion)
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env
@ -392,7 +394,8 @@ class ArtIntegration(Phase):
chat_env.update_codes(self.seminar_conclusion) chat_env.update_codes(self.seminar_conclusion)
chat_env.rewrite_codes() chat_env.rewrite_codes()
# chat_env.generate_images_from_codes() # chat_env.generate_images_from_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env
@ -422,7 +425,8 @@ class CodeComplete(Phase):
if len(chat_env.codes.codebooks.keys()) == 0: if len(chat_env.codes.codebooks.keys()) == 0:
raise ValueError("No Valid Codes.") raise ValueError("No Valid Codes.")
chat_env.rewrite_codes() chat_env.rewrite_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env
@ -460,7 +464,8 @@ class CodeReviewModification(Phase):
if "```".lower() in self.seminar_conclusion.lower(): if "```".lower() in self.seminar_conclusion.lower():
chat_env.update_codes(self.seminar_conclusion) chat_env.update_codes(self.seminar_conclusion)
chat_env.rewrite_codes() chat_env.rewrite_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
self.phase_env['modification_conclusion'] = self.seminar_conclusion self.phase_env['modification_conclusion'] = self.seminar_conclusion
return chat_env return chat_env
@ -470,21 +475,52 @@ class CodeReviewHuman(Phase):
super().__init__(**kwargs) super().__init__(**kwargs)
def update_phase_env(self, chat_env): def update_phase_env(self, chat_env):
print(
f"You can participate in the development of the software {chat_env.env_dict['task_prompt']}. Please input your feedback. (\"End\" to quit the involvement.)")
provided_comments = input()
self.phase_env.update({"task": chat_env.env_dict['task_prompt'], self.phase_env.update({"task": chat_env.env_dict['task_prompt'],
"modality": chat_env.env_dict['modality'], "modality": chat_env.env_dict['modality'],
"ideas": chat_env.env_dict['ideas'], "ideas": chat_env.env_dict['ideas'],
"language": chat_env.env_dict['language'], "language": chat_env.env_dict['language'],
"codes": chat_env.get_codes(), "codes": chat_env.get_codes()})
"comments": provided_comments})
def update_chat_env(self, chat_env) -> ChatEnv: def update_chat_env(self, chat_env) -> ChatEnv:
if "```".lower() in self.seminar_conclusion.lower(): if "```".lower() in self.seminar_conclusion.lower():
chat_env.update_codes(self.seminar_conclusion) chat_env.update_codes(self.seminar_conclusion)
chat_env.rewrite_codes() chat_env.rewrite_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env
def execute(self, chat_env, chat_turn_limit, need_reflect) -> ChatEnv:
self.update_phase_env(chat_env)
log_and_print_online(
f"**[Human-Agent-Interaction]**\n\n"
f"Now you can participate in the development of the software!\n"
f"The task is: {chat_env.env_dict['task_prompt']}\n"
f"Please input your feedback (in one line). It can be bug report or new feature requirement.\n"
f"You are currently in the #{self.phase_env['cycle_index'] + 1} human feedback with a total of {self.phase_env['cycle_num']} feedbacks\n"
f"Press [Enter] to submit.\n"
f"You can type \"End\" to quit this mode at any time.\n"
)
provided_comments = input(">>> ")
self.phase_env["comments"] = provided_comments
log_and_print_online(
f"**[User Provided Comments]**\n\n In the #{self.phase_env['cycle_index'] + 1} of total {self.phase_env['cycle_num']} comments: \n\n" + provided_comments)
if provided_comments.lower() == "end":
return chat_env
self.seminar_conclusion = \
self.chatting(chat_env=chat_env,
task_prompt=chat_env.env_dict['task_prompt'],
need_reflect=need_reflect,
assistant_role_name=self.assistant_role_name,
user_role_name=self.user_role_name,
phase_prompt=self.phase_prompt,
phase_name=self.phase_name,
assistant_role_prompt=self.assistant_role_prompt,
user_role_prompt=self.user_role_prompt,
chat_turn_limit=chat_turn_limit,
placeholders=self.phase_env,
model_type=self.model_type)
chat_env = self.update_chat_env(chat_env)
return chat_env return chat_env
@ -557,7 +593,8 @@ class TestModification(Phase):
if "```".lower() in self.seminar_conclusion.lower(): if "```".lower() in self.seminar_conclusion.lower():
chat_env.update_codes(self.seminar_conclusion) chat_env.update_codes(self.seminar_conclusion)
chat_env.rewrite_codes() chat_env.rewrite_codes()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env
@ -575,7 +612,8 @@ class EnvironmentDoc(Phase):
def update_chat_env(self, chat_env) -> ChatEnv: def update_chat_env(self, chat_env) -> ChatEnv:
chat_env._update_requirements(self.seminar_conclusion) chat_env._update_requirements(self.seminar_conclusion)
chat_env.rewrite_requirements() chat_env.rewrite_requirements()
log_and_print_online("**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'],self.log_filepath))) log_and_print_online(
"**[Software Info]**:\n\n {}".format(get_info(chat_env.env_dict['directory'], self.log_filepath)))
return chat_env return chat_env

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

BIN
misc/Human_command.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
misc/Human_intro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

BIN
misc/Human_v1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
misc/Human_v2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
misc/Human_v3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 144 KiB

View File

@ -1,27 +1,20 @@
import logging import logging
import requests import requests
import os import os
from flask import Flask, send_from_directory, request, jsonify from flask import Flask, send_from_directory, request, jsonify
import argparse
app = Flask(__name__, static_folder='static') app = Flask(__name__, static_folder='static')
app.logger.setLevel(logging.ERROR) app.logger.setLevel(logging.ERROR)
log = logging.getLogger('werkzeug') log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR) log.setLevel(logging.ERROR)
messages = [] messages = []
port = [8000]
def send_msg(role, text): def send_msg(role, text):
try: try:
data = {"role": role, "text": text} data = {"role": role, "text": text}
response = requests.post("http://127.0.0.1:8000/send_message", json=data) response = requests.post(f"http://127.0.0.1:{port[-1]}/send_message", json=data)
if response.status_code == 200:
print("Message sent successfully!")
else:
print("Failed to send message.")
except: except:
logging.info("flask app.py did not start for online log") logging.info("flask app.py did not start for online log")
@ -35,10 +28,12 @@ def index():
def chain_visualizer(): def chain_visualizer():
return send_from_directory("static", "chain_visualizer.html") return send_from_directory("static", "chain_visualizer.html")
@app.route("/replay") @app.route("/replay")
def replay(): def replay():
return send_from_directory("static", "replay.html") return send_from_directory("static", "replay.html")
@app.route("/get_messages") @app.route("/get_messages")
def get_messages(): def get_messages():
return jsonify(messages) return jsonify(messages)
@ -65,5 +60,9 @@ def find_avatar_url(role):
if __name__ == "__main__": if __name__ == "__main__":
print("please visit http://127.0.0.1:8000/ for demo") parser = argparse.ArgumentParser(description='argparse')
app.run(debug=False, port=8000) parser.add_argument('--port', type=int, default=8000, help="port")
args = parser.parse_args()
port.append(args.port)
print(f"Please visit http://127.0.0.1:{port[-1]}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).")
app.run(debug=False, port=port[-1])

View File

@ -15,7 +15,8 @@
#visualization { #visualization {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
overflow-x: auto; overflow-x: visible;
overflow-y: visible;
max-width: 1800px; max-width: 1800px;
max-height: 1600px; max-height: 1600px;
margin: 20px; margin: 20px;
@ -24,9 +25,9 @@
.card { .card {
margin-right: 10px; margin-right: 10px;
display: inline-block; display: inline-block;
min-width: 300px; /* Reduced card width */ min-width: 300px;
vertical-align: top; vertical-align: top;
font-size: 14px; /* Reduced font size */ font-size: 14px;
} }
.simple-phase { .simple-phase {
@ -50,13 +51,16 @@
<body> <body>
<div class="container"> <div class="container">
<h2>ChatChain Visualizer</h2> <h2>ChatChain Visualizer</h2>
<p>Select your ChatChainConfig.json to visualize</p> <p>Select your ChatChainConfig.json under CompanyConfig/ to visualize</p>
<input type="file" id="fileInput"> <input type="file" id="fileInput" accept=".json">
<button id="exportButton">Export as Image</button>
<div id="visualization"></div> <div id="visualization"></div>
</div> </div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>
<script> <script>
document.getElementById('fileInput').addEventListener('change', handleFileSelect, false); document.getElementById('fileInput').addEventListener('change', handleFileSelect, false);
document.getElementById('exportButton').addEventListener('click', exportAsImage, false);
function handleFileSelect(event) { function handleFileSelect(event) {
const file = event.target.files[0]; const file = event.target.files[0];
@ -81,9 +85,6 @@
const cardContent = document.createElement('div'); const cardContent = document.createElement('div');
cardContent.className = 'card-content'; cardContent.className = 'card-content';
// Assuming "element" is a dictionary with some fields to visualize
// Customize this part based on the actual structure of your elements
if (element.phaseType === "ComposedPhase") { if (element.phaseType === "ComposedPhase") {
delete element.Composition; delete element.Composition;
} }
@ -94,7 +95,6 @@
const phaseType = document.createElement('p'); const phaseType = document.createElement('p');
phaseType.innerHTML = `<strong>PhaseType: </strong>${element.phaseType || 'No phaseType'}`; phaseType.innerHTML = `<strong>PhaseType: </strong>${element.phaseType || 'No phaseType'}`;
// Display the JSON content on the card
delete element.phase; delete element.phase;
delete element.phaseType; delete element.phaseType;
const jsonContent = document.createElement('pre'); const jsonContent = document.createElement('pre');
@ -126,21 +126,40 @@
nestedCardWrapper.style.marginTop = '10px'; nestedCardWrapper.style.marginTop = '10px';
nestedCards.forEach(nestedCard => { nestedCards.forEach(nestedCard => {
nestedCard.classList.add('nested-simple-phase'); // Apply the color for nested SimplePhase nestedCard.classList.add('nested-simple-phase');
nestedCardWrapper.appendChild(nestedCard); nestedCardWrapper.appendChild(nestedCard);
}); });
card.classList.add('composed-phase'); // Apply the color for ComposedPhase card.classList.add('composed-phase');
card.appendChild(nestedCardWrapper); card.appendChild(nestedCardWrapper);
visualization.appendChild(card); visualization.appendChild(card);
} else { } else {
const card = createCard(element); const card = createCard(element);
card.classList.add('simple-phase'); // Apply the color for SimplePhase card.classList.add('simple-phase');
visualization.appendChild(card); visualization.appendChild(card);
} }
}); });
} }
function exportAsImage() {
const visualization = document.getElementById('visualization');
const totalWidth = visualization.scrollWidth;
const totalHeight = visualization.scrollHeight;
console.log(totalWidth, totalHeight)
const canvas = document.createElement('canvas');
canvas.width = totalWidth + 100;
canvas.height = totalHeight + 100;
html2canvas(visualization, { scrollX: 0, scrollY: 0, width: totalWidth, height: totalHeight, useCORS: true }).then(canvas => {
const link = document.createElement('a');
link.href = canvas.toDataURL();
link.download = 'ChatChain_Visualization.png';
link.click();
});
}
</script> </script>
</body> </body>
</html> </html>

90
wiki.md
View File

@ -50,9 +50,9 @@
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
--config CONFIG Name of config, which is used to load configuration under CompanyConfig/ --config CONFIG Name of config, which is used to load configuration under CompanyConfig/; Please see CompanyConfig Section below
--org ORG Name of organization, your software will be generated in WareHouse/name_org_timestamp --org ORG Name of organization, your software will be generated in WareHouse/name_org_timestamp
--task TASK Prompt of software --task TASK Prompt of your idea
--name NAME Name of software, your software will be generated in WareHouse/name_org_timestamp --name NAME Name of software, your software will be generated in WareHouse/name_org_timestamp
--model MODEL GPT Model, choose from {'GPT_3_5_TURBO','GPT_4','GPT_4_32K'} --model MODEL GPT Model, choose from {'GPT_3_5_TURBO','GPT_4','GPT_4_32K'}
``` ```
@ -123,25 +123,30 @@ then go to [Local Demo Website](http://127.0.0.1:8000/) to see an online visuali
### Customize ChatChain ### Customize ChatChain
- see ``CompanyConfig/Default/ChatChainConfig.json`` - see ``CompanyConfig/Default/ChatChainConfig.json``
- You can easily pick and organize phases to formulate a ChatChain from all phases (from ``chatdev/phase.py`` or ``chatdev/composed_phase.py``) - You can easily pick and organize phases to formulate a ChatChain from all phases (from ``chatdev/phase.py``
or ``chatdev/composed_phase.py``)
by modifying the json file by modifying the json file
### Customize Phase ### Customize Phase
- This is the only part that needs to modify the code, and it brings much flexibility for customization. - This is the only part that needs to modify the code, and it brings much flexibility for customization.
- you just need to - you just need to
- implement your phase class (in the simplest case, only one functions need to be modified) extending the ``Phase`` class - implement your phase class (in the simplest case, only one functions need to be modified) extending the ``Phase``
class
- config this phase in ``PhaseConfig.json``, including writing phase prompt and assigning roles for this phase - config this phase in ``PhaseConfig.json``, including writing phase prompt and assigning roles for this phase
- Customize SimplePhase - Customize SimplePhase
- see ``CompanyConfig/Default/PhaseConfig.json`` for configuration, see ``chatdev/phase.py`` for implementing your own phase - see ``CompanyConfig/Default/PhaseConfig.json`` for configuration, see ``chatdev/phase.py`` for implementing your
own phase
- each phase contains three steps: - each phase contains three steps:
- generate phase environment from the whole chatchain environment - generate phase environment from the whole chatchain environment
- use phase environment to control the phase prompt and execute the chatting between roles in this phase (which usually does not need to be modified) - use phase environment to control the phase prompt and execute the chatting between roles in this phase (which
usually does not need to be modified)
- get a seminar conclusion from the chatting, and use it to update the whole chatchain environment - get a seminar conclusion from the chatting, and use it to update the whole chatchain environment
- below is a simple example phase on choosing the programming language of the software: - below is a simple example phase on choosing the programming language of the software:
- generate phase environment: we pick task, modality and ideas from the chatchain environment - generate phase environment: we pick task, modality and ideas from the chatchain environment
- execute the phase: no need to implement, which is defined in the Phase class - execute the phase: no need to implement, which is defined in the Phase class
- update chatchain environment: we get seminar conclusion (which language) and update the 'language' key in the chatchain environment - update chatchain environment: we get seminar conclusion (which language) and update the 'language' key in the
chatchain environment
```python ```python
class LanguageChoose(Phase): class LanguageChoose(Phase):
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -178,10 +183,12 @@ then go to [Local Demo Website](http://127.0.0.1:8000/) to see an online visuali
} }
``` ```
- Customize ComposePhase - Customize ComposePhase
- see ``CompanyConfig/Default/ChatChainConfig.json`` for configuration and see ``chatdev/composed_phase.py`` for implementation. - see ``CompanyConfig/Default/ChatChainConfig.json`` for configuration and see ``chatdev/composed_phase.py`` for
implementation.
- **⚠️ Attention** We do not support Nested Composition yet so do not put ComposePhase in ComposePhase. - **⚠️ Attention** We do not support Nested Composition yet so do not put ComposePhase in ComposePhase.
- ComposePhase contains multiple SimplePhase, and can be conducted in loop. - ComposePhase contains multiple SimplePhase, and can be conducted in loop.
- ComposePhase has no Phase json but in the chatchain json file you can define which SimplePhase is in this ComposePhase, such as: - ComposePhase has no Phase json but in the chatchain json file you can define which SimplePhase is in this
ComposePhase, such as:
```json ```json
{ {
"phase": "CodeReview", "phase": "CodeReview",
@ -204,7 +211,8 @@ then go to [Local Demo Website](http://127.0.0.1:8000/) to see an online visuali
} }
``` ```
- You also need to implement your own ComposePhase class, which you need to decide the phase_env update and - You also need to implement your own ComposePhase class, which you need to decide the phase_env update and
chat_env update (the same as SimplePhase, but for the whole ComposePhase) and the condition for stopping the loop (optional): chat_env update (the same as SimplePhase, but for the whole ComposePhase) and the condition for stopping the
loop (optional):
```python ```python
class Test(ComposedPhase): class Test(ComposedPhase):
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -228,23 +236,25 @@ then go to [Local Demo Website](http://127.0.0.1:8000/) to see an online visuali
- see ``CompanyConfig/Default/RoleConfig.json`` - see ``CompanyConfig/Default/RoleConfig.json``
- you can use placeholders for using phase environment, which is the same as PhaseConfig.json - you can use placeholders for using phase environment, which is the same as PhaseConfig.json
- **⚠️ Attention** You need to keep at least "Chief Executive Officer" and "Counselor" in your own ``RoleConfig.json`` to make Reflection work. - **⚠️ Attention** You need to keep at least "Chief Executive Officer" and "Counselor" in your own ``RoleConfig.json``
to make Reflection work.
## ChatChain params ## ChatChain Parameters
- clear_structure: clean cache folders. - *clear_structure*: clean cache folders.
- brainstorming: TBD - *brainstorming*: TBD
- gui_design: whether create gui for software. - *gui_design*: whether create gui for software.
- git_management: open git management on software project or not. - *git_management*: open git management on software project or not.
- self_improve: flag for self-improvement on user input prompt. It is a special chatting that LLM plays as a prompt - *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 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 take longer time to finish the phase. - *max_turn_step*: Max number of chatting turn. You can increase max_turn_step for better performance but it will
- need_reflect: Flag for reflection. Reflection is a special phase that automatically executes after a phase. It take longer time to finish the phase.
- *need_reflect*: Flag for reflection. Reflection is a special phase that automatically executes after a phase. It
will start a chatting between counselor and CEO to refine the conclusion of phase chatting. will start a chatting between counselor and CEO to refine the conclusion of phase chatting.
- params in ComposedPhase - params in ComposedPhase
- cycleNum: Number of cycles to execute SimplePhase in this ComposedPhase. - *cycleNum*: Number of cycles to execute SimplePhase in this ComposedPhase.
## Project Structure ## Project Structure
@ -260,3 +270,43 @@ then go to [Local Demo Website](http://127.0.0.1:8000/) to see an online visuali
├── README.md ├── README.md
└── wiki.md └── wiki.md
``` ```
## CompanyConfig
### Default
![demo](misc/ChatChain_Visualization_Default.png)
- As shown in the ChatChain visualization of Default setting, ChatDev will produce a software in the order of:
- Demand Analysis: decide the modality of the software
- Language Choose: decide the programming language
- Coding: write the code
- CodeCompleteAll: complete the missing function/class
- CodeReview: review and modify the code
- Test: run the software and modify the code based on the test report
- EnvironmentDoc: write the environment doc
- Manual: write the manual
- You can use default setting using ``python3 run.py --config "Default"``.
### Art
![demo](misc/ChatChain_Visualization_Art.png)
- Compared to Default, Art setting add a phase before CodeCompleteAll called Art
- The Art phase will first discuss the name and description of the images assets, then use ``openai.Image.create`` to generate the images based on description.
- You can use default setting using ``python3 run.py --config "Art"`` or just ignore the config parameter.
### Human-Agent Interaction
![demo](misc/ChatChain_Visualization_Human.png)
- Compared to Default, in ***Human-Agent-Interaction*** mode you can play as reviewer and asks programmer agent to modify the code based on your comments.
- It adds a Phase called HumanAgentInteraction after the CodeReview Phase.
- You can use ***Human-Agent-Interaction*** setting using ``python3 run.py --config "Human"``.
- When chatdev executes to this Phase, on the command interface you will see a hint that ask for input.
- You can run your software in the ``WareHouse/`` and see if it satisfies your need. Then you can type anything you want (bug fix or new feature) in the command interface, then press Enter:
![Human_command](misc/Human_command.png)
- For example
- We first run the ChatDev with task "design a gomoku game"
- Then we type "Please add a restart button" in the HumanAgentInteraction Phase, adding the first feature
- In the second loop of HumanAgentInteraction, we add another feature by typing "Please add a current status bar showing whose turn it is".
- At last, we early exit this mode by typing "End".
- Below shows all three versions.
- <img src='misc/Human_v1.png' height=250>&nbsp;&nbsp;&nbsp;&nbsp;<img src='misc/Human_v2.png' height=250>&nbsp;&nbsp;&nbsp;&nbsp;<img src='misc/Human_v3.png' height=250>