🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
update andriod_assistant const and test data
better629e2ed85f197d3
diff --git a/examples/andriod_assistant/README.md b/examples/andriod_assistant/README.mdindex 60649a573..9d5cb5c3e 100644--- a/examples/andriod_assistant/README.md+++ b/examples/andriod_assistant/README.md@@ -17,13 +17,13 @@ pip install -r requirements.txtBy designating the app to explore and the method of learning (automatic or manual demonstration), you can facilitate Android Assistant to master the functions of various apps, thereby generating respective documentation for later use during the phase termed as "Automation of routine tasks". For any given task objective, conducting approximately 20 cycles of exploration can considerably enhance the performance. You can experiment with both the automatic learning and manual demonstration modes for the "contacts" app by implementing the ensuing commands:```bash-python run_assistant.py "your task description" --stage "learn" --mode "auto/manual" --app-name "Contacts"+python run_assistant.py "your task description" --stage "learn" --mode "auto or manual" --app-name "Contacts"```## Free Your HandsOnce the Android Assistant has completed ample exploration, you are all set to automate your tasks! By utilizing either text description or voice input, you can instruct the Android Assistant to perform the desired tasks across various applications. For the specific command processes, please see the following recommendations:### By Text```bash-python run_assistant.py "your task description" --stage "act" --mode "auto/manual" --app-name "app names"+python run_assistant.py "your task description" --stage "act" --mode "auto or manual" --app-name "app names"```### By Voicecoming soondiff --git a/examples/andriod_assistant/roles/android_assistant.py b/examples/andriod_assistant/roles/android_assistant.pyindex eccea298e..2c57521fe 100644--- a/examples/andriod_assistant/roles/android_assistant.py+++ b/examples/andriod_assistant/roles/android_assistant.py@@ -14,6 +14,7 @@ from examples.andriod_assistant.actions.screenshot_parse import ScreenshotParsefrom examples.andriod_assistant.actions.self_learn_and_reflect import (SelfLearnAndReflect,)+from examples.andriod_assistant.utils.const import ROOT_PATHfrom examples.andriod_assistant.utils.schema import AndroidActionOutput, RunStatefrom metagpt.actions.add_requirement import UserRequirementfrom metagpt.config2 import config@@ -40,8 +41,7 @@ class AndroidAssistant(Role):self._watch([UserRequirement, AndroidActionOutput])self.task_desc = config.get_other("task_desc", "Just explore any app in this phone!")app_name = config.get_other("app_name", "demo")- curr_path = Path(__file__).parent- data_dir = curr_path.joinpath("..", "output")+ data_dir = ROOT_PATH.joinpath("output")cur_datetime = datetime.fromtimestamp(int(time.time())).strftime("%Y-%m-%d_%H-%M-%S")"""Firstly, we decide the state with user config, further, we can do it automatically, like if it's new app,diff --git a/examples/andriod_assistant/tests/test.py b/examples/andriod_assistant/tests/test.pyindex ee60d654b..4b3e0af88 100644--- a/examples/andriod_assistant/tests/test.py+++ b/examples/andriod_assistant/tests/test.py@@ -5,7 +5,6 @@import astimport asyncioimport re-from pathlib import Pathfrom examples.andriod_assistant.actions.parse_record_an import RECORD_PARSE_NODEfrom examples.andriod_assistant.prompts.operation_prompt import (@@ -15,17 +14,19 @@ from examples.andriod_assistant.prompts.operation_prompt import (tap_doc_template,text_doc_template,)+from examples.andriod_assistant.utils.const import ROOT_PATHfrom examples.andriod_assistant.utils.schema import ActionOp, SwipeOpfrom metagpt.actions.action import Actionfrom metagpt.config2 import configfrom metagpt.logs import loggerfrom metagpt.utils.common import encode_image-TEST_BEFORE_PATH = Path("apps/demo_Contacts/labeled_screenshots/demo_Contacts_2024-01-30_21-50-19_1.png")-TEST_AFTER_PATH = Path("apps/demo_Contacts/labeled_screenshots/demo_Contacts_2024-01-30_21-50-19_2.png")-RECORD_PATH = Path("apps/demo_Contacts/record.txt")-TASK_DESC_PATH = Path("apps/demo_Contacts/task_desc.txt")-DOCS_DIR = Path("storage")+TASK_PATH = ROOT_PATH.parent.joinpath("data/demo_Contacts")+TEST_BEFORE_PATH = TASK_PATH.joinpath("labeled_screenshots/demo_Contacts_2024-01-24_12-07-55_3.png")+TEST_AFTER_PATH = TASK_PATH.joinpath("labeled_screenshots/demo_Contacts_2024-01-24_12-07-55_4.png")+RECORD_PATH = TASK_PATH.joinpath("record.txt")+TASK_DESC_PATH = TASK_PATH.joinpath("task_desc.txt")+DOCS_DIR = TASK_PATH.joinpath("storage")testaction = Action(name="test")diff --git a/examples/andriod_assistant/tests/test_for_an.py b/examples/andriod_assistant/tests/test_for_an.pyindex a5aa1fb09..2acf4601e 100644--- a/examples/andriod_assistant/tests/test_for_an.py+++ b/examples/andriod_assistant/tests/test_for_an.py@@ -12,35 +12,41 @@ from examples.andriod_assistant.actions.screenshot_parse import ScreenshotParsefrom examples.andriod_assistant.actions.self_learn_and_reflect import (SelfLearnAndReflect,)+from examples.andriod_assistant.utils.const import ROOT_PATHfrom metagpt.environment.android_env.android_env import AndroidEnv-TASK_PATH = Path("apps/Contacts")+TASK_PATH = ROOT_PATH.joinpath("unitest_Contacts")DEMO_NAME = str(time.time())-SELF_EXPLORE_DOC_PATH = TASK_PATH.joinpath("autodocs")-PARSE_RECORD_DOC_PATH = TASK_PATH.joinpath("demodocs")+SELF_EXPLORE_DOC_PATH = TASK_PATH.joinpath("auto_docs")+PARSE_RECORD_DOC_PATH = TASK_PATH.joinpath("demo_docs")++device_id = "emulator-5554"+xml_dir = Path("/sdcard")+screenshot_dir = Path("/sdcard/Pictures/Screenshots")test_env_self_learn_android = AndroidEnv(- device_id="emulator-5554",- xml_dir=Path("/sdcard"),- screenshot_dir=Path("/sdcard/Pictures/Screenshots"),+ device_id=device_id,+ xml_dir=xml_dir,+ screenshot_dir=screenshot_dir,)test_self_learning = SelfLearnAndReflect()test_env_manual_learn_android = AndroidEnv(- device_id="emulator-5554",- xml_dir=Path("/sdcard"),- screenshot_dir=Path("/sdcard/Pictures/Screenshots"),+ device_id=device_id,+ xml_dir=xml_dir,+ screenshot_dir=screenshot_dir,)test_manual_record = ManualRecord()test_manual_parse = ParseRecord()test_env_screenshot_parse_android = AndroidEnv(- device_id="emulator-5554",- xml_dir=Path("/sdcard"),- screenshot_dir=Path("/sdcard/Pictures/Screenshots"),+ device_id=device_id,+ xml_dir=xml_dir,+ screenshot_dir=screenshot_dir,)test_screenshot_parse = ScreenshotParse()+if __name__ == "__main__":loop = asyncio.get_event_loop()diff --git a/examples/andriod_assistant/utils/const.py b/examples/andriod_assistant/utils/const.pyindex 5c373a6f9..0c7951156 100644--- a/examples/andriod_assistant/utils/const.py+++ b/examples/andriod_assistant/utils/const.py@@ -2,4 +2,7 @@# -*- coding: utf-8 -*-# @Desc :+from pathlib import Path++ROOT_PATH = Path(__file__).parent.parent.absolute()ADB_EXEC_FAIL = "FAILED"