FIx Format and Some bugs in android_assistant.py

This commit is contained in:
didi 2024-03-04 16:47:27 +08:00 committed by better629
parent 0f0f41fb30
commit 732cf36fbc
13 changed files with 223 additions and 143 deletions

View file

@ -9,7 +9,12 @@ from typing import Any, Optional
from pydantic import Field
from metagpt.const import ADB_EXEC_FAIL
from metagpt.environment.base_env import Environment, ExtEnv, mark_as_readable, mark_as_writeable
from metagpt.environment.base_env import (
Environment,
ExtEnv,
mark_as_readable,
mark_as_writeable,
)
class AndroidExtEnv(Environment, ExtEnv):
@ -42,7 +47,7 @@ class AndroidExtEnv(Environment, ExtEnv):
return f"adb -s {self.device_id} "
def execute_adb_with_cmd(self, adb_cmd: str) -> str:
adb_cmd = adb_cmd.replace('\\', '/')
adb_cmd = adb_cmd.replace("\\", "/")
res = subprocess.run(adb_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
exec_res = ADB_EXEC_FAIL
if not res.returncode:

View file

@ -49,6 +49,7 @@ def mark_as_writeable(func):
env_write_api_registry[func.__name__] = get_function_schema(func)
return func
class ExtEnv(BaseModel):
"""External Env to integrate actual game environment"""