mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
update env
This commit is contained in:
parent
2289763dfe
commit
ff6f27f0a3
9 changed files with 46 additions and 8 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# @Desc : MG Android Env
|
||||
|
||||
from metagpt.env.android_env.android_ext_env import AndroidExtEnv
|
||||
from metagpt.environment.android_env.android_ext_env import AndroidExtEnv
|
||||
|
||||
|
||||
class AndroidEnv(AndroidExtEnv):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class EnvAPIAbstract(BaseModel):
|
|||
class EnvAPIRegistry(BaseModel):
|
||||
"""the registry to store environment w&r api/interface"""
|
||||
|
||||
registry: dict[str, dict[str, Union[dict, Any, str]]] = Field(default=dict(), exclude=True)
|
||||
registry: dict[str, Callable] = Field(default=dict(), exclude=True)
|
||||
|
||||
def get(self, api_name: str):
|
||||
if api_name not in self.registry:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ def mark_as_readable(func):
|
|||
def mark_as_writeable(func):
|
||||
"""mark functionn as a writeable one in ExtEnv, it does something to ExtEnv"""
|
||||
env_write_api_registry[func.__name__] = get_function_schema(func)
|
||||
return func
|
||||
|
||||
|
||||
class ExtEnv(BaseModel):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Desc :
|
||||
# @Desc : MG Gym Env
|
||||
|
||||
|
||||
class GymEnv:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Desc :
|
||||
# @Desc : MG Mincraft Env
|
||||
|
||||
from metagpt.environment.mincraft_env.mincraft_ext_env import MincraftExtEnv
|
||||
|
||||
|
||||
class MincraftEnv(MincraftExtEnv):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Desc :
|
||||
# @Desc : The Mincraft external environment to integrate with Mincraft game
|
||||
|
||||
from metagpt.environment.base_env import ExtEnv
|
||||
|
||||
|
||||
class MincraftExtEnv(ExtEnv):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# @Desc : MG Werewolf Env
|
||||
|
||||
from metagpt.env.werewolf_env.werewolf_ext_env import WerewolfExtEnv
|
||||
from metagpt.environment.werewolf_env.werewolf_ext_env import WerewolfExtEnv
|
||||
|
||||
|
||||
class WerewolfEnv(WerewolfExtEnv):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from enum import Enum
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from metagpt.env.base_env import ExtEnv, mark_as_readable, mark_as_writeable
|
||||
from metagpt.environment.base_env import ExtEnv, mark_as_readable, mark_as_writeable
|
||||
|
||||
|
||||
class RoleState(Enum):
|
||||
|
|
|
|||
|
|
@ -604,6 +604,29 @@ def read_csv_to_list(curr_file: str, header=False, strip_trail=True):
|
|||
return analysis_list[0], analysis_list[1:]
|
||||
|
||||
|
||||
def read_csv_to_list(curr_file: str, header=False, strip_trail=True):
|
||||
"""
|
||||
Reads in a csv file to a list of list. If header is True, it returns a
|
||||
tuple with (header row, all rows)
|
||||
ARGS:
|
||||
curr_file: path to the current csv file.
|
||||
RETURNS:
|
||||
List of list where the component lists are the rows of the file.
|
||||
"""
|
||||
logger.debug(f"start read csv: {curr_file}")
|
||||
analysis_list = []
|
||||
with open(curr_file) as f_analysis_file:
|
||||
data_reader = csv.reader(f_analysis_file, delimiter=",")
|
||||
for count, row in enumerate(data_reader):
|
||||
if strip_trail:
|
||||
row = [i.strip() for i in row]
|
||||
analysis_list += [row]
|
||||
if not header:
|
||||
return analysis_list
|
||||
else:
|
||||
return analysis_list[0], analysis_list[1:]
|
||||
|
||||
|
||||
def import_class(class_name: str, module_name: str) -> type:
|
||||
module = importlib.import_module(module_name)
|
||||
a_class = getattr(module, class_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue