Skip to content

Commit f780483

Browse files
committed
refactor: fix the dependency in core folder
1 parent 7567141 commit f780483

28 files changed

+1001
-194
lines changed

metagpt/core/base/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
from metagpt.core.base.base_env import BaseEnvironment
2-
from metagpt.core.base.base_role import BaseRole
32

43

5-
__all__ = [
6-
"BaseEnvironment",
7-
"BaseRole",
8-
]
4+
__all__ = ["BaseEnvironment"]

metagpt/core/base/base_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from abc import abstractmethod
77
from typing import Any, Optional
88

9-
from metagpt.base.base_env_space import BaseEnvAction, BaseEnvObsParams
10-
from metagpt.base.base_serialization import BaseSerialization
9+
from metagpt.core.base.base_env_space import BaseEnvAction, BaseEnvObsParams
10+
from metagpt.core.base.base_serialization import BaseSerialization
1111

1212
if typing.TYPE_CHECKING:
1313
from metagpt.schema import Message

metagpt/core/config.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
"""
88
import os
99
from pathlib import Path
10-
from typing import Dict, Iterable, List, Literal, Optional
10+
from typing import Dict, Iterable, Literal
1111

12-
from pydantic import BaseModel, Field, model_validator
12+
from pydantic import BaseModel, model_validator
1313

14-
from metagpt.configs.embedding_config import EmbeddingConfig
15-
from metagpt.core.configs.llm_config import LLMConfig, LLMType
16-
from metagpt.configs.omniparse_config import OmniParseConfig
17-
from metagpt.configs.role_custom_config import RoleCustomConfig
18-
from metagpt.configs.workspace_config import WorkspaceConfig
19-
from metagpt.const import CONFIG_ROOT, METAGPT_ROOT
14+
from metagpt.core.configs.llm_config import LLMConfig
15+
from metagpt.core.const import CONFIG_ROOT, METAGPT_ROOT
2016
from metagpt.core.utils.yaml_model import YamlModel
2117

2218

@@ -51,7 +47,6 @@ class CoreConfig(CLIParams, YamlModel):
5147
# Misc Parameters
5248
repair_llm_output: bool = False
5349
prompt_schema: Literal["json", "markdown", "raw"] = "json"
54-
workspace: WorkspaceConfig = Field(default_factory=WorkspaceConfig)
5550

5651
@classmethod
5752
def from_home(cls, path):
@@ -113,4 +108,4 @@ def merge_dict(dicts: Iterable[Dict]) -> Dict:
113108
return result
114109

115110

116-
_CONFIG_CACHE = {}
111+
_CONFIG_CACHE = {}

metagpt/core/configs/llm_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
from pydantic import field_validator
1313

14-
from metagpt.configs.compress_msg_config import CompressType
15-
from metagpt.const import CONFIG_ROOT, LLM_API_TIMEOUT, METAGPT_ROOT
16-
from metagpt.utils.yaml_model import YamlModel
14+
from metagpt.core.configs.compress_msg_config import CompressType
15+
from metagpt.core.const import CONFIG_ROOT, LLM_API_TIMEOUT, METAGPT_ROOT
16+
from metagpt.core.utils.yaml_model import YamlModel
1717

1818

1919
class LLMType(Enum):

metagpt/core/configs/models_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from metagpt.core.config import merge_dict
2121
from metagpt.core.configs.llm_config import LLMConfig
22-
from metagpt.const import CONFIG_ROOT, METAGPT_ROOT
22+
from metagpt.core.const import CONFIG_ROOT, METAGPT_ROOT
2323
from metagpt.core.utils.yaml_model import YamlModel
2424

2525

metagpt/core/const.py

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,8 @@ def get_metagpt_root():
3838
# METAGPT PROJECT ROOT AND VARS
3939
CONFIG_ROOT = Path.home() / ".metagpt"
4040
METAGPT_ROOT = get_metagpt_root() # Dependent on METAGPT_PROJECT_ROOT
41-
DEFAULT_WORKSPACE_ROOT = METAGPT_ROOT / "workspace"
42-
43-
EXAMPLE_PATH = METAGPT_ROOT / "examples"
44-
EXAMPLE_DATA_PATH = EXAMPLE_PATH / "data"
45-
DATA_PATH = METAGPT_ROOT / "data"
46-
DABENCH_PATH = EXAMPLE_PATH / "di/InfiAgent-DABench/data"
47-
EXAMPLE_BENCHMARK_PATH = EXAMPLE_PATH / "data/rag_bm"
48-
TEST_DATA_PATH = METAGPT_ROOT / "tests/data"
49-
RESEARCH_PATH = DATA_PATH / "research"
50-
TUTORIAL_PATH = DATA_PATH / "tutorial_docx"
51-
INVOICE_OCR_TABLE_PATH = DATA_PATH / "invoice_table"
52-
53-
UT_PATH = DATA_PATH / "ut"
54-
SWAGGER_PATH = UT_PATH / "files/api/"
55-
UT_PY_PATH = UT_PATH / "files/ut/"
56-
API_QUESTIONS_PATH = UT_PATH / "files/question/"
57-
58-
SERDESER_PATH = DEFAULT_WORKSPACE_ROOT / "storage" # TODO to store `storage` under the individual generated project
59-
60-
TMP = METAGPT_ROOT / "tmp"
61-
62-
SOURCE_ROOT = METAGPT_ROOT / "metagpt"
63-
PROMPT_PATH = SOURCE_ROOT / "prompts"
64-
SKILL_DIRECTORY = SOURCE_ROOT / "skills"
65-
TOOL_SCHEMA_PATH = METAGPT_ROOT / "metagpt/tools/schemas"
66-
TOOL_LIBS_PATH = METAGPT_ROOT / "metagpt/tools/libs"
67-
68-
# TEMPLATE PATH
69-
TEMPLATE_FOLDER_PATH = METAGPT_ROOT / "template"
70-
VUE_TEMPLATE_PATH = TEMPLATE_FOLDER_PATH / "vue_template"
71-
REACT_TEMPLATE_PATH = TEMPLATE_FOLDER_PATH / "react_template"
7241

7342
# REAL CONSTS
74-
7543
MEM_TTL = 24 * 30 * 3600
7644

7745
MESSAGE_ROUTE_FROM = "sent_from"
@@ -82,49 +50,17 @@ def get_metagpt_root():
8250
MESSAGE_ROUTE_TO_NONE = "<none>"
8351
MESSAGE_ROUTE_TO_SELF = "<self>" # Add this tag to replace `ActionOutput`
8452

85-
86-
REQUIREMENT_FILENAME = "requirement.txt"
53+
CORE_REQUIREMENT_FILENAME = "requirement_core.txt"
8754
BUGFIX_FILENAME = "bugfix.txt"
88-
PACKAGE_REQUIREMENTS_FILENAME = "requirements.txt"
89-
90-
DOCS_FILE_REPO = "docs"
91-
PRDS_FILE_REPO = "docs/prd"
92-
SYSTEM_DESIGN_FILE_REPO = "docs/system_design"
93-
TASK_FILE_REPO = "docs/task"
94-
CODE_PLAN_AND_CHANGE_FILE_REPO = "docs/code_plan_and_change"
95-
COMPETITIVE_ANALYSIS_FILE_REPO = "resources/competitive_analysis"
96-
DATA_API_DESIGN_FILE_REPO = "resources/data_api_design"
97-
SEQ_FLOW_FILE_REPO = "resources/seq_flow"
98-
SYSTEM_DESIGN_PDF_FILE_REPO = "resources/system_design"
99-
PRD_PDF_FILE_REPO = "resources/prd"
100-
TASK_PDF_FILE_REPO = "resources/api_spec_and_task"
101-
CODE_PLAN_AND_CHANGE_PDF_FILE_REPO = "resources/code_plan_and_change"
102-
TEST_CODES_FILE_REPO = "tests"
103-
TEST_OUTPUTS_FILE_REPO = "test_outputs"
104-
CODE_SUMMARIES_FILE_REPO = "docs/code_summary"
105-
CODE_SUMMARIES_PDF_FILE_REPO = "resources/code_summary"
106-
RESOURCES_FILE_REPO = "resources"
107-
SD_OUTPUT_FILE_REPO = DEFAULT_WORKSPACE_ROOT
108-
GRAPH_REPO_FILE_REPO = "docs/graph_repo"
109-
VISUAL_GRAPH_REPO_FILE_REPO = "resources/graph_db"
110-
CLASS_VIEW_FILE_REPO = "docs/class_view"
111-
112-
YAPI_URL = "http://yapi.deepwisdomai.com/"
113-
SD_URL = "http://172.31.0.51:49094"
11455

11556
DEFAULT_LANGUAGE = "English"
11657
DEFAULT_MAX_TOKENS = 1500
11758
COMMAND_TOKENS = 500
118-
SKILL_PATH = "SKILL_PATH"
119-
SERPER_API_KEY = "SERPER_API_KEY"
12059
DEFAULT_TOKEN_SIZE = 500
12160

12261
# format
12362
BASE64_FORMAT = "base64"
12463

125-
# REDIS
126-
REDIS_KEY = "REDIS_KEY"
127-
12864
# Message id
12965
IGNORED_MESSAGE_ID = "0"
13066

@@ -150,12 +86,5 @@ def get_metagpt_root():
15086
AGENT = "agent"
15187
IMAGES = "images"
15288

153-
154-
# experience pool
155-
EXPERIENCE_MASK = "<experience>"
156-
157-
# TeamLeader's name
158-
TEAMLEADER_NAME = "Mike"
159-
16089
DEFAULT_MIN_TOKEN_COUNT = 10000
16190
DEFAULT_MAX_TOKEN_COUNT = 100000000

metagpt/core/context.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
from pydantic import BaseModel, ConfigDict, Field
1414

15-
from metagpt.config2 import Config
16-
from metagpt.configs.llm_config import LLMConfig, LLMType
17-
from metagpt.provider.base_llm import BaseLLM
18-
from metagpt.provider.llm_provider_registry import create_llm_instance
19-
from metagpt.utils.cost_manager import (
15+
from metagpt.core.config import CoreConfig
16+
from metagpt.core.configs.llm_config import LLMConfig, LLMType
17+
from metagpt.core.provider.base_llm import BaseLLM
18+
from metagpt.core.provider.llm_provider_registry import create_llm_instance
19+
from metagpt.core.utils.cost_manager import (
2020
CostManager,
2121
FireworksCostManager,
2222
TokenCostManager,
@@ -61,7 +61,7 @@ class Context(BaseModel):
6161
model_config = ConfigDict(arbitrary_types_allowed=True)
6262

6363
kwargs: AttrDict = AttrDict()
64-
config: Config = Field(default_factory=Config.default)
64+
config: CoreConfig = Field(default_factory=CoreConfig.default)
6565

6666
cost_manager: CostManager = CostManager()
6767

0 commit comments

Comments
 (0)