🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
refine code
geekand150cc358a7b
diff --git a/metagpt/actions/write_prd_an.py b/metagpt/actions/write_prd_an.pyindex 948d7d62f..715e8fc55 100644--- a/metagpt/actions/write_prd_an.py+++ b/metagpt/actions/write_prd_an.py@@ -8,7 +8,6 @@from typing import Listfrom metagpt.actions.action_node import ActionNode-from metagpt.logs import loggerLANGUAGE = ActionNode(key="Language",@@ -34,7 +33,8 @@ ORIGINAL_REQUIREMENTS = ActionNode(PROJECT_NAME = ActionNode(key="Project Name",expected_type=str,- instruction="According to the content of \"Original Requirements,\" name the project using snake case style , like 'game_2048' or 'simple_crm.",+ instruction='According to the content of "Original Requirements," name the project using snake case style , '+ "like 'game_2048' or 'simple_crm.",example="game_2048",)@@ -155,12 +155,3 @@ NODES = [WRITE_PRD_NODE = ActionNode.from_children("WritePRD", NODES)WP_ISSUE_TYPE_NODE = ActionNode.from_children("WP_ISSUE_TYPE", [ISSUE_TYPE, REASON])WP_IS_RELATIVE_NODE = ActionNode.from_children("WP_IS_RELATIVE", [IS_RELATIVE, REASON])---def main():- prompt = WRITE_PRD_NODE.compile(context="")- logger.info(prompt)---if __name__ == "__main__":- main()diff --git a/metagpt/memory/longterm_memory.py b/metagpt/memory/longterm_memory.pyindex b54653970..5a139a93b 100644--- a/metagpt/memory/longterm_memory.py+++ b/metagpt/memory/longterm_memory.py@@ -2,7 +2,6 @@# -*- coding: utf-8 -*-"""@Desc : the implement of Long-term memory-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation."""from typing import Optionaldiff --git a/metagpt/memory/memory_storage.py b/metagpt/memory/memory_storage.pyindex 1850e0ea0..c029d027b 100644--- a/metagpt/memory/memory_storage.py+++ b/metagpt/memory/memory_storage.py@@ -2,7 +2,6 @@# -*- coding: utf-8 -*-"""@Desc : the implement of memory storage-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation."""from pathlib import Pathdiff --git a/metagpt/provider/azure_openai_api.py b/metagpt/provider/azure_openai_api.pyindex 0b46b1fa7..6dc32d380 100644--- a/metagpt/provider/azure_openai_api.py+++ b/metagpt/provider/azure_openai_api.py@@ -3,8 +3,6 @@@Time : 2023/5/5 23:08@Author : alexanderwu@File : openai.py-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation;- Change cost control from global to company level.@Modified By: mashenquan, 2023/11/21. Fix bug: ReadTimeout.@Modified By: mashenquan, 2023/12/1. Fix bug: Unclosed connection caused by openai 0.x."""diff --git a/metagpt/provider/fireworks_api.py b/metagpt/provider/fireworks_api.pyindex 5fbcfdbf0..f9ff7e655 100644--- a/metagpt/provider/fireworks_api.py+++ b/metagpt/provider/fireworks_api.py@@ -84,7 +84,7 @@ class FireworksLLM(OpenAILLM):def _update_costs(self, usage: CompletionUsage):if self.config.calc_usage and usage:try:- # use FireworksCostManager not CONFIG.cost_manager+ # use FireworksCostManager not CONTEXT.cost_managerself.cost_manager.update_cost(usage.prompt_tokens, usage.completion_tokens, self.model)except Exception as e:logger.error(f"updating costs failed!, exp: {e}")diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.pyindex 2741485bd..05a8d75f8 100644--- a/metagpt/provider/openai_api.py+++ b/metagpt/provider/openai_api.py@@ -3,8 +3,6 @@@Time : 2023/5/5 23:08@Author : alexanderwu@File : openai.py-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for isolation;- Change cost control from global to company level.@Modified By: mashenquan, 2023/11/21. Fix bug: ReadTimeout.@Modified By: mashenquan, 2023/12/1. Fix bug: Unclosed connection caused by openai 0.x."""diff --git a/metagpt/roles/role.py b/metagpt/roles/role.pyindex 6e05937a7..0e20e45ad 100644--- a/metagpt/roles/role.py+++ b/metagpt/roles/role.py@@ -102,7 +102,7 @@ class RoleContext(BaseModel):max_react_loop: int = 1def check(self, role_id: str):- # if hasattr(CONFIG, "long_term_memory") and CONFIG.long_term_memory:+ # if hasattr(CONFIG, "enable_longterm_memory") and CONFIG.enable_longterm_memory:# self.long_term_memory.recover_memory(role_id, self)# self.memory = self.long_term_memory # use memory to act as long_term_memory for unify operationpassdiff --git a/metagpt/tools/web_browser_engine.py b/metagpt/tools/web_browser_engine.pyindex ff1f46a36..61d29688b 100644--- a/metagpt/tools/web_browser_engine.py+++ b/metagpt/tools/web_browser_engine.py@@ -1,7 +1,5 @@#!/usr/bin/env python-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+# -*- coding: utf-8 -*-from __future__ import annotationsdiff --git a/metagpt/tools/web_browser_engine_playwright.py b/metagpt/tools/web_browser_engine_playwright.pyindex 14c19816d..f8dabd5ac 100644--- a/metagpt/tools/web_browser_engine_playwright.py+++ b/metagpt/tools/web_browser_engine_playwright.py@@ -1,7 +1,5 @@#!/usr/bin/env python-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+# -*- coding: utf-8 -*-from __future__ import annotationsdiff --git a/metagpt/tools/web_browser_engine_selenium.py b/metagpt/tools/web_browser_engine_selenium.pyindex 18e5db974..7988358ff 100644--- a/metagpt/tools/web_browser_engine_selenium.py+++ b/metagpt/tools/web_browser_engine_selenium.py@@ -1,7 +1,5 @@#!/usr/bin/env python-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+# -*- coding: utf-8 -*-from __future__ import annotationsdiff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.pyindex 3f6a2ef12..e49fdea5d 100644--- a/metagpt/utils/mermaid.py+++ b/metagpt/utils/mermaid.py@@ -4,7 +4,6 @@@Time : 2023/7/4 10:53@Author : alexanderwu alitrack@File : mermaid.py-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation."""import asyncioimport osdiff --git a/tests/conftest.py b/tests/conftest.pyindex 9ad05e1a0..34429417b 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -30,7 +30,6 @@ ALLOW_OPENAI_API_CALL = int(@pytest.fixture(scope="session")def rsp_cache():- # model_version = CONFIG.openai_api_modelrsp_cache_file_path = TEST_DATA_PATH / "rsp_cache.json" # read repo-providednew_rsp_cache_file_path = TEST_DATA_PATH / "rsp_cache_new.json" # exporting a new copyif os.path.exists(rsp_cache_file_path):diff --git a/tests/metagpt/memory/test_longterm_memory.py b/tests/metagpt/memory/test_longterm_memory.pyindex a9ef56bad..5c71ddd13 100644--- a/tests/metagpt/memory/test_longterm_memory.py+++ b/tests/metagpt/memory/test_longterm_memory.py@@ -2,7 +2,6 @@# -*- coding: utf-8 -*-"""@Desc : unittest of `metagpt/memory/longterm_memory.py`-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation."""import osdiff --git a/tests/metagpt/provider/test_zhipuai_api.py b/tests/metagpt/provider/test_zhipuai_api.pyindex 6ac8c428c..c4a40c23d 100644--- a/tests/metagpt/provider/test_zhipuai_api.py+++ b/tests/metagpt/provider/test_zhipuai_api.py@@ -82,6 +82,7 @@ async def test_zhipuai_acompletion(mocker):def test_zhipuai_proxy():- # CONFIG.openai_proxy = "http://127.0.0.1:8080"+ # it seems like zhipuai would be inflected by the proxy of openai, maybe it's a bug+ # but someone may want to use openai.proxy, so we keep this test case+ # assert openai.proxy == config.llm.proxy_ = ZhiPuAILLM(mock_llm_config_zhipu)- # assert openai.proxy == CONFIG.openai_proxydiff --git a/tests/metagpt/test_context_mixin.py b/tests/metagpt/test_context_mixin.pyindex 472d67a27..a098ff0dc 100644--- a/tests/metagpt/test_context_mixin.py+++ b/tests/metagpt/test_context_mixin.py@@ -125,4 +125,3 @@ async def test_config_priority():assert a3.llm.model == "gpt-3.5-turbo-1106"# history = await team.run(idea="Topic: climate change. Under 80 words per message.", send_to="a1", n_round=3)- # assert "Alex" in historydiff --git a/tests/metagpt/test_environment.py b/tests/metagpt/test_environment.pyindex 49fd8a5fc..10839a2a5 100644--- a/tests/metagpt/test_environment.py+++ b/tests/metagpt/test_environment.py@@ -4,8 +4,6 @@@Time : 2023/5/12 00:47@Author : alexanderwu@File : test_environment.py-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""from pathlib import Pathdiff --git a/tests/metagpt/test_llm.py b/tests/metagpt/test_llm.pyindex dc18114b1..d46a29c7f 100644--- a/tests/metagpt/test_llm.py+++ b/tests/metagpt/test_llm.py@@ -4,7 +4,6 @@@Time : 2023/5/11 14:45@Author : alexanderwu@File : test_llm.py-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation."""import pytestdiff --git a/tests/metagpt/tools/test_web_browser_engine.py b/tests/metagpt/tools/test_web_browser_engine.pyindex 289edda2f..ceebd67fc 100644--- a/tests/metagpt/tools/test_web_browser_engine.py+++ b/tests/metagpt/tools/test_web_browser_engine.py@@ -1,6 +1,5 @@-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+#!/usr/bin/env python+# -*- coding: utf-8 -*-import pytestdiff --git a/tests/metagpt/tools/test_web_browser_engine_playwright.py b/tests/metagpt/tools/test_web_browser_engine_playwright.pyindex 32019bad9..053f1782d 100644--- a/tests/metagpt/tools/test_web_browser_engine_playwright.py+++ b/tests/metagpt/tools/test_web_browser_engine_playwright.py@@ -1,6 +1,5 @@-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+#!/usr/bin/env python+# -*- coding: utf-8 -*-import pytestdiff --git a/tests/metagpt/tools/test_web_browser_engine_selenium.py b/tests/metagpt/tools/test_web_browser_engine_selenium.pyindex bd5abcb9b..8dcd006f3 100644--- a/tests/metagpt/tools/test_web_browser_engine_selenium.py+++ b/tests/metagpt/tools/test_web_browser_engine_selenium.py@@ -1,6 +1,5 @@-"""-@Modified By: mashenquan, 2023/8/20. Remove global configuration `CONFIG`, enable configuration support for business isolation.-"""+#!/usr/bin/env python+# -*- coding: utf-8 -*-import pytest