🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
Update 混乱版本
didi02c7c4ea47d7
diff --git a/examples/ags/w_action_node/evaluator.py b/examples/ags/w_action_node/evaluator.pyindex 75875c5b5..42e2a7d96 100644--- a/examples/ags/w_action_node/evaluator.py+++ b/examples/ags/w_action_node/evaluator.py@@ -6,7 +6,7 @@ from typing import Literal# TODO 完成实验数据集的手动划分-DatasetType = Literal["humaneval", "gsm8k", "hotpotqa", "drop", "mmlu"]+DatasetType = Literal["HumanEval", "MMBP", "Gsm8K", "MATH", "HotpotQa", "MMLU"]class Evaluator:diff --git a/examples/ags/w_action_node/graph.py b/examples/ags/w_action_node/graph.pyindex 4b6286192..24865a2a5 100644--- a/examples/ags/w_action_node/graph.py+++ b/examples/ags/w_action_node/graph.py@@ -8,7 +8,7 @@ from typing import Literalfrom metagpt.llm import LLMfrom metagpt.utils.cost_manager import CostManager-DatasetType = Literal["humaneval", "gsm8k", "hotpotqa", "drop", "mmlu"]+DatasetType = Literal["HumanEval", "MMBP", "Gsm8K", "MATH", "HotpotQa", "MMLU"]cost_manager = CostManager()diff --git a/examples/ags/w_action_node/operator_an.py b/examples/ags/w_action_node/operator_an.pyindex 30ef27986..d5e47db4d 100644--- a/examples/ags/w_action_node/operator_an.py+++ b/examples/ags/w_action_node/operator_an.py@@ -86,3 +86,7 @@ class ReflectionTestOp(BaseModel):refined_solution: str = Field(default="", description="Corrective solution for code execution errors or test case failures")+++class Optimize(BaseModel):+ graph: str = Field(default="", description="graph")diff --git a/examples/ags/w_action_node/graphs/gsm8k/basic/graph.py b/examples/ags/w_action_node/optimized/gsm8k/basic/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/basic/graph.pyrename to examples/ags/w_action_node/optimized/gsm8k/basic/graph.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/basic/operator.py b/examples/ags/w_action_node/optimized/gsm8k/basic/operator.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/basic/operator.pyrename to examples/ags/w_action_node/optimized/gsm8k/basic/operator.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/basic/prompt.py b/examples/ags/w_action_node/optimized/gsm8k/basic/prompt.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/basic/prompt.pyrename to examples/ags/w_action_node/optimized/gsm8k/basic/prompt.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/graph.py b/examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/graph.pyrename to examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/graph.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/operator.py b/examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/operator.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/operator.pyrename to examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/operator.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/operator_an.py b/examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/operator_an.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/operator_an.pyrename to examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/operator_an.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/prompt.py b/examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/prompt.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/optimized/round_1/prompt.pyrename to examples/ags/w_action_node/optimized/gsm8k/graphs/round_1/prompt.pydiff --git a/examples/ags/w_action_node/graphs/gsm8k/handcraft/graph.py b/examples/ags/w_action_node/optimized/gsm8k/handcraft/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/gsm8k/handcraft/graph.pyrename to examples/ags/w_action_node/optimized/gsm8k/handcraft/graph.pydiff --git a/examples/ags/w_action_node/graphs/hotpotqa/basic/graph.py b/examples/ags/w_action_node/optimized/hotpotqa/basic/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/hotpotqa/basic/graph.pyrename to examples/ags/w_action_node/optimized/hotpotqa/basic/graph.pydiff --git a/examples/ags/w_action_node/graphs/hotpotqa/basic/operator.py b/examples/ags/w_action_node/optimized/hotpotqa/basic/operator.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/hotpotqa/basic/operator.pyrename to examples/ags/w_action_node/optimized/hotpotqa/basic/operator.pydiff --git a/examples/ags/w_action_node/graphs/hotpotqa/basic/prompt.py b/examples/ags/w_action_node/optimized/hotpotqa/basic/prompt.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/hotpotqa/basic/prompt.pyrename to examples/ags/w_action_node/optimized/hotpotqa/basic/prompt.pydiff --git a/examples/ags/w_action_node/graphs/hotpotqa/graph.py b/examples/ags/w_action_node/optimized/hotpotqa/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/hotpotqa/graph.pyrename to examples/ags/w_action_node/optimized/hotpotqa/graph.pydiff --git a/examples/ags/w_action_node/graphs/humaneval/basic/graph.py b/examples/ags/w_action_node/optimized/humaneval/basic/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/humaneval/basic/graph.pyrename to examples/ags/w_action_node/optimized/humaneval/basic/graph.pydiff --git a/examples/ags/w_action_node/graphs/humaneval/basic/operator.py b/examples/ags/w_action_node/optimized/humaneval/basic/operator.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/humaneval/basic/operator.pyrename to examples/ags/w_action_node/optimized/humaneval/basic/operator.pydiff --git a/examples/ags/w_action_node/graphs/humaneval/basic/prompt.py b/examples/ags/w_action_node/optimized/humaneval/basic/prompt.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/humaneval/basic/prompt.pyrename to examples/ags/w_action_node/optimized/humaneval/basic/prompt.pydiff --git a/examples/ags/w_action_node/graphs/humaneval/graph.py b/examples/ags/w_action_node/optimized/humaneval/graph.pysimilarity index 100%rename from examples/ags/w_action_node/graphs/humaneval/graph.pyrename to examples/ags/w_action_node/optimized/humaneval/graph.pydiff --git a/examples/ags/w_action_node/optimizer.py b/examples/ags/w_action_node/optimizer.pyindex a88f6baa3..6b6ed942a 100644--- a/examples/ags/w_action_node/optimizer.py+++ b/examples/ags/w_action_node/optimizer.py@@ -21,6 +21,11 @@ DatasetType = Literal["HumanEval", "MMBP", "Gsm8K", "MATH", "HotpotQa", "MMLU"]evaluator = Evaluator(eval_path="eval")+# prompt = GENERATE_PROMPT.format(problem_description=problem_description)+# node = await ActionNode.from_pydantic(GenerateOp).fill(context=prompt, mode="context_fill", llm=self.llm)+# response = node.instruct_content.model_dump()+# return response+class Optimizer:def __init__(self, dataset: DatasetType, llm: LLM, operators: List, optimized_path: str = None) -> None:@@ -28,6 +33,7 @@ class Optimizer:self.dataset = datasetself.graph = None # 初始化为 None,稍后加载self.operators = operators+ self.optimize_prompt = ""self._optimized_path = optimized_pathself.root_path = f"{self._optimized_path}/{self.dataset}"self.sample = 6 # sample 含义是什么?@@ -37,9 +43,10 @@ class Optimizer:def _initialize(self):"""- 基于数据集、操作符初始化 operator 跟 graph+ 基于数据集、操作符初始化optimize prompt, operator 跟 graph"""- basic_path = f"{config_iterate_path}/{self.dataset}/basic"++ basic_path = f"{self.root_path}/basic"required_files = ["operator.py", "graph.py", "prompt.py"]def check_files_exist(basic_path, required_files):@@ -104,6 +111,7 @@ class Optimizer:动态读取指定轮次的 Prompt和Graph。"""# 构建 prompt.py 文件的相对路径+ # examples/ags/w_action_node/optimized/gsm8k/graphs/round_1prompt_file_path = os.path.join(graphs_path, "prompt.py")graph_file_path = os.path.join(graphs_path, "graph.py")@@ -228,7 +236,7 @@ class Optimizer:"""# TODO 读取basic模版(从对应的dataset文件夹 {dataset}/basic/operator.py, graph.py, prompt.py ),Operator几乎不用动# TODO 动Prompt内容;动Graph连接- graph_path = f"{self.root_path}/graphs"+ graph_path = f"{self._optimized_path}/{self.dataset}/graphs"f"{graph_path}/round_{self.round + 1}"# TODO 填充Optimize 逻辑