mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-04 05:12:37 +02:00
update watch action
This commit is contained in:
parent
e1c0ae32cf
commit
d284c89df8
4 changed files with 20 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue