🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
format code
seehib20316d6cd2b
diff --git a/metagpt/exp_pool/context_builders/action_node.py b/metagpt/exp_pool/context_builders/action_node.pyindex a3362875c..891b898be 100644--- a/metagpt/exp_pool/context_builders/action_node.py+++ b/metagpt/exp_pool/context_builders/action_node.py@@ -24,6 +24,7 @@ class ActionNodeContextBuilder(BaseContextBuilder):If there are no experiences, returns the original `req`;otherwise returns context with `req` and formatted experiences."""+exps = self.format_exps()return ACTION_NODE_CONTEXT_TEMPLATE.format(req=req, exps=exps) if exps else reqdiff --git a/metagpt/exp_pool/context_builders/role_zero.py b/metagpt/exp_pool/context_builders/role_zero.pyindex 2ee469661..aa5524ab4 100644--- a/metagpt/exp_pool/context_builders/role_zero.py+++ b/metagpt/exp_pool/context_builders/role_zero.py@@ -16,6 +16,7 @@ class RoleZeroContextBuilder(BaseContextBuilder):2. Returns the original `req` if it is empty, incorrectly formatted or there are no experiences.3. Creates a copy of req and replaces the example content in the copied req with actual experiences."""+if not req or len(req) < 2:return reqdiff --git a/metagpt/exp_pool/manager.py b/metagpt/exp_pool/manager.pyindex ba1a8bcf0..d6922ff00 100644--- a/metagpt/exp_pool/manager.py+++ b/metagpt/exp_pool/manager.py@@ -39,7 +39,7 @@ class ExperienceManager(BaseModel):similarity_top_k=DEFAULT_SIMILARITY_TOP_K,)]- ranker_configs = [LLMRankerConfig()]+ ranker_configs = [LLMRankerConfig(top_n=DEFAULT_SIMILARITY_TOP_K)]self.storage = SimpleEngine.from_objs(retriever_configs=retriever_configs, ranker_configs=ranker_configs)@@ -57,6 +57,7 @@ class ExperienceManager(BaseModel):Args:exp (Experience): The experience to add."""+if not self.config.exp_pool.enable_write:return@@ -74,6 +75,7 @@ class ExperienceManager(BaseModel):Returns:list[Experience]: A list of experiences that match the args."""+if not self.config.exp_pool.enable_read:return []@@ -90,6 +92,8 @@ class ExperienceManager(BaseModel):return expsdef get_exps_count(self) -> int:+ """Get the total number of experiences."""+return self.vector_store._collection.count()diff --git a/metagpt/exp_pool/scorers/simple.py b/metagpt/exp_pool/scorers/simple.pyindex fd7b6537b..4b060aac4 100644--- a/metagpt/exp_pool/scorers/simple.py+++ b/metagpt/exp_pool/scorers/simple.py@@ -57,6 +57,7 @@ class SimpleScorer(BaseScorer):Returns:Score: An object containing the score (1-10) and the reasoning."""+prompt = SIMPLE_SCORER_TEMPLATE.format(req=req, resp=resp)resp = await self.llm.aask(prompt)resp_json = json.loads(CodeParser.parse_code(resp, lang="json"))diff --git a/metagpt/exp_pool/serializers/role_zero.py b/metagpt/exp_pool/serializers/role_zero.pyindex f5363b1ff..720bf5078 100644--- a/metagpt/exp_pool/serializers/role_zero.py+++ b/metagpt/exp_pool/serializers/role_zero.py@@ -24,6 +24,7 @@ class RoleZeroSerializer(SimpleSerializer):Returns:str: The serialized request as a JSON string."""+if not req:return ""