add FileManager and provide issue fixing example

This commit is contained in:
yzlin 2024-04-03 03:58:56 +08:00
parent 5e34038831
commit 8648a7646e
4 changed files with 243 additions and 0 deletions

View file

@ -0,0 +1,33 @@
# This is a real issue from MetaGPT: https://github.com/geekan/MetaGPT/issues/1067
# with corresponding bugfix as https://github.com/geekan/MetaGPT/pull/1069
# We demonstrate that DataInterpreter has the capability to fix such issues.
# Prerequisite: You need to manually add back the bug in your local file metagpt/utils/repair_llm_raw_output.py
# to test the DataInterpreter's issue solving ability.
import asyncio
from metagpt.roles.di.data_interpreter import DataInterpreter
REQ = """
# Requirement
Below is a github issue, solve it. Use FileManager to search for the function, understand it, and modify the relevant code.
Write a new test file test.py with FileManager and use Terminal to python the test file to ensure you have fixed the issue.
When writing test.py, you should import the function from the file you modified and test it with the given input.
Notice: Don't write all codes in one response, each time, just write code for one step.
# Issue
>> s = "-1"
>> print(extract_state_value_from_output(s))
>> 1
The extract_state_value_from_output function will process -1 into 1,
resulted in an infinite loop for the react mode.
"""
async def main():
di = DataInterpreter(tools=["Terminal", "FileManager"], react_mode="react")
await di.run(REQ)
if __name__ == "__main__":
asyncio.run(main())