🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: merge geekan:env_refactor
莘权 马1a36361691e2
diff --git a/metagpt/provider/fireworks_api.py b/metagpt/provider/fireworks_api.pyindex 47ac9cf61..5dc68ad35 100644--- a/metagpt/provider/fireworks_api.py+++ b/metagpt/provider/fireworks_api.py@@ -5,7 +5,8 @@import openaifrom metagpt.config import CONFIG-from metagpt.provider.openai_api import CostManager, OpenAIGPTAPI, RateLimiter+from metagpt.provider.openai_api import OpenAIGPTAPI, RateLimiter+from metagpt.utils.cost_manager import CostManagerclass FireWorksGPTAPI(OpenAIGPTAPI):diff --git a/metagpt/provider/open_llm_api.py b/metagpt/provider/open_llm_api.pyindex f421e30c8..97e4c9f67 100644--- a/metagpt/provider/open_llm_api.py+++ b/metagpt/provider/open_llm_api.py@@ -6,7 +6,8 @@ import openaifrom metagpt.config import CONFIGfrom metagpt.logs import logger-from metagpt.provider.openai_api import CostManager, OpenAIGPTAPI, RateLimiter+from metagpt.provider.openai_api import OpenAIGPTAPI, RateLimiter+from metagpt.utils.cost_manager import CostManagerclass OpenLLMCostManager(CostManager):diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.pyindex 206be29d0..493f88153 100644--- a/metagpt/provider/openai_api.py+++ b/metagpt/provider/openai_api.py@@ -118,7 +118,11 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter):kwargs["model"] = CONFIG.deployment_idelse:kwargs["model"] = self.model- kwargs["timeout"] = max(CONFIG.TIMEOUT, timeout) if CONFIG.TIMEOUT is not None else timeout+ try:+ default_timeout = int(CONFIG.TIMEOUT) if CONFIG.TIMEOUT else 0+ except ValueError:+ default_timeout = 0+ kwargs["timeout"] = max(default_timeout, timeout)return kwargsdiff --git a/metagpt/roles/product_manager.py b/metagpt/roles/product_manager.pyindex b37a2f777..f022237f5 100644--- a/metagpt/roles/product_manager.py+++ b/metagpt/roles/product_manager.py@@ -45,6 +45,7 @@ class ProductManager(Role):self._init_actions([PrepareDocuments, WritePRD])self._watch([UserRequirement, PrepareDocuments])+ self._todo = any_to_name(PrepareDocuments)async def _think(self) -> None:"""Decide what to do"""@@ -52,6 +53,7 @@ class ProductManager(Role):self._set_state(1)else:self._set_state(0)+ self._todo = any_to_name(WritePRD)return self._rc.todoasync def _observe(self, ignore_memory=False) -> int:@@ -59,7 +61,4 @@ class ProductManager(Role):@propertydef todo(self) -> str:- if self._rc.state == 0:- return any_to_name(WritePRD)- else:- return any_to_name(PrepareDocuments)+ return self._tododiff --git a/metagpt/utils/mermaid.py b/metagpt/utils/mermaid.pyindex 3fa7ab79a..a1a6d462b 100644--- a/metagpt/utils/mermaid.py+++ b/metagpt/utils/mermaid.py@@ -93,57 +93,57 @@ async def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048,return 0-if __name__ == "__main__":- MMC1 = """classDiagram- class Main {- -SearchEngine search_engine- +main() str- }- class SearchEngine {- -Index index- -Ranking ranking- -Summary summary- +search(query: str) str- }- class Index {- -KnowledgeBase knowledge_base- +create_index(data: dict)- +query_index(query: str) list- }- class Ranking {- +rank_results(results: list) list- }- class Summary {- +summarize_results(results: list) str- }- class KnowledgeBase {- +update(data: dict)- +fetch_data(query: str) dict- }- Main --> SearchEngine- SearchEngine --> Index- SearchEngine --> Ranking- SearchEngine --> Summary- Index --> KnowledgeBase"""-- MMC2 = """sequenceDiagram- participant M as Main- participant SE as SearchEngine- participant I as Index- participant R as Ranking- participant S as Summary- participant KB as KnowledgeBase- M->>SE: search(query)- SE->>I: query_index(query)- I->>KB: fetch_data(query)- KB-->>I: return data- I-->>SE: return results- SE->>R: rank_results(results)- R-->>SE: return ranked_results- SE->>S: summarize_results(ranked_results)- S-->>SE: return summary- SE-->>M: return summary"""+MMC1 = """classDiagram+class Main {+ -SearchEngine search_engine+ +main() str+}+class SearchEngine {+ -Index index+ -Ranking ranking+ -Summary summary+ +search(query: str) str+}+class Index {+ -KnowledgeBase knowledge_base+ +create_index(data: dict)+ +query_index(query: str) list+}+class Ranking {+ +rank_results(results: list) list+}+class Summary {+ +summarize_results(results: list) str+}+class KnowledgeBase {+ +update(data: dict)+ +fetch_data(query: str) dict+}+Main --> SearchEngine+SearchEngine --> Index+SearchEngine --> Ranking+SearchEngine --> Summary+Index --> KnowledgeBase"""++MMC2 = """sequenceDiagram+participant M as Main+participant SE as SearchEngine+participant I as Index+participant R as Ranking+participant S as Summary+participant KB as KnowledgeBase+M->>SE: search(query)+SE->>I: query_index(query)+I->>KB: fetch_data(query)+KB-->>I: return data+I-->>SE: return results+SE->>R: rank_results(results)+R-->>SE: return ranked_results+SE->>S: summarize_results(ranked_results)+S-->>SE: return summary+SE-->>M: return summary"""+if __name__ == "__main__":loop = asyncio.new_event_loop()result = loop.run_until_complete(mermaid_to_file(MMC1, METAGPT_ROOT / f"{CONFIG.mermaid_engine}/1"))result = loop.run_until_complete(mermaid_to_file(MMC2, METAGPT_ROOT / f"{CONFIG.mermaid_engine}/2"))