fix add inner voice type mismatch problem

This commit is contained in:
better629 2023-10-03 19:11:05 +08:00
parent 13a69711f0
commit 385f049fa3
7 changed files with 30 additions and 27 deletions

View file

@ -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")

View file

@ -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:

View file

@ -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):

View file

@ -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}")

View file

@ -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,

View file

@ -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):

View file

@ -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: