mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
Merge branch 'data_analyst_ldy' into 'mgx_ops'
Data analyst ldy See merge request pub/MetaGPT!244
This commit is contained in:
commit
e7fed5e8e8
4 changed files with 16 additions and 5 deletions
|
|
@ -31,8 +31,12 @@ class WriteAnalysisCode(Action):
|
|||
|
||||
rsp = await self._aask(reflection_prompt, system_msgs=[REFLECTION_SYSTEM_MSG])
|
||||
reflection = json.loads(CodeParser.parse_code(text=rsp))
|
||||
try:
|
||||
improved_impl = CodeParser.parse_code(text=reflection["improved_impl"], lang="python")
|
||||
except Exception as e:
|
||||
improved_impl = reflection["improved_impl"]
|
||||
|
||||
return reflection["improved_impl"]
|
||||
return improved_impl
|
||||
|
||||
async def run(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ EXTRA_INSTRUCTION = """
|
|||
- When no click action is required, no need to use the browser tool to navigate to the webpage before scraping.
|
||||
- If you need detail HTML content, write code to get it but not to use the browser tool.
|
||||
- Make sure the command_name are certainly in Available Commands when you use the browser tool.
|
||||
7. When you are making plan. It is highly recommend to plan all the coding plan and reviews plan in first response.
|
||||
7. When you are making plan. It is highly recommend to plan and append all the tasks in first response once time.
|
||||
8. Don't finish_current_task multiple times for the same task.
|
||||
9. Finish current task timely, such as when the code is written and executed successfully.
|
||||
"""
|
||||
|
||||
TASK_TYPE_DESC = "\n".join([f"- **{tt.type_name}**: {tt.value.desc}" for tt in TaskType])
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ your code
|
|||
|
||||
REFLECTION_SYSTEM_MSG = """
|
||||
You are an AI Python assistant. You will be given your previous implementation code of a task, runtime error results, and a hint to change the implementation appropriately. Write your full implementation.
|
||||
When occuring ModuleNotFoundError, always install the required package. And use Terminal tool if available.
|
||||
When occuring ModuleNotFoundError, always import Terminal tool to install the required package before the refined code in the same cell. Such as `from metagpt.tools.libs.terminal import Terminal\nterminal = Terminal()\nawait terminal.run_command('pip install pandas')` before importing pandas.
|
||||
"""
|
||||
|
||||
DEBUG_REFLECTION_EXAMPLE = '''
|
||||
|
|
|
|||
|
|
@ -60,14 +60,19 @@ class DataAnalyst(RoleZero):
|
|||
self.rc.working_memory.add(Message(content=browser_actions, role="user", cause_by="browser"))
|
||||
return memory
|
||||
|
||||
async def write_and_exec_code(self):
|
||||
"""Write a code block for current task and execute it in an interactive notebook environment."""
|
||||
async def write_and_exec_code(self, instruction: str = ""):
|
||||
"""Write a code block for current task and execute it in an interactive notebook environment.
|
||||
|
||||
Args:
|
||||
instruction: The specific task description for which the code needs to be written.
|
||||
"""
|
||||
counter = 0
|
||||
success = False
|
||||
await self.execute_code.init_code()
|
||||
|
||||
# plan info
|
||||
plan_status = self.planner.get_plan_status()
|
||||
plan_status = plan_status + f"\nFurther Task Instruction: {instruction}"
|
||||
|
||||
# tool info
|
||||
if self.custom_tool_recommender:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue