From 385f049fa335cde4e810dd7de77110084115bd1d Mon Sep 17 00:00:00 2001 From: better629 Date: Tue, 3 Oct 2023 19:11:05 +0800 Subject: [PATCH] fix add inner voice type mismatch problem --- examples/st_game/compress_sim_storage.py | 6 +++-- examples/st_game/maze.py | 5 +++-- examples/st_game/maze_environment.py | 2 +- examples/st_game/roles/st_role.py | 28 ++++++++++++------------ examples/st_game/run_st_game.py | 10 ++++----- examples/st_game/stanford_town.py | 4 ++-- examples/st_game/utils/utils.py | 2 +- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/examples/st_game/compress_sim_storage.py b/examples/st_game/compress_sim_storage.py index eb07b9a4d..ead34a248 100644 --- a/examples/st_game/compress_sim_storage.py +++ b/examples/st_game/compress_sim_storage.py @@ -7,8 +7,9 @@ Description: Compresses a simulation for replay demos. import shutil import json -from utils.utils import find_filenames, create_folder_if_not_there -from utils.const import STORAGE_PATH + +from examples.st_game.utils.utils import find_filenames, create_folder_if_not_there +from examples.st_game.utils.const import STORAGE_PATH def compress(sim_code): @@ -64,5 +65,6 @@ def compress(sim_code): shutil.copyfile(meta_file, f"{compressed_storage}/meta.json") shutil.copytree(persona_folder, f"{compressed_storage}/personas/") + if __name__ == '__main__': compress("July1_the_ville_isabella_maria_klaus-step-3-9") diff --git a/examples/st_game/maze.py b/examples/st_game/maze.py index 73440a2a3..a62b1da6e 100644 --- a/examples/st_game/maze.py +++ b/examples/st_game/maze.py @@ -14,8 +14,9 @@ import json import math from pathlib import Path import networkx as nx -from utils.const import MAZE_ASSET_PATH -from utils.utils import read_csv_to_list + +from examples.st_game.utils.const import MAZE_ASSET_PATH +from examples.st_game.utils.utils import read_csv_to_list class Maze: diff --git a/examples/st_game/maze_environment.py b/examples/st_game/maze_environment.py index e0a16f3de..894ace49b 100644 --- a/examples/st_game/maze_environment.py +++ b/examples/st_game/maze_environment.py @@ -7,7 +7,7 @@ from pydantic import Field from metagpt.environment import Environment from metagpt.roles.role import Role -from maze import Maze +from examples.st_game.maze import Maze class MazeEnvironment(Environment): diff --git a/examples/st_game/roles/st_role.py b/examples/st_game/roles/st_role.py index bd96b70c6..1521d0336 100644 --- a/examples/st_game/roles/st_role.py +++ b/examples/st_game/roles/st_role.py @@ -119,7 +119,7 @@ class STRole(Role): observed = self._rc.env.memory.get_by_actions(self._rc.watch) self._rc.news = self._rc.memory.remember(observed) - if len(self._rc.news) == 1 and isinstance(self._rc.news[0], UserRequirement): + if len(self._rc.news) == 1 and self._rc.news[0].cause_by == UserRequirement: # add inner voice # TODO logger.warning(f"Role: {self.name} add inner voice: {self._rc.news[0].content}") @@ -469,19 +469,19 @@ class STRole(Role): # TODO retrieve, use self._rc.memory 's retrieve functions # TODO plan - plan = self.plan() - - # TODO reflect - - # TODO execute(feed-back into maze_env) - next_tile, pronunciatio, description = self.execute(plan) - role_move = { - "movement": next_tile, - "pronunciatio": pronunciatio, - "description": description, - "chat": self.scratch.chat - } - save_movement(self.name, role_move, step=self.step, sim_code=self.sim_code, curr_time=self.curr_time) + # plan = self.plan() + # + # # TODO reflect + # + # # TODO execute(feed-back into maze_env) + # next_tile, pronunciatio, description = self.execute(plan) + # role_move = { + # "movement": next_tile, + # "pronunciatio": pronunciatio, + # "description": description, + # "chat": self.scratch.chat + # } + # save_movement(self.name, role_move, step=self.step, sim_code=self.sim_code, curr_time=self.curr_time) # step update logger.info(f"Role: {self.name} run at {self.step} step on {self.curr_time}") diff --git a/examples/st_game/run_st_game.py b/examples/st_game/run_st_game.py index 954b3f946..722308120 100644 --- a/examples/st_game/run_st_game.py +++ b/examples/st_game/run_st_game.py @@ -5,11 +5,11 @@ import asyncio import fire -from stanford_town import StanfordTown -from roles.st_role import STRole -from utils.mg_ga_transform import get_reverie_meta -from utils.const import STORAGE_PATH -from utils.utils import copy_folder +from examples.st_game.stanford_town import StanfordTown +from examples.st_game.roles.st_role import STRole +from examples.st_game.utils.mg_ga_transform import get_reverie_meta +from examples.st_game.utils.const import STORAGE_PATH +from examples.st_game.utils.utils import copy_folder async def startup(idea: str, diff --git a/examples/st_game/stanford_town.py b/examples/st_game/stanford_town.py index 0522710f7..d259dbc36 100644 --- a/examples/st_game/stanford_town.py +++ b/examples/st_game/stanford_town.py @@ -9,8 +9,8 @@ from metagpt.roles.role import Role from metagpt.schema import Message from metagpt.logs import logger -from maze_environment import MazeEnvironment -from actions.user_requirement import UserRequirement +from examples.st_game.maze_environment import MazeEnvironment +from examples.st_game.actions.user_requirement import UserRequirement class StanfordTown(SoftwareCompany): diff --git a/examples/st_game/utils/utils.py b/examples/st_game/utils/utils.py index a2cfabb54..097e41387 100644 --- a/examples/st_game/utils/utils.py +++ b/examples/st_game/utils/utils.py @@ -41,7 +41,7 @@ def read_csv_to_list(curr_file: str, header=False, strip_trail=True): RETURNS: List of list where the component lists are the rows of the file. """ - logger.info(f"start read csv: {curr_file}") + logger.debug(f"start read csv: {curr_file}") if not header: analysis_list = [] with open(curr_file) as f_analysis_file: