use llm cache to make exp_pool

This commit is contained in:
seehi 2024-07-08 10:09:36 +08:00
parent d902a6f18c
commit c624c0ffc7
41 changed files with 844 additions and 368 deletions

View file

@ -7,16 +7,15 @@ from metagpt.exp_pool import exp_cache, exp_manager
from metagpt.logs import logger
@exp_cache(pass_exps_to_func=True)
async def produce(req, exps=None):
logger.info(f"Previous experiences: {exps}")
@exp_cache()
async def produce(req=""):
return f"{req} {uuid.uuid4().hex}"
async def main():
req = "Water"
resp = await produce(req)
resp = await produce(req=req)
logger.info(f"The resp of `produce{req}` is: {resp}")
exps = await exp_manager.query_exps(req)

View file

@ -50,9 +50,9 @@ async def generate_novel():
"Fill the empty nodes with your own ideas. Be creative! Use your own words!"
"I will tip you $100,000 if you write a good novel."
)
novel_node = await ActionNode.from_pydantic(Novel).fill(context=instruction, llm=LLM())
novel_node = await ActionNode.from_pydantic(Novel).fill(req=instruction, llm=LLM())
chap_node = await ActionNode.from_pydantic(Chapters).fill(
context=f"### instruction\n{instruction}\n### novel\n{novel_node.content}", llm=LLM()
req=f"### instruction\n{instruction}\n### novel\n{novel_node.content}", llm=LLM()
)
print(chap_node.instruct_content)