🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
update task_dir/docs_dir
better629c2d959c3628f
diff --git a/examples/andriod_assistant/roles/android_assistant.py b/examples/andriod_assistant/roles/android_assistant.pyindex ee510f25c..05665b90b 100644--- a/examples/andriod_assistant/roles/android_assistant.py+++ b/examples/andriod_assistant/roles/android_assistant.py@@ -1,10 +1,11 @@#!/usr/bin/env python# -*- coding: utf-8 -*-# @Desc : android assistant to learn from app operations and operate apps-+import timefrom typing import Optionalfrom pathlib import Pathfrom pydantic import Field+from datetime import datetimefrom examples.andriod_assistant.actions.manual_record import ManualRecordfrom examples.andriod_assistant.actions.parse_record import ParseRecord@@ -35,6 +36,10 @@ class AndroidAssistant(Role):self._watch([UserRequirement])+ app_name = config.get_other("app_name", "demo")+ data_dir = Path(__file__).parent.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,run the learn first and then do the act stage or learn it during the action."""@@ -42,14 +47,29 @@ class AndroidAssistant(Role):# choose ManualRecord and then run ParseRecord# Remember, only run each action only one time, no need to run n_round.self.set_actions([ManualRecord, ParseRecord])+ self.task_dir = data_dir.joinpath(app_name, f"manual_learn_{cur_datetime}")+ self.docs_dir = data_dir.joinpath(f"manual_docs")elif config.get_other("stage") == "learn" and config.get_other("mode") == "auto":# choose SelfLearnAndReflect to runself.set_actions([SelfLearnAndReflect])+ self.task_dir = data_dir.joinpath(app_name, f"auto_learn_{cur_datetime}")+ self.docs_dir = data_dir.joinpath(f"auto_docs")elif config.get_other("stage") == "act":# choose ScreenshotParse to runself.set_actions([ScreenshotParse])+ self.task_dir = data_dir.joinpath(app_name, f"act_{cur_datetime}")+ if config.get_other("mode") == "manual":+ self.docs_dir = data_dir.joinpath(f"manual_docs")+ else:+ self.docs_dir = data_dir.joinpath(f"auto_docs")+ self._check_dir()+self._set_react_mode(RoleReactMode.BY_ORDER)+ def _check_dir(self):+ self.task_dir.mkdir(exist_ok=True)+ self.docs_dir.mkdir(exist_ok=True)+async def react(self) -> Message:self.round_count += 1super().react()diff --git a/examples/andriod_assistant/run_assistant.py b/examples/andriod_assistant/run_assistant.pyindex 4d599e80b..ce15d9511 100644--- a/examples/andriod_assistant/run_assistant.py+++ b/examples/andriod_assistant/run_assistant.py@@ -20,6 +20,7 @@ def startup(n_round: int = typer.Option(default=20, help="The max round to do an app operation task."),stage: str = typer.Option(default="learn", help="stage: learn / act"),mode: str = typer.Option(default="auto", help="mode: auto / manual , when state=learn"),+ app_name: str = typer.Option(default="demo", help="the name of app you want to run"),investment: float = typer.Option(default=5.0, help="Dollar amount to invest in the AI company."),refine_doc: bool = typer.Option(default=False, help="Refine existing operation docs based on the latest observation if True."@@ -40,6 +41,7 @@ def startup({"stage": stage,"mode": mode,+ "app_name": app_name,"refine_doc": refine_doc,"min_dist": min_dist,"android_screenshot_dir": android_screenshot_dir,