mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
change context_fill to xml_fill
This commit is contained in:
parent
35acb98d7a
commit
828d187681
12 changed files with 23 additions and 22 deletions
|
|
@ -25,7 +25,7 @@ from examples.aflow.scripts.operator_an import (
|
|||
ReviseOp,
|
||||
|
||||
)
|
||||
from examples.aflow.scripts.prompt import (
|
||||
from examples.aflow.scripts.prompts.prompt import (
|
||||
FORMAT_PROMPT,
|
||||
ANSWER_GENERATION_PROMPT,
|
||||
SC_ENSEMBLE_PROMPT,
|
||||
|
|
@ -73,7 +73,7 @@ class AnswerGenerate(Operator):
|
|||
|
||||
async def __call__(self, input: str, mode: str = None) -> Tuple[str, str]:
|
||||
prompt = ANSWER_GENERATION_PROMPT.format(input=input)
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="xml_fill")
|
||||
return response
|
||||
|
||||
class CustomCodeGenerate(Operator):
|
||||
|
|
@ -105,7 +105,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
@ -295,7 +295,7 @@ class Review(Operator):
|
|||
|
||||
async def __call__(self, problem, solution, mode: str = None):
|
||||
prompt = REVIEW_PROMPT.format(problem=problem, solution=solution)
|
||||
response = await self._fill_node(ReviewOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ReviewOp, prompt, mode="xml_fill")
|
||||
return response
|
||||
|
||||
class Revise(Operator):
|
||||
|
|
@ -304,7 +304,7 @@ class Revise(Operator):
|
|||
|
||||
async def __call__(self, problem, solution, feedback, mode: str = None):
|
||||
prompt = REVISE_PROMPT.format(problem=problem, solution=solution, feedback=feedback)
|
||||
response = await self._fill_node(ReviseOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ReviseOp, prompt, mode="xml_fill")
|
||||
return response
|
||||
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ class MdEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = MD_ENSEMBLE_PROMPT.format(solutions=solution_text, question=problem)
|
||||
response = await self._fill_node(MdEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(MdEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "A")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class AnswerGenerate(Operator):
|
|||
|
||||
async def __call__(self, input: str, mode: str = None) -> Tuple[str, str]:
|
||||
prompt = ANSWER_GENERATION_PROMPT.format(input=input)
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="xml_fill")
|
||||
return response
|
||||
|
||||
class ScEnsemble(Operator):
|
||||
|
|
@ -73,7 +73,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class AnswerGenerate(Operator):
|
|||
|
||||
async def __call__(self, input: str, mode: str = None) -> Tuple[str, str]:
|
||||
prompt = ANSWER_GENERATION_PROMPT.format(input=input)
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(AnswerGenerateOp, prompt, mode="xml_fill")
|
||||
return response
|
||||
|
||||
class ScEnsemble(Operator):
|
||||
|
|
@ -73,7 +73,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class ScEnsemble(Operator):
|
|||
solution_text += f"{chr(65 + index)}: \n{str(solution)}\n\n\n"
|
||||
|
||||
prompt = SC_ENSEMBLE_PROMPT.format(solutions=solution_text)
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="context_fill")
|
||||
response = await self._fill_node(ScEnsembleOp, prompt, mode="xml_fill")
|
||||
|
||||
answer = response.get("solution_letter", "")
|
||||
answer = answer.strip().upper()
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class Optimizer:
|
|||
)
|
||||
|
||||
graph_optimize_node = await ActionNode.from_pydantic(GraphOptimize).fill(
|
||||
context=graph_optimize_prompt, mode="context_fill", llm=self.optimize_llm
|
||||
context=graph_optimize_prompt, mode="xml_fill", llm=self.optimize_llm
|
||||
)
|
||||
|
||||
response = await self.graph_utils.get_graph_optimize_response(graph_optimize_node)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class ReviseMode(Enum):
|
|||
TAG = "CONTENT"
|
||||
class FillMode(Enum):
|
||||
CODE_FILL = "code_fill"
|
||||
CONTEXT_FILL = "context_fill"
|
||||
XML_FILL = "xml_fill"
|
||||
SINGLE_FILL = "single_fill"
|
||||
|
||||
LANGUAGE_CONSTRAINT = "Language: Please use the same language as Human INPUT."
|
||||
|
|
@ -542,7 +542,7 @@ class ActionNode:
|
|||
result = {field_name: content}
|
||||
return result
|
||||
|
||||
async def context_fill(self, context):
|
||||
async def xml_fill(self, context):
|
||||
"""
|
||||
使用XML标签填充上下文并根据字段类型进行转换,包括字符串、整数、布尔值、列表和字典类型
|
||||
"""
|
||||
|
|
@ -628,9 +628,9 @@ class ActionNode:
|
|||
self.instruct_content = self.create_class()(**result)
|
||||
return self
|
||||
|
||||
elif mode == FillMode.CONTEXT_FILL.value:
|
||||
elif mode == FillMode.XML_FILL.value:
|
||||
context = self.xml_compile(context=self.context)
|
||||
result = await self.context_fill(context)
|
||||
result = await self.xml_fill(context)
|
||||
self.instruct_content = self.create_class()(**result)
|
||||
return self
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@
|
|||
# @Desc : Entrance of AFlow.
|
||||
|
||||
from examples.aflow.scripts.optimizer import Optimizer
|
||||
from examples.aflow.scripts.evaluator import DatasetType, QuestionType, OptimizerType
|
||||
from examples.aflow.data.download_data import download
|
||||
from metagpt.configs.models_config import ModelsConfig
|
||||
from typing import Literal
|
||||
|
||||
# DatasetType, QuestionType, and OptimizerType definitions
|
||||
DatasetType = Literal["HumanEval", "MBPP", "GSM8K", "MATH", "HotpotQA", "DROP"]
|
||||
QuestionType = Literal["math", "code", "qa"]
|
||||
OptimizerType = Literal["Graph", "Test"]
|
||||
# DatasetType = Literal["HumanEval", "MBPP", "GSM8K", "MATH", "HotpotQA", "DROP"]
|
||||
# QuestionType = Literal["math", "code", "qa"]
|
||||
# OptimizerType = Literal["Graph", "Test"]
|
||||
|
||||
# When you fisrt use, please download the datasets and initial rounds; If you want to get a look of the results, please download the results.
|
||||
# download(["datasets", "results", "initial_rounds"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue