move stanford_town folder

This commit is contained in:
better629 2024-03-28 16:40:51 +08:00
parent 183cd45521
commit 8c8b054438
94 changed files with 119 additions and 102 deletions

View file

@ -1,2 +0,0 @@
storage/test*
storage/unittest*

View file

@ -7,15 +7,15 @@ from typing import Optional
import fire
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.stanford_town import StanfordTown
from examples.stanford_town.utils.const import STORAGE_PATH
from examples.stanford_town.utils.mg_ga_transform import (
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.stanford_town import StanfordTown
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH
from metagpt.ext.stanford_town.utils.mg_ga_transform import (
get_reverie_meta,
write_curr_sim_code,
write_curr_step,
)
from examples.stanford_town.utils.utils import copy_folder
from metagpt.ext.stanford_town.utils.utils import copy_folder
from metagpt.logs import logger

View file

@ -1,3 +1,4 @@
# path to store simulation data
test_*
unittest*
July*

View file

@ -1,13 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :
from pathlib import Path
ROOT_PATH = Path(__file__).parent.parent
STORAGE_PATH = ROOT_PATH.joinpath("storage")
TEMP_STORAGE_PATH = ROOT_PATH.joinpath("temp_storage")
MAZE_ASSET_PATH = ROOT_PATH.joinpath("static_dirs/assets/the_ville")
PROMPTS_DIR = ROOT_PATH.joinpath("prompts")
collision_block_id = "32125"

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc : stanford town implement

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# @Desc : summarize relationship in a agent chat
from examples.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# @Desc : device to talk to another role, return yes or no
from examples.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -5,10 +5,9 @@
import random
from metagpt.environment.stanford_town.env_space import EnvObsParams, EnvObsType
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger
from .st_action import STAction
class GenActionSector(STAction):
name: str = "GenActionSector"

View file

@ -3,10 +3,9 @@
# @Desc : gen_daily_schedule
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger
from .st_action import STAction
class GenDailySchedule(STAction):
name: str = "GenDailySchedule"

View file

@ -2,9 +2,9 @@
# -*- coding: utf-8 -*-
# @Desc : generate_iterative_chat_utt
from examples.stanford_town.actions.st_action import STAction
from examples.stanford_town.utils.utils import extract_first_json_dict
from metagpt.environment.stanford_town.env_space import EnvObsParams, EnvObsType
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.utils.utils import extract_first_json_dict
from metagpt.logs import logger

View file

@ -1,4 +1,8 @@
from examples.stanford_town.actions.st_action import STAction
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -4,7 +4,7 @@
import datetime
from examples.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -4,7 +4,7 @@
import re
from examples.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -7,9 +7,9 @@ from abc import abstractmethod
from pathlib import Path
from typing import Any, Optional, Union
from examples.stanford_town.utils.const import PROMPTS_DIR
from metagpt.actions.action import Action
from metagpt.config2 import config
from metagpt.ext.stanford_town.utils.const import PROMPTS_DIR
from metagpt.logs import logger

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# @Desc : summarize the content of agents' conversation
from examples.stanford_town.actions.st_action import STAction
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger

View file

@ -4,10 +4,9 @@
import datetime
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger
from ..actions.st_action import STAction
class TaskDecomp(STAction):
name: str = "TaskDecomp"

View file

@ -3,10 +3,9 @@
# @Desc : wake_up
from metagpt.ext.stanford_town.actions.st_action import STAction
from metagpt.logs import logger
from ..actions.st_action import STAction
class WakeUp(STAction):
name: str = "WakeUp"

View file

@ -7,8 +7,8 @@ import datetime
from numpy import dot
from numpy.linalg import norm
from examples.stanford_town.memory.agent_memory import BasicMemory
from examples.stanford_town.utils.utils import get_embedding
from metagpt.ext.stanford_town.memory.agent_memory import BasicMemory
from metagpt.ext.stanford_town.utils.utils import get_embedding
def agent_retrieve(

View file

@ -4,9 +4,9 @@
from typing import Tuple
from examples.stanford_town.actions.agent_chat_sum_rel import AgentChatSumRel
from examples.stanford_town.actions.gen_iter_chat_utt import GenIterChatUTT
from examples.stanford_town.memory.retrieve import new_agent_retrieve
from metagpt.ext.stanford_town.actions.agent_chat_sum_rel import AgentChatSumRel
from metagpt.ext.stanford_town.actions.gen_iter_chat_utt import GenIterChatUTT
from metagpt.ext.stanford_town.memory.retrieve import new_agent_retrieve
from metagpt.logs import logger

View file

@ -7,21 +7,20 @@ import math
import random
from typing import Tuple, Union
from metagpt.ext.stanford_town.actions.decide_to_talk import DecideToTalk
from metagpt.ext.stanford_town.actions.gen_action_details import GenActionDetails
from metagpt.ext.stanford_town.actions.gen_daily_schedule import GenDailySchedule
from metagpt.ext.stanford_town.actions.gen_hourly_schedule import GenHourlySchedule
from metagpt.ext.stanford_town.actions.new_decomp_schedule import NewDecompSchedule
from metagpt.ext.stanford_town.actions.summarize_conv import SummarizeConv
from metagpt.ext.stanford_town.actions.task_decomp import TaskDecomp
from metagpt.ext.stanford_town.actions.wake_up import WakeUp
from metagpt.ext.stanford_town.memory.retrieve import new_agent_retrieve
from metagpt.ext.stanford_town.plan.converse import agent_conversation
from metagpt.ext.stanford_town.utils.utils import get_embedding
from metagpt.llm import LLM
from metagpt.logs import logger
from ..actions.decide_to_talk import DecideToTalk
from ..actions.gen_action_details import GenActionDetails
from ..actions.gen_daily_schedule import GenDailySchedule
from ..actions.gen_hourly_schedule import GenHourlySchedule
from ..actions.new_decomp_schedule import NewDecompSchedule
from ..actions.summarize_conv import SummarizeConv
from ..actions.task_decomp import TaskDecomp
from ..actions.wake_up import WakeUp
from ..memory.retrieve import new_agent_retrieve
from ..plan.converse import agent_conversation
from ..utils.utils import get_embedding
async def plan(role: "STRole", roles: dict["STRole"], new_day: bool, retrieved: dict) -> str:
# PART 1: Generate the hourly schedule.

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc : stanford town prompt templates

View file

@ -5,7 +5,7 @@
import datetime
import time
from examples.stanford_town.actions.run_reflect_action import (
from metagpt.ext.stanford_town.actions.run_reflect_action import (
AgentChatPoignancy,
AgentEventPoignancy,
AgentEventTriple,
@ -14,8 +14,8 @@ from examples.stanford_town.actions.run_reflect_action import (
AgentMemoryOnConvo,
AgentPlanThoughtOnConvo,
)
from examples.stanford_town.memory.retrieve import new_agent_retrieve
from examples.stanford_town.utils.utils import get_embedding
from metagpt.ext.stanford_town.memory.retrieve import new_agent_retrieve
from metagpt.ext.stanford_town.utils.utils import get_embedding
from metagpt.logs import logger

View file

@ -20,21 +20,6 @@ from typing import TYPE_CHECKING, Optional
from pydantic import ConfigDict, Field, field_validator, model_validator
from examples.stanford_town.actions.dummy_action import DummyAction, DummyMessage
from examples.stanford_town.actions.inner_voice_action import AgentWhisperThoughtAction
from examples.stanford_town.actions.run_reflect_action import AgentEventTriple
from examples.stanford_town.memory.agent_memory import AgentMemory, BasicMemory
from examples.stanford_town.memory.scratch import Scratch
from examples.stanford_town.memory.spatial_memory import MemoryTree
from examples.stanford_town.plan.st_plan import plan
from examples.stanford_town.reflect.reflect import generate_poig_score, role_reflect
from examples.stanford_town.utils.const import STORAGE_PATH, collision_block_id
from examples.stanford_town.utils.mg_ga_transform import (
get_role_environment,
save_environment,
save_movement,
)
from examples.stanford_town.utils.utils import get_embedding, path_finder
from metagpt.actions.add_requirement import UserRequirement
from metagpt.environment.stanford_town.env_space import (
EnvAction,
@ -42,6 +27,23 @@ from metagpt.environment.stanford_town.env_space import (
EnvObsParams,
EnvObsType,
)
from metagpt.ext.stanford_town.actions.dummy_action import DummyAction, DummyMessage
from metagpt.ext.stanford_town.actions.inner_voice_action import (
AgentWhisperThoughtAction,
)
from metagpt.ext.stanford_town.actions.run_reflect_action import AgentEventTriple
from metagpt.ext.stanford_town.memory.agent_memory import AgentMemory, BasicMemory
from metagpt.ext.stanford_town.memory.scratch import Scratch
from metagpt.ext.stanford_town.memory.spatial_memory import MemoryTree
from metagpt.ext.stanford_town.plan.st_plan import plan
from metagpt.ext.stanford_town.reflect.reflect import generate_poig_score, role_reflect
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH, collision_block_id
from metagpt.ext.stanford_town.utils.mg_ga_transform import (
get_role_environment,
save_environment,
save_movement,
)
from metagpt.ext.stanford_town.utils.utils import get_embedding, path_finder
from metagpt.logs import logger
from metagpt.roles.role import Role, RoleContext
from metagpt.schema import Message

View file

@ -4,10 +4,10 @@
from typing import Any, Optional
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.utils.const import MAZE_ASSET_PATH
from metagpt.context import Context
from metagpt.environment import StanfordTownEnv
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.utils.const import MAZE_ASSET_PATH
from metagpt.logs import logger
from metagpt.team import Team

View file

@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :
from pathlib import Path
from metagpt.const import EXAMPLE_PATH
ST_ROOT_PATH = Path(__file__).parent.parent
STORAGE_PATH = EXAMPLE_PATH.joinpath("stanford_town/storage")
TEMP_STORAGE_PATH = EXAMPLE_PATH.joinpath("stanford_town/temp_storage")
MAZE_ASSET_PATH = ST_ROOT_PATH.joinpath("static_dirs/assets/the_ville")
PROMPTS_DIR = ST_ROOT_PATH.joinpath("prompts")
collision_block_id = "32125"

View file

@ -5,7 +5,7 @@
from pathlib import Path
from typing import Optional
from examples.stanford_town.utils.const import STORAGE_PATH, TEMP_STORAGE_PATH
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH, TEMP_STORAGE_PATH
from metagpt.logs import logger
from metagpt.utils.common import read_json_file, write_json_file

View file

@ -1,3 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc : prompt templates
# @Desc :

View file

@ -4,17 +4,17 @@
import pytest
from examples.stanford_town.actions.gen_action_details import (
from metagpt.environment import StanfordTownEnv
from metagpt.environment.api.env_api import EnvAPIAbstract
from metagpt.ext.stanford_town.actions.gen_action_details import (
GenActionArena,
GenActionDetails,
GenActionObject,
GenActionSector,
GenActObjDescription,
)
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.utils.const import MAZE_ASSET_PATH
from metagpt.environment import StanfordTownEnv
from metagpt.environment.api.env_api import EnvAPIAbstract
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.utils.const import MAZE_ASSET_PATH
@pytest.mark.asyncio

View file

@ -4,7 +4,7 @@
import pytest
from examples.stanford_town.actions.summarize_conv import SummarizeConv
from metagpt.ext.stanford_town.actions.summarize_conv import SummarizeConv
@pytest.mark.asyncio

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :

View file

@ -6,9 +6,9 @@ from datetime import datetime, timedelta
import pytest
from examples.stanford_town.memory.agent_memory import AgentMemory
from examples.stanford_town.memory.retrieve import agent_retrieve
from examples.stanford_town.utils.const import STORAGE_PATH
from metagpt.ext.stanford_town.memory import AgentMemory
from metagpt.ext.stanford_town.memory.retrieve import agent_retrieve
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH
from metagpt.logs import logger
"""

View file

@ -6,7 +6,7 @@ from datetime import datetime, timedelta
import pytest
from examples.stanford_town.memory.agent_memory import BasicMemory
from metagpt.ext.stanford_town.memory.agent_memory import BasicMemory
from metagpt.logs import logger
"""

View file

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
# @Desc : the unittest of MemoryTree
from ..memory.spatial_memory import MemoryTree
from ..utils.const import STORAGE_PATH
from metagpt.ext.stanford_town.memory.spatial_memory import MemoryTree
from metagpt.ext.stanford_town.utils.const import STORAGE_PATH
def test_spatial_memory():

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :

View file

@ -6,12 +6,12 @@ from typing import Tuple
import pytest
from examples.stanford_town.plan.converse import agent_conversation
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.utils.const import MAZE_ASSET_PATH, STORAGE_PATH
from examples.stanford_town.utils.mg_ga_transform import get_reverie_meta
from examples.stanford_town.utils.utils import copy_folder
from metagpt.environment import StanfordTownEnv
from metagpt.ext.stanford_town.plan.converse import agent_conversation
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.utils.const import MAZE_ASSET_PATH, STORAGE_PATH
from metagpt.ext.stanford_town.utils.mg_ga_transform import get_reverie_meta
from metagpt.ext.stanford_town.utils.utils import copy_folder
async def init_two_roles(fork_sim_code: str = "base_the_ville_isabella_maria_klaus") -> Tuple["STRole"]:

View file

@ -4,12 +4,12 @@
import pytest
from examples.stanford_town.plan.st_plan import (
from metagpt.ext.stanford_town.plan.st_plan import (
_choose_retrieved,
_should_react,
_wait_react,
)
from examples.stanford_town.tests.plan.test_converse import init_two_roles
from tests.metagpt.ext.stanford_town.plan.test_conversation import init_two_roles
def test_should_react():

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Desc :

View file

@ -4,10 +4,10 @@
import pytest
from examples.stanford_town.memory.agent_memory import BasicMemory
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.utils.const import MAZE_ASSET_PATH
from metagpt.environment import StanfordTownEnv
from metagpt.ext.stanford_town.memory.agent_memory import BasicMemory
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.utils.const import MAZE_ASSET_PATH
@pytest.mark.asyncio

View file

@ -4,14 +4,14 @@
import pytest
from examples.stanford_town.actions.run_reflect_action import (
from metagpt.environment import StanfordTownEnv
from metagpt.ext.stanford_town.actions.run_reflect_action import (
AgentEventTriple,
AgentFocusPt,
AgentInsightAndGuidance,
)
from examples.stanford_town.roles.st_role import STRole
from examples.stanford_town.utils.const import MAZE_ASSET_PATH
from metagpt.environment import StanfordTownEnv
from metagpt.ext.stanford_town.roles.st_role import STRole
from metagpt.ext.stanford_town.utils.const import MAZE_ASSET_PATH
@pytest.mark.asyncio