diff --git a/metagpt/actions/debug_error.py b/metagpt/actions/debug_error.py index 78a9e2409..75375a4fd 100644 --- a/metagpt/actions/debug_error.py +++ b/metagpt/actions/debug_error.py @@ -43,4 +43,8 @@ class DebugError(Action): code = CodeParser.parse_code(block="", text=rsp) return file_name, code - \ No newline at end of file +<<<<<<< HEAD + +======= + +>>>>>>> 57ffca3b5c4559ac28b257ad5cb45f584769440d diff --git a/metagpt/actions/run_code.py b/metagpt/actions/run_code.py index 0c8149c11..24e33c89a 100644 --- a/metagpt/actions/run_code.py +++ b/metagpt/actions/run_code.py @@ -1,63 +1,22 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -@Time : 2023/5/11 17:46 +@Time : 2023/5/11 22:12 @Author : alexanderwu -@File : run_code.py +@File : environment.py """ -import traceback -import os -import subprocess -from typing import List, Tuple +import asyncio +from typing import Iterable -from metagpt.logs import logger -from metagpt.actions.action import Action +from pydantic import BaseModel, Field -PROMPT_TEMPLATE = """ -Role: You are a senior development and qa engineer, your role is summarize the code running result. -If the running result does not include an error, you should explicitly approve the result. -On the other hand, if the running result indicates some error, you should point out which part, the development code or the test code, produces the error, -and give specific instructions on fixing the errors. Here is the code info: -{context} -Now you should begin your analysis ---- -## instruction: -Please summarize the cause of the errors and give correction instruction -## File To Rewrite: -Determine the ONE file to rewrite in order to fix the error, for example, xyz.py, or test_xyz.py -## Status: -Determine if all of the code works fine, if so write PASS, else FAIL, -WRITE ONLY ONE WORD, PASS OR FAIL, IN THI SECTION -## Send To: -Please write Engineer if the errors are due to problematic development codes, and QaEngineer to problematic test codes, and NoOne if there are no errors, -WRITE ONLY ONE WORD, Engineer OR QaEngineer OR NoOne, IN THIS SECTION. ---- -You should fill in necessary instruction, status, send to, and finally return all content between the --- segment line. -""" +from metagpt.memory import Memory +from metagpt.roles import Role +from metagpt.schema import Message -CONTEXT = """ -## Development Code File Name -{code_file_name} -## Development Code -```python -{code} -``` -## Test File Name -{test_file_name} -## Test Code -```python -{test_code} -``` -## Running Command -{command} -## Running Output -standard output: {outs}; -standard errors: {errs}; -""" -class RunCode(Action): - def __init__(self, name="RunCode", context=None, llm=None): - super().__init__(name, context, llm) +class Environment(BaseModel): + """Environment that carries a set of roles. Roles can publish messages to the environment, which can be observed by other roles.""" @classmethod async def run_text(cls, code) -> Tuple[str, str]: @@ -119,4 +78,4 @@ class RunCode(Action): result = context + rsp - return result \ No newline at end of file + return result