🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
test strategy
geekan0789f2c1093a
diff --git a/metagpt/strategy/tot.py b/metagpt/strategy/tot.pyindex a32cfdf40..4f33698bf 100644--- a/metagpt/strategy/tot.py+++ b/metagpt/strategy/tot.py@@ -5,7 +5,7 @@import asynciofrom typing import Any, List-from pydantic import BaseModel, Field+from pydantic import BaseModel, ConfigDict, Fieldfrom metagpt.llm import LLMfrom metagpt.logs import logger@@ -29,6 +29,8 @@ Output a list of jsons following the format:class ThoughtSolverBase(BaseModel):+ model_config = ConfigDict(arbitrary_types_allowed=True)+thought_tree: str = ""llm: BaseLLM = Field(default_factory=LLM, exclude=True)config: ThoughtSolverConfig = Field(default_factory=ThoughtSolverConfig)diff --git a/requirements.txt b/requirements.txtindex 832b4c1c8..c04c6cc7f 100644--- a/requirements.txt+++ b/requirements.txt@@ -58,3 +58,4 @@ websockets~=12.0networkx~=3.2.1google-generativeai==0.3.1playwright==1.40.0+anytreediff --git a/tests/metagpt/strategy/__init__.py b/tests/metagpt/strategy/__init__.pynew file mode 100644index 000000000..e95a9b4ed--- /dev/null+++ b/tests/metagpt/strategy/__init__.py@@ -0,0 +1,7 @@+#!/usr/bin/env python+# -*- coding: utf-8 -*-+"""+@Time : 2023/12/30 00:33+@Author : alexanderwu+@File : __init__.py+"""diff --git a/metagpt/strategy/examples/__init__.py b/tests/metagpt/strategy/examples/__init__.pysimilarity index 100%rename from metagpt/strategy/examples/__init__.pyrename to tests/metagpt/strategy/examples/__init__.pydiff --git a/metagpt/strategy/examples/creative_writing.py b/tests/metagpt/strategy/examples/creative_writing.pysimilarity index 87%rename from metagpt/strategy/examples/creative_writing.pyrename to tests/metagpt/strategy/examples/creative_writing.pyindex 94efd9264..59a3c94d7 100644--- a/metagpt/strategy/examples/creative_writing.py+++ b/tests/metagpt/strategy/examples/creative_writing.py@@ -3,8 +3,8 @@# @Author : stellahong ([email protected])# @Desc :import re+from typing import Dict-from metagpt.strategy.prompt_templates.creative_writing import cot_prompt, vote_promptfrom metagpt.strategy.tot import TreeofThoughtfrom metagpt.strategy.tot_schema import (BaseEvaluator,@@ -12,6 +12,10 @@ from metagpt.strategy.tot_schema import (Strategy,ThoughtSolverConfig,)+from tests.metagpt.strategy.prompt_templates.creative_writing import (+ cot_prompt,+ vote_prompt,+)class TextGenParser(BaseParser):@@ -31,8 +35,8 @@ class TextGenParser(BaseParser):class TextGenEvaluator(BaseEvaluator):- value_map = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc- status_map = {val: key for key, val in value_map.items()}+ value_map: Dict[str, float] = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc+ status_map: Dict = {val: key for key, val in value_map.items()}def __call__(self, evaluation: str, **kwargs) -> float:try:@@ -59,7 +63,7 @@ class TextGenEvaluator(BaseEvaluator):return status-if __name__ == "__main__":+def test_creative_writing():import asyncioinitial_prompt = """It isn't difficult to do a handstand if you just stand on your hands. It caught him off guard that space smelled of seared steak. When she didn’t like a guy who was trying to pick her up, she started using sign language. Each person who knows you has a different perception of who you are."""diff --git a/metagpt/strategy/examples/game24.py b/tests/metagpt/strategy/examples/game24.pysimilarity index 85%rename from metagpt/strategy/examples/game24.pyrename to tests/metagpt/strategy/examples/game24.pyindex 32e4ede02..c26c8da88 100644--- a/metagpt/strategy/examples/game24.py+++ b/tests/metagpt/strategy/examples/game24.py@@ -3,8 +3,8 @@# @Author : stellahong ([email protected])# @Desc :import re+from typing import Dict-from metagpt.strategy.prompt_templates.game24 import propose_prompt, value_promptfrom metagpt.strategy.tot import TreeofThoughtfrom metagpt.strategy.tot_schema import (BaseEvaluator,@@ -12,6 +12,7 @@ from metagpt.strategy.tot_schema import (Strategy,ThoughtSolverConfig,)+from tests.metagpt.strategy.prompt_templates.game24 import propose_prompt, value_promptclass Game24Parser(BaseParser):@@ -31,8 +32,8 @@ class Game24Parser(BaseParser):class Game24Evaluator(BaseEvaluator):- value_map = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc- status_map = {val: key for key, val in value_map.items()}+ value_map: Dict[str, float] = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc+ status_map: Dict = {val: key for key, val in value_map.items()}def __call__(self, evaluation: str, **kwargs) -> float:try:@@ -51,7 +52,7 @@ class Game24Evaluator(BaseEvaluator):return status-if __name__ == "__main__":+def test_game24():import asyncioinitial_prompt = """4 5 6 10"""diff --git a/metagpt/strategy/prompt_templates/__init__.py b/tests/metagpt/strategy/prompt_templates/__init__.pysimilarity index 100%rename from metagpt/strategy/prompt_templates/__init__.pyrename to tests/metagpt/strategy/prompt_templates/__init__.pydiff --git a/metagpt/strategy/prompt_templates/creative_writing.py b/tests/metagpt/strategy/prompt_templates/creative_writing.pysimilarity index 100%rename from metagpt/strategy/prompt_templates/creative_writing.pyrename to tests/metagpt/strategy/prompt_templates/creative_writing.pydiff --git a/metagpt/strategy/prompt_templates/game24.py b/tests/metagpt/strategy/prompt_templates/game24.pysimilarity index 100%rename from metagpt/strategy/prompt_templates/game24.pyrename to tests/metagpt/strategy/prompt_templates/game24.py