Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

test to test dir

femto2cd48705924b
diff --git a/examples/sk_agent.py b/examples/sk_agent.py
index e9ff69a90..f60e7299b 100644
--- a/examples/sk_agent.py
+++ b/examples/sk_agent.py
@@ -6,7 +6,6 @@
@File : sk_agent.py
"""
import asyncio
-import os
from semantic_kernel.core_skills import FileIOSkill, MathSkill, TextSkill, TimeSkill
from semantic_kernel.planning import SequentialPlanner
@@ -15,17 +14,11 @@ from semantic_kernel.planning import SequentialPlanner
from semantic_kernel.planning.action_planner.action_planner import ActionPlanner
from metagpt.actions import BossRequirement
+from metagpt.const import SKILL_DIRECTORY
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
from metagpt.tools.search_engine import SkSearchEngine
-# Get the directory of the current file
-current_file_directory = os.path.dirname(os.path.abspath(__file__))
-# Construct the skills_directory by joining the parent directory and "skillss"
-skills_directory = os.path.join(current_file_directory, "..", "metagpt", "skills")
-# Normalize the path to ensure it's in the correct format
-skills_directory = os.path.normpath(skills_directory)
-
async def main():
await basic_planner_example()
@@ -42,8 +35,8 @@ async def basic_planner_example():
role = SkAgent()
# let's give the agent some skills
- role.import_semantic_skill_from_directory(skills_directory, "SummarizeSkill")
- role.import_semantic_skill_from_directory(skills_directory, "WriterSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
await role.run(Message(content=task, cause_by=BossRequirement))
@@ -56,8 +49,8 @@ async def sequential_planner_example():
role = SkAgent(planner_cls=SequentialPlanner)
# let's give the agent some skills
- role.import_semantic_skill_from_directory(skills_directory, "SummarizeSkill")
- role.import_semantic_skill_from_directory(skills_directory, "WriterSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
await role.run(Message(content=task, cause_by=BossRequirement))
diff --git a/metagpt/const.py b/metagpt/const.py
index 35b4c9fa7..b8b08628e 100644
--- a/metagpt/const.py
+++ b/metagpt/const.py
@@ -12,9 +12,11 @@ def get_project_root():
"""Search upwards to find the project root directory."""
current_path = Path.cwd()
while True:
- if (current_path / '.git').exists() or \
- (current_path / '.project_root').exists() or \
- (current_path / '.gitignore').exists():
+ if (
+ (current_path / ".git").exists()
+ or (current_path / ".project_root").exists()
+ or (current_path / ".gitignore").exists()
+ ):
return current_path
parent_path = current_path.parent
if parent_path == current_path:
@@ -23,16 +25,18 @@ def get_project_root():
PROJECT_ROOT = get_project_root()
-DATA_PATH = PROJECT_ROOT / 'data'
-WORKSPACE_ROOT = PROJECT_ROOT / 'workspace'
-PROMPT_PATH = PROJECT_ROOT / 'metagpt/prompts'
-UT_PATH = PROJECT_ROOT / 'data/ut'
+DATA_PATH = PROJECT_ROOT / "data"
+WORKSPACE_ROOT = PROJECT_ROOT / "workspace"
+PROMPT_PATH = PROJECT_ROOT / "metagpt/prompts"
+UT_PATH = PROJECT_ROOT / "data/ut"
SWAGGER_PATH = UT_PATH / "files/api/"
UT_PY_PATH = UT_PATH / "files/ut/"
API_QUESTIONS_PATH = UT_PATH / "files/question/"
YAPI_URL = "http://yapi.deepwisdomai.com/"
-TMP = PROJECT_ROOT / 'tmp'
+TMP = PROJECT_ROOT / "tmp"
RESEARCH_PATH = DATA_PATH / "research"
TUTORIAL_PATH = DATA_PATH / "tutorial_docx"
+SKILL_DIRECTORY = PROJECT_ROOT / "metagpt/skills"
+
MEM_TTL = 24 * 30 * 3600
diff --git a/metagpt/planner/__init__.py b/tests/metagpt/planner/__init__.py
similarity index 100%
rename from metagpt/planner/__init__.py
rename to tests/metagpt/planner/__init__.py
diff --git a/metagpt/planner/test_action_planner.py b/tests/metagpt/planner/test_action_planner.py
similarity index 71%
rename from metagpt/planner/test_action_planner.py
rename to tests/metagpt/planner/test_action_planner.py
index dcb023a0a..5ab9a493f 100644
--- a/metagpt/planner/test_action_planner.py
+++ b/tests/metagpt/planner/test_action_planner.py
@@ -5,8 +5,6 @@
@Author : femto Zheng
@File : test_basic_planner.py
"""
-import os
-
import pytest
from semantic_kernel.core_skills import FileIOSkill, MathSkill, TextSkill, TimeSkill
from semantic_kernel.planning.action_planner.action_planner import ActionPlanner
@@ -15,13 +13,6 @@ from metagpt.actions import BossRequirement
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
-# Get the directory of the current file
-current_file_directory = os.path.dirname(os.path.abspath(__file__))
-# Construct the skills_directory by joining the parent directory and "skillss"
-skills_directory = os.path.join(current_file_directory, "..", "skills")
-# Normalize the path to ensure it's in the correct format
-skills_directory = os.path.normpath(skills_directory)
-
@pytest.mark.asyncio
async def test_action_planner():
diff --git a/metagpt/planner/test_basic_planner.py b/tests/metagpt/planner/test_basic_planner.py
similarity index 66%
rename from metagpt/planner/test_basic_planner.py
rename to tests/metagpt/planner/test_basic_planner.py
index afe003725..03a82ec5e 100644
--- a/metagpt/planner/test_basic_planner.py
+++ b/tests/metagpt/planner/test_basic_planner.py
@@ -5,22 +5,14 @@
@Author : femto Zheng
@File : test_basic_planner.py
"""
-import os
-
import pytest
from semantic_kernel.core_skills import TextSkill
from metagpt.actions import BossRequirement
+from metagpt.const import SKILL_DIRECTORY
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
-# Get the directory of the current file
-current_file_directory = os.path.dirname(os.path.abspath(__file__))
-# Construct the skills_directory by joining the parent directory and "skillss"
-skills_directory = os.path.join(current_file_directory, "..", "skills")
-# Normalize the path to ensure it's in the correct format
-skills_directory = os.path.normpath(skills_directory)
-
@pytest.mark.asyncio
async def test_basic_planner():
@@ -30,8 +22,8 @@ async def test_basic_planner():
role = SkAgent()
# let's give the agent some skills
- role.import_semantic_skill_from_directory(skills_directory, "SummarizeSkill")
- role.import_semantic_skill_from_directory(skills_directory, "WriterSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
+ role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
role.recv(Message(content=task, cause_by=BossRequirement))