Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

update watch action

betterwangd284c89df8a6
diff --git a/examples/andriod_assistant/roles/android_assistant.py b/examples/andriod_assistant/roles/android_assistant.py
index c4512cc22..606d582f7 100644
--- a/examples/andriod_assistant/roles/android_assistant.py
+++ b/examples/andriod_assistant/roles/android_assistant.py
@@ -11,7 +11,7 @@ from examples.andriod_assistant.actions.manual_record import ManualRecord
from examples.andriod_assistant.actions.parse_record import ParseRecord
from examples.andriod_assistant.actions.screenshot_parse import ScreenshotParse
from examples.andriod_assistant.actions.self_learn_and_reflect import SelfLearnAndReflect
-from examples.andriod_assistant.utils.schema import RunState
+from examples.andriod_assistant.utils.schema import RunState, AndroidActionOutput
from metagpt.actions.add_requirement import UserRequirement
from metagpt.config2 import config
from metagpt.logs import logger
@@ -34,7 +34,7 @@ class AndroidAssistant(Role):
def __init__(self, **data):
super().__init__(**data)
- self._watch([UserRequirement, ScreenshotParse, SelfLearnAndReflect])
+ self._watch([UserRequirement, AndroidActionOutput])
app_name = config.get_other("app_name", "demo")
curr_path = Path(__file__).parent
diff --git a/examples/andriod_assistant/run_assistant.py b/examples/andriod_assistant/run_assistant.py
index e1c4b0362..eb80c2111 100644
--- a/examples/andriod_assistant/run_assistant.py
+++ b/examples/andriod_assistant/run_assistant.py
@@ -4,6 +4,7 @@
import asyncio
from pathlib import Path
+
import typer
from examples.andriod_assistant.roles.android_assistant import AndroidAssistant
@@ -36,10 +37,7 @@ def startup(
default="/sdcard",
help="The path to store xml files for determining UI elements localtion. Make sure it exists.",
),
- device_id : str = typer.Option(
- default="emulator-5554",
- help="The Android device_id"
- ),
+ device_id: str = typer.Option(default="emulator-5554", help="The Android device_id"),
):
config.set_other(
{
@@ -50,15 +48,17 @@ def startup(
"min_dist": min_dist,
"android_screenshot_dir": android_screenshot_dir,
"android_xml_dir": android_xml_dir,
- "device_id":device_id
+ "device_id": device_id,
}
)
- team = Team(env=AndroidEnv(
- device_id=device_id,
- xml_dir=Path(android_xml_dir),
- screenshot_dir=Path(android_screenshot_dir),
- ))
+ team = Team(
+ env=AndroidEnv(
+ device_id=device_id,
+ xml_dir=Path(android_xml_dir),
+ screenshot_dir=Path(android_screenshot_dir),
+ )
+ )
team.hire([AndroidAssistant()])
team.invest(investment)
diff --git a/examples/andriod_assistant/test.py b/examples/andriod_assistant/tests/test.py
similarity index 100%
rename from examples/andriod_assistant/test.py
rename to examples/andriod_assistant/tests/test.py
diff --git a/examples/andriod_assistant/test_for_an.py b/examples/andriod_assistant/tests/test_for_an.py
similarity index 93%
rename from examples/andriod_assistant/test_for_an.py
rename to examples/andriod_assistant/tests/test_for_an.py
index bccb5f3b3..7dddaabf5 100644
--- a/examples/andriod_assistant/test_for_an.py
+++ b/examples/andriod_assistant/tests/test_for_an.py
@@ -4,10 +4,12 @@
import asyncio
import time
from pathlib import Path
+
from actions.manual_record import ManualRecord
from actions.parse_record import ParseRecord
-from actions.self_learn_and_reflect import SelfLearnAndReflect
from actions.screenshot_parse import ScreenshotParse
+from actions.self_learn_and_reflect import SelfLearnAndReflect
+
from metagpt.environment.android_env.android_env import AndroidEnv
TASK_PATH = Path("apps/Contacts")
@@ -47,20 +49,20 @@ if __name__ == "__main__":
last_act="",
task_dir=TASK_PATH / "demos" / f"self_learning_{DEMO_NAME}",
docs_dir=SELF_EXPLORE_DOC_PATH,
- env=test_env_self_learn_android
+ env=test_env_self_learn_android,
),
test_manual_record.run(
# demo_name=DEMO_NAME,
task_dir=TASK_PATH / "demos" / f"manual_record_{DEMO_NAME}",
task_desc="Create a contact in Contacts App named zjy with a phone number +86 18831933368 ",
- env=test_env_manual_learn_android
+ env=test_env_manual_learn_android,
),
test_manual_parse.run(
app_name="Contacts",
# demo_name=DEMO_NAME,
task_dir=TASK_PATH / "demos" / f"manual_record_{DEMO_NAME}", # 修要修改
docs_dir=PARSE_RECORD_DOC_PATH, # 需要修改
- env=test_env_manual_learn_android
+ env=test_env_manual_learn_android,
),
test_screenshot_parse.run(
round_count=20,
@@ -69,8 +71,8 @@ if __name__ == "__main__":
task_dir=TASK_PATH / f"act_{DEMO_NAME}",
docs_dir=PARSE_RECORD_DOC_PATH,
env=test_env_screenshot_parse_android,
- grid_on=False
- )
+ grid_on=False,
+ ),
]
loop.run_until_complete(asyncio.gather(*test_action_list))