Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask data interpreter to automatically save generated Python codes and calculation results? #1245

Closed
sunweihunu opened this issue May 5, 2024 · 1 comment

Comments

@sunweihunu
Copy link

How to fix the following demo and ask data interpreter to automatically save generated Python codes and calculation results to a specific folder ?

import asyncio
from metagpt.roles.di.data_interpreter import DataInterpreter

async def main():
    di = DataInterpreter()
    await di.run("Run data analysis on sklearn Iris dataset, include a plot")

asyncio.run(main())  # or await main() in a jupyter notebook setting
@geekan
Copy link
Owner

geekan commented May 18, 2024

There's an example: https://github.com/geekan/MetaGPT/blob/main/examples/di/data_visualization.py

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()
    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))

@geekan geekan closed this as completed May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants