Merge pull request #1090 from luxiangtaoya/main

updata di example and change the location of the .ipynb locations
This commit is contained in:
garylin2099 2024-03-25 12:07:06 +08:00 committed by GitHub
commit 4d8234763c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -1,14 +1,17 @@
import asyncio
from metagpt.logs import logger
from metagpt.roles.di.data_interpreter import DataInterpreter
from metagpt.utils.recovery_util import save_history
async def main(requirement: str = ""):
di = DataInterpreter()
await di.run(requirement)
rsp = await di.run(requirement)
logger.info(rsp)
save_history(role=di)
if __name__ == "__main__":
requirement = "Run data analysis on sklearn Iris dataset, include a plot"
asyncio.run(main(requirement))

View file

@ -54,5 +54,5 @@ def save_history(role: Role, save_dir: str = ""):
with open(save_path / "plan.json", "w", encoding="utf-8") as plan_file:
json.dump(plan, plan_file, indent=4, ensure_ascii=False)
save_code_file(name=Path(record_time) / "history_nb", code_context=role.execute_code.nb, file_format="ipynb")
save_code_file(name=Path(record_time), code_context=role.execute_code.nb, file_format="ipynb")
return save_path